Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Mac / Modules / dlg / dlgscan.py
blob6ef502a0e2389993c919d2fb58dbc16da3c3ea5d
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 import os
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
11 LONG = "Dialogs"
12 SHORT = "dlg"
13 OBJECT = "DialogPtr"
15 def main():
16 input = LONG + ".h"
17 output = SHORT + "gen.py"
18 defsoutput = TOOLBOXDIR + LONG + ".py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
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"
31 if arglist:
32 t, n, m = arglist[0]
33 if t in ("DialogPtr", "DialogRef") and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
38 def makeblacklistnames(self):
39 return [
40 'InitDialogs',
41 'ErrorSound',
42 # Dialogs are disposed when the object is deleted
43 'CloseDialog',
44 'DisposDialog',
45 'DisposeDialog',
46 'UpdtDialog',
47 'CouldAlert',
48 'FreeAlert',
49 'CouldDialog',
50 'FreeDialog',
51 'GetStdFilterProc',
52 'GetDialogParent',
53 # Can't find these in the CW Pro 3 libraries
54 'SetDialogMovableModal',
55 'GetDialogControlNotificationProc',
58 def makeblacklisttypes(self):
59 return [
60 "AlertStdAlertParamPtr", # Too much work, for now
61 "QTModelessCallbackProcPtr",
64 def makerepairinstructions(self):
65 return [
66 ([("Str255", "*", "InMode")],
67 [("*", "*", "OutMode")]),
69 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
72 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
73 ("long", "*", "OutMode")],
74 [("VarVarOutBuffer", "*", "InOutMode")]),
76 # GetDialogItem return handle is optional
77 ([("Handle", "item", "OutMode")],
78 [("OptHandle", "item", "OutMode")]),
80 # NewDialog ETC.
81 ([("void", "*", "OutMode")],
82 [("NullStorage", "*", "InMode")]),
84 ([("DialogPtr", "*", "OutMode")],
85 [("ExistingDialogPtr", "*", "*")]),
86 ([("DialogRef", "*", "OutMode")],
87 [("ExistingDialogPtr", "*", "*")]),
90 if __name__ == "__main__":
91 main()