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
14 output
= SHORT
+ "gen.py"
15 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
16 scanner
= MyScanner(input, output
, defsoutput
)
19 print "=== Testing definitions output code ==="
20 execfile(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"
30 return classname
, listname
32 def makeblacklistnames(self
):
34 "OutlineMetrics", # Too complicated
35 "AntiTextIsAntiAliased", # XXXX Missing from library...
38 "AntiTextGetApplicationAware",
39 "AntiTextSetApplicationAware",
40 # These are tricky: they're not Carbon dependent or anything, but they
41 # exist only on 8.6 or later (both in Carbon and Classic).
42 # Disabling them is the easiest path.
43 'SetAntiAliasedTextEnabled',
44 'IsAntiAliasedTextEnabled',
51 def makegreylist(self
):
53 ('#if !TARGET_API_MAC_CARBON', [
55 def makeblacklisttypes(self
):
57 "FMInput_ptr", # Not needed for now
59 ## "void_ptr", # Don't know how to do this right now
63 def makerepairinstructions(self
):
65 ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
66 ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
67 ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
68 [('TextBuffer', 'inText', 'InMode')]),
71 def writeinitialdefs(self
):
72 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
73 self
.defsfile
.write("kNilOptions = 0\n")
75 if __name__
== "__main__":