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 makegreylist(self
):
60 ('#if !TARGET_API_MAC_CARBON', [
61 'SetGrafPortOfDialog',
64 def makeblacklisttypes(self
):
66 "AlertStdAlertParamPtr", # Too much work, for now
67 "QTModelessCallbackProcPtr",
70 def makerepairinstructions(self
):
72 ([("Str255", "*", "InMode")],
73 [("*", "*", "OutMode")]),
75 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
76 [("InBuffer", "*", "*")]),
78 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
79 ("long", "*", "OutMode")],
80 [("VarVarOutBuffer", "*", "InOutMode")]),
82 # GetDialogItem return handle is optional
83 ([("Handle", "item", "OutMode")],
84 [("OptHandle", "item", "OutMode")]),
87 ([("void", "*", "OutMode")],
88 [("NullStorage", "*", "InMode")]),
90 ([("DialogPtr", "*", "OutMode")],
91 [("ExistingDialogPtr", "*", "*")]),
92 ([("DialogRef", "*", "OutMode")],
93 [("ExistingDialogPtr", "*", "*")]),
94 ([("WindowPtr", "*", "OutMode")],
95 [("ExistingWindowPtr", "*", "*")]),
96 ([("WindowPtr", "*", "ReturnMode")],
97 [("ExistingWindowPtr", "*", "*")]),
100 def writeinitialdefs(self
):
101 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
104 if __name__
== "__main__":