1 # Scan an Apple header file, generating a Python file of generator calls.
5 from bgenlocations
import TOOLBOXDIR
, BGENDIR
6 sys
.path
.append(BGENDIR
)
7 from scantools
import Scanner_OSX
11 OBJECTS
= ("CGContextRef",
13 # ADD object typenames here
19 output
= SHORT
+ "gen.py"
20 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
21 scanner
= MyScanner(input, output
, defsoutput
)
23 scanner
.gentypetest(SHORT
+"typetest.py")
25 print "=== Testing definitions output code ==="
26 execfile(defsoutput
, {}, {})
27 print "=== Done scanning and generating, now importing the generated code... ==="
28 exec "import " + SHORT
+ "support"
29 print "=== Done. It's up to you to compile it now! ==="
31 class MyScanner(Scanner_OSX
):
33 def destination(self
, type, name
, arglist
):
34 classname
= "Function"
35 listname
= "functions"
38 if t
in OBJECTS
and m
== "InMode":
40 listname
= t
+ "_methods"
41 # Special case for the silly first AllocatorRef argument
42 if t
== 'CFAllocatorRef' and m
== 'InMode' and len(arglist
) > 1:
44 if t
in OBJECTS
and m
== "InMode":
45 classname
= "MethodSkipArg1"
46 listname
= t
+ "_methods"
47 return classname
, listname
49 def writeinitialdefs(self
):
50 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
52 def makeblacklistnames(self
):
58 def makegreylist(self
):
61 def makeblacklisttypes(self
):
67 "CGColorRenderingIntent",
75 def makerepairinstructions(self
):
77 ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
78 [("InBuffer", "*", "*")]),
79 # ([("char_ptr", "name", "InMode"),],
80 # [("CCCCC", "*", "*")]),
83 if __name__
== "__main__":