1
# Scan an Apple header file, generating a Python file of generator calls.
4
from bgenlocations import TOOLBOXDIR, BGENDIR
5
sys.path.append(BGENDIR)
7
from scantools import Scanner
15
output = SHORT + "gen.py"
16
defsoutput = TOOLBOXDIR + LONG + ".py"
17
scanner = MyScanner(input, output, defsoutput)
20
print "=== Testing definitions output code ==="
21
execfile(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
62
def makeblacklisttypes(self):
64
"AlertStdAlertParamPtr", # Too much work, for now
65
"AlertStdAlertParamRec", # ditto
66
"AlertStdAlertParamRec_ptr", # ditto
67
"AlertStdCFStringAlertParamPtr", # ditto
68
"AlertStdCFStringAlertParamRec",
69
"AlertStdCFStringAlertParamRec_ptr",
70
"QTModelessCallbackProcPtr",
73
def makerepairinstructions(self):
75
([("Str255", "*", "InMode")],
76
[("*", "*", "OutMode")]),
78
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
79
[("InBuffer", "*", "*")]),
81
([("void", "*", "OutMode"), ("long", "*", "InMode"),
82
("long", "*", "OutMode")],
83
[("VarVarOutBuffer", "*", "InOutMode")]),
85
# GetDialogItem return handle is optional
86
([("Handle", "item", "OutMode")],
87
[("OptHandle", "item", "OutMode")]),
90
([("void", "*", "OutMode")],
91
[("NullStorage", "*", "InMode")]),
93
([("DialogPtr", "*", "OutMode")],
94
[("ExistingDialogPtr", "*", "*")]),
95
([("DialogRef", "*", "OutMode")],
96
[("ExistingDialogPtr", "*", "*")]),
97
([("WindowPtr", "*", "OutMode")],
98
[("ExistingWindowPtr", "*", "*")]),
99
([("WindowPtr", "*", "ReturnMode")],
100
[("ExistingWindowPtr", "*", "*")]),
103
([('EventRecord', 'event', 'OutMode'),
104
('DialogItemIndex', 'itemHit', 'OutMode')],
105
[('EventRecord', 'event', 'InOutMode'),
106
('DialogItemIndex', 'itemHit', 'InOutMode')])
110
def writeinitialdefs(self):
111
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
114
if __name__ == "__main__":