blob: 6738828606cd4ace93f256e941028fd376675c95 [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
Jack Jansenae8a68f1995-06-06 12:55:40 +00003import addpack
4addpack.addpack(':Tools:bgen:bgen')
5
Guido van Rossum17448e21995-01-30 11:53:55 +00006from scantools import Scanner
7
8LONG = "Dialogs"
9SHORT = "dlg"
10OBJECT = "DialogPtr"
11
12def main():
13 input = LONG + ".h"
14 output = SHORT + "gen.py"
15 defsoutput = LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 print "=== Done scanning and generating, now importing the generated code... ==="
20 exec "import " + SHORT + "support"
21 print "=== Done. It's up to you to compile it now! ==="
22
23class MyScanner(Scanner):
24
25 def destination(self, type, name, arglist):
26 classname = "Function"
27 listname = "functions"
28 if arglist:
29 t, n, m = arglist[0]
Jack Jansenae8a68f1995-06-06 12:55:40 +000030 if t in ("DialogPtr", "DialogRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000031 classname = "Method"
32 listname = "methods"
33 return classname, listname
34
35 def makeblacklistnames(self):
36 return [
37 'InitDialogs',
38 'ErrorSound',
39 # Dialogs are disposed when the object is deleted
40 'CloseDialog',
41 'DisposDialog',
42 'DisposeDialog',
Guido van Rossum97842951995-02-19 15:59:49 +000043 'UpdtDialog',
44 'CouldAlert',
45 'FreeAlert',
46 'CouldDialog',
47 'FreeDialog',
Jack Jansenae8a68f1995-06-06 12:55:40 +000048 'GetStdFilterProc',
Guido van Rossum17448e21995-01-30 11:53:55 +000049 ]
50
51 def makeblacklisttypes(self):
52 return [
53 ]
54
55 def makerepairinstructions(self):
56 return [
57 ([("Str255", "*", "InMode")],
58 [("*", "*", "OutMode")]),
59
60 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
61 [("InBuffer", "*", "*")]),
62
63 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
64 ("long", "*", "OutMode")],
65 [("VarVarOutBuffer", "*", "InOutMode")]),
66
67 # NewDialog ETC.
68 ([("void", "*", "OutMode")],
69 [("NullStorage", "*", "InMode")]),
70
71 ([("DialogPtr", "*", "OutMode")],
72 [("ExistingDialogPtr", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +000073 ([("DialogRef", "*", "OutMode")],
74 [("ExistingDialogPtr", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000075 ]
76
77if __name__ == "__main__":
78 main()