1 # Scan an Apple header file, generating a Python file of generator calls.
5 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
6 sys
.path
.append(BGENDIR
)
8 from scantools
import Scanner
9 from bgenlocations
import TOOLBOXDIR
17 output
= SHORT
+ "gen.py"
18 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
19 scanner
= MyScanner(input, output
, defsoutput
)
22 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT
+ "support"
24 print "=== Done. It's up to you to compile it now! ==="
26 class MyScanner(Scanner
):
28 def destination(self
, type, name
, arglist
):
29 classname
= "Function"
30 listname
= "functions"
33 if t
in ("DialogPtr", "DialogRef") and m
== "InMode":
36 return classname
, listname
38 def makeblacklistnames(self
):
42 # Dialogs are disposed when the object is deleted
53 # Can't find these in the CW Pro 3 libraries
54 'SetDialogMovableModal',
55 'GetDialogControlNotificationProc',
58 def makeblacklisttypes(self
):
60 "AlertStdAlertParamPtr", # Too much work, for now
61 "QTModelessCallbackProcPtr",
64 def makerepairinstructions(self
):
66 ([("Str255", "*", "InMode")],
67 [("*", "*", "OutMode")]),
69 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
72 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
73 ("long", "*", "OutMode")],
74 [("VarVarOutBuffer", "*", "InOutMode")]),
76 # GetDialogItem return handle is optional
77 ([("Handle", "item", "OutMode")],
78 [("OptHandle", "item", "OutMode")]),
81 ([("void", "*", "OutMode")],
82 [("NullStorage", "*", "InMode")]),
84 ([("DialogPtr", "*", "OutMode")],
85 [("ExistingDialogPtr", "*", "*")]),
86 ([("DialogRef", "*", "OutMode")],
87 [("ExistingDialogPtr", "*", "*")]),
90 if __name__
== "__main__":