move sections
[python/dscho.git] / Mac / Modules / evt / evtscan.py
blobea0692cfe16d51237e1dcf36db7e810297491e33
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5 sys.path.append(BGENDIR)
6 from scantools import Scanner
8 LONG = "Events"
9 SHORT = "evt"
10 OBJECT = "NOTUSED"
12 def main():
13 input = LONG + ".h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
21 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
25 class MyScanner(Scanner):
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 # This is non-functional today
33 if t == OBJECT and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
38 def makeblacklistnames(self):
39 return [
40 "KeyTranslate",
41 "GetEventMask", # I cannot seem to find this routine...
42 "WaitNextEvent", # Manually generated because of optional region
43 # Constants with funny definitions
44 "osEvtMessageMask",
45 # OS8 calls
46 'SystemEvent',
47 'SystemTask',
48 'SystemClick',
49 'GetOSEvent',
50 'OSEventAvail',
53 def makeblacklisttypes(self):
54 return [
55 "EvQElPtr", "QHdrPtr"
58 def makerepairinstructions(self):
59 return [
60 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
61 [("InBuffer", "*", "*")]),
63 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
64 ("long", "*", "OutMode")],
65 [("VarVarOutBuffer", "*", "InOutMode")]),
67 ([("void", "wStorage", "OutMode")],
68 [("NullStorage", "*", "InMode")]),
70 # GetKeys
71 ([('KeyMap', 'theKeys', 'InMode')],
72 [('*', '*', 'OutMode')]),
74 # GetTicker
75 ([('unsigned long', '*', '*')],
76 [('unsigned_long', '*', '*')]),
79 if __name__ == "__main__":
80 main()