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_OSX
8 from bgenlocations
import TOOLBOXDIR
12 OBJECTS
= ("CGContextRef",
14 # ADD object typenames here
20 output
= SHORT
+ "gen.py"
21 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
22 scanner
= MyScanner(input, output
, defsoutput
)
24 scanner
.gentypetest(SHORT
+"typetest.py")
26 print "=== Done scanning and generating, now importing the generated code... ==="
27 exec "import " + SHORT
+ "support"
28 print "=== Done. It's up to you to compile it now! ==="
30 class MyScanner(Scanner_OSX
):
32 def destination(self
, type, name
, arglist
):
33 classname
= "Function"
34 listname
= "functions"
37 if t
in OBJECTS
and m
== "InMode":
39 listname
= t
+ "_methods"
40 # Special case for the silly first AllocatorRef argument
41 if t
== 'CFAllocatorRef' and m
== 'InMode' and len(arglist
) > 1:
43 if t
in OBJECTS
and m
== "InMode":
44 classname
= "MethodSkipArg1"
45 listname
= t
+ "_methods"
46 return classname
, listname
48 def writeinitialdefs(self
):
49 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
51 def makeblacklistnames(self
):
57 def makegreylist(self
):
60 def makeblacklisttypes(self
):
66 "CGColorRenderingIntent",
74 def makerepairinstructions(self
):
76 ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
77 [("InBuffer", "*", "*")]),
78 # ([("char_ptr", "name", "InMode"),],
79 # [("CCCCC", "*", "*")]),
82 if __name__
== "__main__":