blob: 2a410f6a11b44bc3d216bc52584d0e7d7c038336 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3from scantools import Scanner
4
5LONG = "Dialogs"
6SHORT = "dlg"
7OBJECT = "DialogPtr"
8
9def main():
10 input = LONG + ".h"
11 output = SHORT + "gen.py"
12 defsoutput = LONG + ".py"
13 scanner = MyScanner(input, output, defsoutput)
14 scanner.scan()
15 scanner.close()
16 print "=== Done scanning and generating, now importing the generated code... ==="
17 exec "import " + SHORT + "support"
18 print "=== Done. It's up to you to compile it now! ==="
19
20class MyScanner(Scanner):
21
22 def destination(self, type, name, arglist):
23 classname = "Function"
24 listname = "functions"
25 if arglist:
26 t, n, m = arglist[0]
27 if t == "DialogPtr" and m == "InMode":
28 classname = "Method"
29 listname = "methods"
30 return classname, listname
31
32 def makeblacklistnames(self):
33 return [
34 'InitDialogs',
35 'ErrorSound',
36 # Dialogs are disposed when the object is deleted
37 'CloseDialog',
38 'DisposDialog',
39 'DisposeDialog',
40 ]
41
42 def makeblacklisttypes(self):
43 return [
44 ]
45
46 def makerepairinstructions(self):
47 return [
48 ([("Str255", "*", "InMode")],
49 [("*", "*", "OutMode")]),
50
51 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
52 [("InBuffer", "*", "*")]),
53
54 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
55 ("long", "*", "OutMode")],
56 [("VarVarOutBuffer", "*", "InOutMode")]),
57
58 # NewDialog ETC.
59 ([("void", "*", "OutMode")],
60 [("NullStorage", "*", "InMode")]),
61
62 ([("DialogPtr", "*", "OutMode")],
63 [("ExistingDialogPtr", "*", "*")]),
64 ]
65
66if __name__ == "__main__":
67 main()