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',
56 'SetGrafPortOfDialog', # Funny, and probably not useful
59 def makegreylist(self
):
61 ('#if !TARGET_API_MAC_CARBON', [
62 'SetGrafPortOfDialog',
64 ('#if TARGET_API_MAC_CARBON', [
70 def makeblacklisttypes(self
):
72 "AlertStdAlertParamPtr", # Too much work, for now
73 "AlertStdAlertParamRec", # ditto
74 "AlertStdAlertParamRec_ptr", # ditto
75 "QTModelessCallbackProcPtr",
78 def makerepairinstructions(self
):
80 ([("Str255", "*", "InMode")],
81 [("*", "*", "OutMode")]),
83 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
84 [("InBuffer", "*", "*")]),
86 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
87 ("long", "*", "OutMode")],
88 [("VarVarOutBuffer", "*", "InOutMode")]),
90 # GetDialogItem return handle is optional
91 ([("Handle", "item", "OutMode")],
92 [("OptHandle", "item", "OutMode")]),
95 ([("void", "*", "OutMode")],
96 [("NullStorage", "*", "InMode")]),
98 ([("DialogPtr", "*", "OutMode")],
99 [("ExistingDialogPtr", "*", "*")]),
100 ([("DialogRef", "*", "OutMode")],
101 [("ExistingDialogPtr", "*", "*")]),
102 ([("WindowPtr", "*", "OutMode")],
103 [("ExistingWindowPtr", "*", "*")]),
104 ([("WindowPtr", "*", "ReturnMode")],
105 [("ExistingWindowPtr", "*", "*")]),
108 def writeinitialdefs(self
):
109 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
112 if __name__
== "__main__":