1 # Scan an Apple header file, generating a Python file of generator calls.
4 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
5 sys
.path
.append(BGENDIR
)
6 from bgenlocations
import TOOLBOXDIR
8 from scantools
import Scanner
11 input = "MacWindows.h"
13 defsoutput
= TOOLBOXDIR
+ "Windows.py"
14 scanner
= MyScanner(input, output
, defsoutput
)
17 print "=== Done scanning and generating, now importing the generated code... ==="
19 print "=== Done. It's up to you to compile it now! ==="
21 class MyScanner(Scanner
):
23 def destination(self
, type, name
, arglist
):
24 classname
= "Function"
25 listname
= "functions"
28 if t
in ("WindowPtr", "WindowPeek", "WindowRef") and m
== "InMode":
31 return classname
, listname
33 def writeinitialdefs(self
):
34 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
36 def makeblacklistnames(self
):
38 'DisposeWindow', # Implied when the object is deleted
42 def makeblacklisttypes(self
):
48 def makerepairinstructions(self
):
52 ([("Str255", "*", "InMode")],
53 [("*", "*", "OutMode")]),
55 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
56 [("InBuffer", "*", "*")]),
58 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
59 ("long", "*", "OutMode")],
60 [("VarVarOutBuffer", "*", "InOutMode")]),
62 ([("void", "wStorage", "OutMode")],
63 [("NullStorage", "*", "InMode")]),
65 ([("WindowPtr", "*", "OutMode")],
66 [("ExistingWindowPtr", "*", "*")]),
67 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
68 [("ExistingWindowPtr", "*", "*")]),
70 ([("WindowPtr", "FrontWindow", "ReturnMode")],
71 [("ExistingWindowPtr", "*", "*")]),
72 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
73 [("ExistingWindowPtr", "*", "*")]),
76 if __name__
== "__main__":