blob: dcb9ee040de020e05072e0e56a1f95e274820201 [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 Jansen0c4d9471998-04-17 14:07:56 +00003import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00006sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00007from scantools import Scanner
8
9LONG = "Events"
10SHORT = "evt"
11OBJECT = "NOTUSED"
12
13def main():
14 input = LONG + ".h"
15 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000016 defsoutput = TOOLBOXDIR + LONG + ".py"
Guido van Rossum17448e21995-01-30 11:53:55 +000017 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
20 print "=== Done scanning and generating, now importing the generated code... ==="
21 exec "import " + SHORT + "support"
22 print "=== Done. It's up to you to compile it now! ==="
23
24class MyScanner(Scanner):
25
26 def destination(self, type, name, arglist):
27 classname = "Function"
28 listname = "functions"
29 if arglist:
30 t, n, m = arglist[0]
31 # This is non-functional today
32 if t == OBJECT and m == "InMode":
33 classname = "Method"
34 listname = "methods"
35 return classname, listname
36
Jack Jansenabf17032000-06-20 07:42:23 +000037 def makegreylist(self):
38 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000039 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansenabf17032000-06-20 07:42:23 +000040 'SystemEvent',
41 'SystemTask',
42 'SystemClick',
43 'GetOSEvent',
44 'OSEventAvail',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000045 ]),
46 ('#if TARGET_API_MAC_CARBON', [
47 'CheckEventQueueForUserCancel',
48 'GetCurrentKeyModifiers',
49 'GetGlobalMouse',
Jack Jansenabf17032000-06-20 07:42:23 +000050 ])]
51
Guido van Rossum17448e21995-01-30 11:53:55 +000052 def makeblacklistnames(self):
53 return [
Jack Jansen7d0bc831995-06-09 20:56:31 +000054 "KeyTranslate",
55 "GetEventMask", # I cannot seem to find this routine...
Jack Jansenb1b78d81999-12-14 15:47:01 +000056 "WaitNextEvent", # Manually generated because of optional region
57 # Constants with funny definitions
58 "osEvtMessageMask",
Guido van Rossum17448e21995-01-30 11:53:55 +000059 ]
60
61 def makeblacklisttypes(self):
62 return [
Jack Jansenb81cf9d1995-06-06 13:08:40 +000063 "EvQElPtr", "QHdrPtr"
Guido van Rossum17448e21995-01-30 11:53:55 +000064 ]
65
66 def makerepairinstructions(self):
67 return [
68 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
69 [("InBuffer", "*", "*")]),
70
71 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
72 ("long", "*", "OutMode")],
73 [("VarVarOutBuffer", "*", "InOutMode")]),
74
75 ([("void", "wStorage", "OutMode")],
76 [("NullStorage", "*", "InMode")]),
77
78 # GetKeys
79 ([('KeyMap', 'theKeys', 'InMode')],
80 [('*', '*', 'OutMode')]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000081
82 # GetTicker
83 ([('unsigned long', '*', '*')],
84 [('unsigned_long', '*', '*')]),
Guido van Rossum17448e21995-01-30 11:53:55 +000085 ]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000086
Guido van Rossum17448e21995-01-30 11:53:55 +000087if __name__ == "__main__":
88 main()