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
40 'SetWindowProperty', # For the moment
42 'GetWindowPropertySize',
43 'RemoveWindowProperty',
44 # Constants with funny definitions
48 def makeblacklisttypes(self
):
52 'Collection', # For now, to be done later
53 'DragReference', # Ditto, dragmodule doesn't export it yet.
56 def makerepairinstructions(self
):
60 ([("Str255", "*", "InMode")],
61 [("*", "*", "OutMode")]),
63 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
64 [("InBuffer", "*", "*")]),
66 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
67 ("long", "*", "OutMode")],
68 [("VarVarOutBuffer", "*", "InOutMode")]),
70 ([("void", "wStorage", "OutMode")],
71 [("NullStorage", "*", "InMode")]),
73 ([("WindowPtr", "*", "OutMode")],
74 [("ExistingWindowPtr", "*", "*")]),
75 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
76 [("ExistingWindowPtr", "*", "*")]),
78 ([("WindowPtr", "FrontWindow", "ReturnMode")],
79 [("ExistingWindowPtr", "*", "*")]),
80 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
81 [("ExistingWindowPtr", "*", "*")]),
84 if __name__
== "__main__":