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
):
56 def makerepairinstructions(self
):
58 ([("Str255", "*", "InMode")],
59 [("*", "*", "OutMode")]),
61 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
62 [("InBuffer", "*", "*")]),
64 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
65 ("long", "*", "OutMode")],
66 [("VarVarOutBuffer", "*", "InOutMode")]),
68 # GetDialogItem return handle is optional
69 ([("Handle", "item", "OutMode")],
70 [("OptHandle", "item", "OutMode")]),
73 ([("void", "*", "OutMode")],
74 [("NullStorage", "*", "InMode")]),
76 ([("DialogPtr", "*", "OutMode")],
77 [("ExistingDialogPtr", "*", "*")]),
78 ([("DialogRef", "*", "OutMode")],
79 [("ExistingDialogPtr", "*", "*")]),
82 if __name__
== "__main__":