1 # Scan an Apple header file, generating a Python file of generator calls.
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
16 output
= SHORT
+ "gen.py"
17 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
18 scanner
= MyScanner(input, output
, 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"
32 # This is non-functional today
33 if t
== OBJECT
and m
== "InMode":
36 return classname
, listname
38 def makegreylist(self
):
40 ('#if !TARGET_API_MAC_CARBON', [
47 ('#if TARGET_API_MAC_CARBON', [
48 'CheckEventQueueForUserCancel',
49 'GetCurrentKeyModifiers',
53 def makeblacklistnames(self
):
56 "GetEventMask", # I cannot seem to find this routine...
57 "WaitNextEvent", # Manually generated because of optional region
58 # Constants with funny definitions
62 def makeblacklisttypes(self
):
67 def makerepairinstructions(self
):
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")]),
80 ([('KeyMap', 'theKeys', 'InMode')],
81 [('*', '*', 'OutMode')]),
84 ([('unsigned long', '*', '*')],
85 [('unsigned_long', '*', '*')]),
88 if __name__
== "__main__":