blob: ae7070777d2159776d70e65faee7ec9b0c60eb37 [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
3import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00004from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansena4e6ae61999-03-07 23:11:21 +00005sys.path.append(BGENDIR)
Jack Jansena4e6ae61999-03-07 23:11:21 +00006
7from scantools import Scanner
8
9def main():
10 input = "QDOffscreen.h"
11 output = "qdoffsgen.py"
12 defsoutput = TOOLBOXDIR + "QDOffscreen.py"
13 scanner = MyScanner(input, output, defsoutput)
14 scanner.scan()
15 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000016 print "=== Testing definitions output code ==="
17 execfile(defsoutput, {}, {})
Jack Jansena4e6ae61999-03-07 23:11:21 +000018 print "=== Done scanning and generating, now importing the generated code... ==="
19 import qdoffssupport
20 print "=== Done. It's up to you to compile it now! ==="
21
22class MyScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
29 if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
30 classname = "Method"
31 listname = "methods"
32 return classname, listname
33
34 def writeinitialdefs(self):
35 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36
37 def makeblacklistnames(self):
38 return [
39 'DisposeGWorld', # Implied when the object is deleted
40 'NewGWorldFromHBITMAP', # Don't know what the args do
Jack Jansena05ac601999-12-12 21:41:51 +000041 'GetGDeviceAttributes', # Windows-only
Jack Jansena4e6ae61999-03-07 23:11:21 +000042 ]
43
44 def makeblacklisttypes(self):
45 return [
46 "void_ptr", # GetGDeviceSurface, blacklisted for now
47 "Ptr", # Again, for now (array is probably ok here)
48 ]
49
50 def makerepairinstructions(self):
51 return [
52
53## ("UpdateGWorld",
54## [("GWorldPtr", "*", "OutMode")],
55## [("*", "*", "InOutMode")]),
56
57 # This one is incorrect: we say that all input gdevices are
58 # optional, but some are not. Most are, however, so users passing
59 # None for non-optional gdevices will get a qd error, I guess, in
60 # stead of a python argument error.
61 ([("GDHandle", "*", "InMode")],
62 [("OptGDHandle", "*", "InMode")]),
63 ]
64
65if __name__ == "__main__":
66 main()
67