blob: 82b92608b627a9eca4e17a345cc1dd6efd0d8181 [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
5BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00007from scantools import Scanner
Jack Jansen46d9e791996-04-12 16:29:23 +00008from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00009
10LONG = "Events"
11SHORT = "evt"
12OBJECT = "NOTUSED"
13
14def main():
15 input = LONG + ".h"
16 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000017 defsoutput = TOOLBOXDIR + LONG + ".py"
Guido van Rossum17448e21995-01-30 11:53:55 +000018 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! ==="
24
25class MyScanner(Scanner):
26
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
37
Jack Jansenabf17032000-06-20 07:42:23 +000038 def makegreylist(self):
39 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000040 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansenabf17032000-06-20 07:42:23 +000041 'SystemEvent',
42 'SystemTask',
43 'SystemClick',
44 'GetOSEvent',
45 'OSEventAvail',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000046 ]),
47 ('#if TARGET_API_MAC_CARBON', [
48 'CheckEventQueueForUserCancel',
49 'GetCurrentKeyModifiers',
50 'GetGlobalMouse',
Jack Jansenabf17032000-06-20 07:42:23 +000051 ])]
52
Guido van Rossum17448e21995-01-30 11:53:55 +000053 def makeblacklistnames(self):
54 return [
Jack Jansen7d0bc831995-06-09 20:56:31 +000055 "KeyTranslate",
56 "GetEventMask", # I cannot seem to find this routine...
Jack Jansenb1b78d81999-12-14 15:47:01 +000057 "WaitNextEvent", # Manually generated because of optional region
58 # Constants with funny definitions
59 "osEvtMessageMask",
Guido van Rossum17448e21995-01-30 11:53:55 +000060 ]
61
62 def makeblacklisttypes(self):
63 return [
Jack Jansenb81cf9d1995-06-06 13:08:40 +000064 "EvQElPtr", "QHdrPtr"
Guido van Rossum17448e21995-01-30 11:53:55 +000065 ]
66
67 def makerepairinstructions(self):
68 return [
69 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
71
72 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
73 ("long", "*", "OutMode")],
74 [("VarVarOutBuffer", "*", "InOutMode")]),
75
76 ([("void", "wStorage", "OutMode")],
77 [("NullStorage", "*", "InMode")]),
78
79 # GetKeys
80 ([('KeyMap', 'theKeys', 'InMode')],
81 [('*', '*', 'OutMode')]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000082
83 # GetTicker
84 ([('unsigned long', '*', '*')],
85 [('unsigned_long', '*', '*')]),
Guido van Rossum17448e21995-01-30 11:53:55 +000086 ]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000087
Guido van Rossum17448e21995-01-30 11:53:55 +000088if __name__ == "__main__":
89 main()