Updated for hfsplus module, new gusi libs.
[python/dscho.git] / Mac / Modules / dlg / dlgscan.py
blob2c6308022168e504dc0f0b428a318f63cbe8a530
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',
56 'SetGrafPortOfDialog', # Funny, and probably not useful
59 def makegreylist(self):
60 return [
61 ('#if !TARGET_API_MAC_CARBON', [
62 'SetGrafPortOfDialog',
63 ]),
64 ('#if TARGET_API_MAC_CARBON', [
65 'InsertDialogItem',
66 'RemoveDialogItems',
67 'GetParamText',
68 ])]
70 def makeblacklisttypes(self):
71 return [
72 "AlertStdAlertParamPtr", # Too much work, for now
73 "AlertStdAlertParamRec", # ditto
74 "AlertStdAlertParamRec_ptr", # ditto
75 "QTModelessCallbackProcPtr",
78 def makerepairinstructions(self):
79 return [
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")]),
94 # NewDialog ETC.
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__":
113 main()