Last-minute fix for Jim H: don't die after del sys.stdout
[python/dscho.git] / Mac / Modules / dlg / dlgscan.py
blob31c88dd33c8da74ca2423eb354cb67ce09f4223b
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 [
56 def makerepairinstructions(self):
57 return [
58 ([("Str255", "*", "InMode")],
59 [("*", "*", "OutMode")]),
61 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
62 [("InBuffer", "*", "*")]),
64 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
65 ("long", "*", "OutMode")],
66 [("VarVarOutBuffer", "*", "InOutMode")]),
68 # GetDialogItem return handle is optional
69 ([("Handle", "item", "OutMode")],
70 [("OptHandle", "item", "OutMode")]),
72 # NewDialog ETC.
73 ([("void", "*", "OutMode")],
74 [("NullStorage", "*", "InMode")]),
76 ([("DialogPtr", "*", "OutMode")],
77 [("ExistingDialogPtr", "*", "*")]),
78 ([("DialogRef", "*", "OutMode")],
79 [("ExistingDialogPtr", "*", "*")]),
82 if __name__ == "__main__":
83 main()