Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Mac / Modules / dlg / dlgscan.py
blobd51a2d1e26bb9b742ff9f76c0091e037d64c27fd
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import addpack
4 addpack.addpack(':Tools:bgen:bgen')
6 from scantools import Scanner
7 from bgenlocations import TOOLBOXDIR
9 LONG = "Dialogs"
10 SHORT = "dlg"
11 OBJECT = "DialogPtr"
13 def main():
14 input = LONG + ".h"
15 output = SHORT + "gen.py"
16 defsoutput = TOOLBOXDIR + LONG + ".py"
17 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
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"
29 if arglist:
30 t, n, m = arglist[0]
31 if t in ("DialogPtr", "DialogRef") and m == "InMode":
32 classname = "Method"
33 listname = "methods"
34 return classname, listname
36 def makeblacklistnames(self):
37 return [
38 'InitDialogs',
39 'ErrorSound',
40 # Dialogs are disposed when the object is deleted
41 'CloseDialog',
42 'DisposDialog',
43 'DisposeDialog',
44 'UpdtDialog',
45 'CouldAlert',
46 'FreeAlert',
47 'CouldDialog',
48 'FreeDialog',
49 'GetStdFilterProc',
52 def makeblacklisttypes(self):
53 return [
54 "AlertStdAlertParamPtr", # Too much work, for now
57 def makerepairinstructions(self):
58 return [
59 ([("Str255", "*", "InMode")],
60 [("*", "*", "OutMode")]),
62 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
63 [("InBuffer", "*", "*")]),
65 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
66 ("long", "*", "OutMode")],
67 [("VarVarOutBuffer", "*", "InOutMode")]),
69 # GetDialogItem return handle is optional
70 ([("Handle", "item", "OutMode")],
71 [("OptHandle", "item", "OutMode")]),
73 # NewDialog ETC.
74 ([("void", "*", "OutMode")],
75 [("NullStorage", "*", "InMode")]),
77 ([("DialogPtr", "*", "OutMode")],
78 [("ExistingDialogPtr", "*", "*")]),
79 ([("DialogRef", "*", "OutMode")],
80 [("ExistingDialogPtr", "*", "*")]),
83 if __name__ == "__main__":
84 main()