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_PreUH3
8 from bgenlocations
import MWERKSDIR
, TOOLBOXDIR
10 WASTEDIR
=":::::Waste 1.3 Distribution:WASTE C/C++ Headers:"
14 OBJECT
= "WEReference"
15 OBJECT2
= "WEObjectReference"
18 input = WASTEDIR
+ "WASTE.h"
19 output
= SHORT
+ "gen.py"
20 defsoutput
= TOOLBOXDIR
+ "WASTEconst.py"
21 scanner
= MyScanner(input, output
, defsoutput
)
23 ## scanner.gentypetest(SHORT+"typetest.py")
25 print "=== Done scanning and generating, now importing the generated code... ==="
26 exec "import " + SHORT
+ "support"
27 print "=== Done. It's up to you to compile it now! ==="
29 class MyScanner(Scanner_PreUH3
):
31 def destination(self
, type, name
, arglist
):
32 classname
= "Function"
33 listname
= "functions"
36 # This is non-functional today
37 if t
== OBJECT
and m
== "InMode":
42 if t
== OBJECT2
and m
== "InMode":
45 return classname
, listname
47 def writeinitialdefs(self
):
48 self
.defsfile
.write("kPascalStackBased = None # workaround for header parsing\n")
49 def makeblacklistnames(self
):
52 "WESetInfo", # Argument type unknown...
54 "WEVersion", # Unfortunately...
57 def makeblacklisttypes(self
):
59 "DragReference", # For now...
65 def makerepairinstructions(self
):
67 ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
68 [("InBuffer", "*", "*")]),
71 ([("WEStyleMode", "mode", "OutMode"), ("TextStyle", "ts", "OutMode")],
72 [("WEStyleMode", "mode", "InOutMode"), ("TextStyle", "ts", "OutMode")]),
75 ([('Handle', 'hText', 'InMode'), ('StScrpHandle', 'hStyles', 'InMode'),
76 ('WESoupHandle', 'hSoup', 'InMode')],
77 [('OptHandle', 'hText', 'InMode'), ('OptStScrpHandle', 'hStyles', 'InMode'),
78 ('OptSoupHandle', 'hSoup', 'InMode')]),
81 ([('StScrpHandle', 'hStyles', 'InMode'), ('WESoupHandle', 'hSoup', 'InMode')],
82 [('OptStScrpHandle', 'hStyles', 'InMode'), ('OptSoupHandle', 'hSoup', 'InMode')]),
86 [('WEReference', '*', 'ReturnMode')],
87 [('ExistingWEReference', '*', 'ReturnMode')])
91 if __name__
== "__main__":