1 # Scan an Apple header file, generating a Python file of generator calls.
4 addpack
.addpack(':Tools:bgen:bgen')
6 from scantools
import Scanner
7 from bgenlocations
import TOOLBOXDIR
15 output
= SHORT
+ "gen.py"
16 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
17 scanner
= MyScanner(input, output
, defsoutput
)
20 print "=== Done scanning and generating, now importing the generated code... ==="
21 exec "import " + SHORT
+ "support"
22 print "=== Done. It's up to you to compile it now! ==="
24 class MyScanner(Scanner
):
26 def destination(self
, type, name
, arglist
):
27 classname
= "Function"
28 listname
= "functions"
31 if t
in ("DialogPtr", "DialogRef") and m
== "InMode":
34 return classname
, listname
36 def makeblacklistnames(self
):
40 # Dialogs are disposed when the object is deleted
52 def makeblacklisttypes(self
):
54 "AlertStdAlertParamPtr", # Too much work, for now
57 def makerepairinstructions(self
):
59 ([("Str255", "*", "InMode")],
60 [("*", "*", "OutMode")]),
62 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
63 [("InBuffer", "*", "*")]),
65 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
66 ("long", "*", "OutMode")],
67 [("VarVarOutBuffer", "*", "InOutMode")]),
69 # GetDialogItem return handle is optional
70 ([("Handle", "item", "OutMode")],
71 [("OptHandle", "item", "OutMode")]),
74 ([("void", "*", "OutMode")],
75 [("NullStorage", "*", "InMode")]),
77 ([("DialogPtr", "*", "OutMode")],
78 [("ExistingDialogPtr", "*", "*")]),
79 ([("DialogRef", "*", "OutMode")],
80 [("ExistingDialogPtr", "*", "*")]),
83 if __name__
== "__main__":