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
9 WASTEDIR
='/Volumes/Moes/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/MacOS Support/(Third Party Support)/Waste 2.0 Distribution/C_C++ Headers/'
11 if not os
.path
.exists(WASTEDIR
):
12 raise 'Error: not found: %s', WASTEDIR
16 OBJECT
= "WEReference"
17 OBJECT2
= "WEObjectReference"
20 input = WASTEDIR
+ "WASTE.h"
21 output
= SHORT
+ "gen.py"
22 defsoutput
= TOOLBOXDIR
+ "WASTEconst.py"
23 scanner
= MyScanner(input, output
, defsoutput
)
25 ## scanner.gentypetest(SHORT+"typetest.py")
27 print "=== Testing definitions output code ==="
28 execfile(defsoutput
, {}, {})
29 print "=== Done scanning and generating, now importing the generated code... ==="
30 exec "import " + SHORT
+ "support"
31 print "=== Done. It's up to you to compile it now! ==="
33 #class MyScanner(Scanner_PreUH3):
34 class MyScanner(Scanner
):
36 def destination(self
, type, name
, arglist
):
37 classname
= "Function"
38 listname
= "functions"
41 # This is non-functional today
42 if t
== OBJECT
and m
== "InMode":
47 if t
== OBJECT2
and m
== "InMode":
50 return classname
, listname
52 def writeinitialdefs(self
):
53 self
.defsfile
.write("kPascalStackBased = None # workaround for header parsing\n")
54 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
56 def makeblacklistnames(self
):
59 "WESetInfo", # Argument type unknown...
61 "WEVersion", # Unfortunately...
62 "WEPut", # XXXX TBD: needs array of flavortypes.
63 "WEGetOneAttribute", # XXXX TBD: output buffer
64 # Incompatible constant definitions
78 "weDoInhibitICSupport",
82 def makeblacklisttypes(self
):
84 "DragReference", # For now...
94 "WEHiliteDropAreaUPP",
106 "WEDisposeObjectUPP",
111 "WERuler", # XXXX To be done
112 "WERuler_ptr", # ditto
113 "WEParaInfo", # XXXX To be done
114 "WEPrintSession", # XXXX To be done
115 "WEPrintOptions_ptr", # XXXX To be done
118 def makerepairinstructions(self
):
120 ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
121 [("InBuffer", "*", "*")]),
124 ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
125 [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
128 ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
129 ('WESoupHandle', 'outSoup', 'InMode')],
130 [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
131 ('OptSoupHandle', '*', '*')]),
134 ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
135 [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
139 [('WEReference', '*', 'ReturnMode')],
140 [('ExistingWEReference', '*', 'ReturnMode')]),
143 ([("char_ptr", "inKey", "InMode")],
144 [("stringptr", "*", "*")]),
147 ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
148 [("InBuffer", "*", "*")]),
151 if __name__
== "__main__":