blob: 0ad98028b41dc70eec97ef76020945eaeee30989 [file] [log] [blame]
Jack Jansena4e6ae61999-03-07 23:11:21 +00001# Scan an Apple header file, generating a Python file of generator calls.
2import sys
Jack Jansenaaebdd62002-08-05 15:39:30 +00003from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansena4e6ae61999-03-07 23:11:21 +00004sys.path.append(BGENDIR)
Jack Jansena4e6ae61999-03-07 23:11:21 +00005
6from scantools import Scanner
7
8def main():
Tim Peters182b5ac2004-07-18 06:16:08 +00009 input = "QDOffscreen.h"
10 output = "qdoffsgen.py"
11 defsoutput = TOOLBOXDIR + "QDOffscreen.py"
12 scanner = MyScanner(input, output, defsoutput)
13 scanner.scan()
14 scanner.close()
15 print "=== Testing definitions output code ==="
16 execfile(defsoutput, {}, {})
17 print "=== Done scanning and generating, now importing the generated code... ==="
18 import qdoffssupport
19 print "=== Done. It's up to you to compile it now! ==="
Jack Jansena4e6ae61999-03-07 23:11:21 +000020
21class MyScanner(Scanner):
22
Tim Peters182b5ac2004-07-18 06:16:08 +000023 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
28 if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
29 classname = "Method"
30 listname = "methods"
31 return classname, listname
Jack Jansena4e6ae61999-03-07 23:11:21 +000032
Tim Peters182b5ac2004-07-18 06:16:08 +000033 def writeinitialdefs(self):
34 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansena4e6ae61999-03-07 23:11:21 +000035
Tim Peters182b5ac2004-07-18 06:16:08 +000036 def makeblacklistnames(self):
37 return [
38 'DisposeGWorld', # Implied when the object is deleted
39 'NewGWorldFromHBITMAP', # Don't know what the args do
40 'GetGDeviceAttributes', # Windows-only
41 ]
Jack Jansena4e6ae61999-03-07 23:11:21 +000042
Tim Peters182b5ac2004-07-18 06:16:08 +000043 def makeblacklisttypes(self):
44 return [
45 "void_ptr", # GetGDeviceSurface, blacklisted for now
46 "Ptr", # Again, for now (array is probably ok here)
47 ]
Jack Jansena4e6ae61999-03-07 23:11:21 +000048
Tim Peters182b5ac2004-07-18 06:16:08 +000049 def makerepairinstructions(self):
50 return [
51
52## ("UpdateGWorld",
53## [("GWorldPtr", "*", "OutMode")],
54## [("*", "*", "InOutMode")]),
55
56 # This one is incorrect: we say that all input gdevices are
57 # optional, but some are not. Most are, however, so users passing
58 # None for non-optional gdevices will get a qd error, I guess, in
59 # stead of a python argument error.
60 ([("GDHandle", "*", "InMode")],
61 [("OptGDHandle", "*", "InMode")]),
62 ]
Jack Jansena4e6ae61999-03-07 23:11:21 +000063
64if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000065 main()