blob: 517db710f3194f380cf646ac6a362c54f4638e2b [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 = "Events"
6SHORT = "evt"
7OBJECT = "NOTUSED"
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 # This is non-functional today
28 if t == OBJECT and m == "InMode":
29 classname = "Method"
30 listname = "methods"
31 return classname, listname
32
33 def makeblacklistnames(self):
34 return [
35 ]
36
37 def makeblacklisttypes(self):
38 return [
39 ]
40
41 def makerepairinstructions(self):
42 return [
43 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
44 [("InBuffer", "*", "*")]),
45
46 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
47 ("long", "*", "OutMode")],
48 [("VarVarOutBuffer", "*", "InOutMode")]),
49
50 ([("void", "wStorage", "OutMode")],
51 [("NullStorage", "*", "InMode")]),
52
53 # GetKeys
54 ([('KeyMap', 'theKeys', 'InMode')],
55 [('*', '*', 'OutMode')]),
56 ]
57
58if __name__ == "__main__":
59 main()