blob: b2b55b22fc5f03e006b36d5bf5175d9d4e50d1ac [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()
16 print "=== Done scanning and generating, now importing the generated code... ==="
17 import qdoffssupport
18 print "=== Done. It's up to you to compile it now! ==="
19
20class MyScanner(Scanner):
21
22 def destination(self, type, name, arglist):
23 classname = "Function"
24 listname = "functions"
25 if arglist:
26 t, n, m = arglist[0]
27 if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
28 classname = "Method"
29 listname = "methods"
30 return classname, listname
31
32 def writeinitialdefs(self):
33 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
34
35 def makeblacklistnames(self):
36 return [
37 'DisposeGWorld', # Implied when the object is deleted
38 'NewGWorldFromHBITMAP', # Don't know what the args do
Jack Jansena05ac601999-12-12 21:41:51 +000039 'GetGDeviceAttributes', # Windows-only
Jack Jansena4e6ae61999-03-07 23:11:21 +000040 ]
41
42 def makeblacklisttypes(self):
43 return [
44 "void_ptr", # GetGDeviceSurface, blacklisted for now
45 "Ptr", # Again, for now (array is probably ok here)
46 ]
47
48 def makerepairinstructions(self):
49 return [
50
51## ("UpdateGWorld",
52## [("GWorldPtr", "*", "OutMode")],
53## [("*", "*", "InOutMode")]),
54
55 # This one is incorrect: we say that all input gdevices are
56 # optional, but some are not. Most are, however, so users passing
57 # None for non-optional gdevices will get a qd error, I guess, in
58 # stead of a python argument error.
59 ([("GDHandle", "*", "InMode")],
60 [("OptGDHandle", "*", "InMode")]),
61 ]
62
63if __name__ == "__main__":
64 main()
65