Fix three PyChecker-detected gotchas.
[python/dscho.git] / Mac / Modules / evt / evtscan.py
blob82b92608b627a9eca4e17a345cc1dd6efd0d8181
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)
7 from scantools import Scanner
8 from bgenlocations import TOOLBOXDIR
10 LONG = "Events"
11 SHORT = "evt"
12 OBJECT = "NOTUSED"
14 def main():
15 input = LONG + ".h"
16 output = SHORT + "gen.py"
17 defsoutput = TOOLBOXDIR + LONG + ".py"
18 scanner = MyScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
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 makegreylist(self):
39 return [
40 ('#if !TARGET_API_MAC_CARBON', [
41 'SystemEvent',
42 'SystemTask',
43 'SystemClick',
44 'GetOSEvent',
45 'OSEventAvail',
46 ]),
47 ('#if TARGET_API_MAC_CARBON', [
48 'CheckEventQueueForUserCancel',
49 'GetCurrentKeyModifiers',
50 'GetGlobalMouse',
51 ])]
53 def makeblacklistnames(self):
54 return [
55 "KeyTranslate",
56 "GetEventMask", # I cannot seem to find this routine...
57 "WaitNextEvent", # Manually generated because of optional region
58 # Constants with funny definitions
59 "osEvtMessageMask",
62 def makeblacklisttypes(self):
63 return [
64 "EvQElPtr", "QHdrPtr"
67 def makerepairinstructions(self):
68 return [
69 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
72 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
73 ("long", "*", "OutMode")],
74 [("VarVarOutBuffer", "*", "InOutMode")]),
76 ([("void", "wStorage", "OutMode")],
77 [("NullStorage", "*", "InMode")]),
79 # GetKeys
80 ([('KeyMap', 'theKeys', 'InMode')],
81 [('*', '*', 'OutMode')]),
83 # GetTicker
84 ([('unsigned long', '*', '*')],
85 [('unsigned_long', '*', '*')]),
88 if __name__ == "__main__":
89 main()