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
10 LONG
= "MacTextEditor"
12 OBJECTS
= ("TXNObject", "TXNFontMenuObject")
13 # ADD object typenames here
16 input = "MacTextEditor.h"
17 output
= SHORT
+ "gen.py"
18 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
19 scanner
= MyScanner(input, output
, defsoutput
)
21 scanner
.gentypetest(SHORT
+"typetest.py")
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT
+ "support"
25 print "=== Done. It's up to you to compile it now! ==="
27 class MyScanner(Scanner_OSX
):
29 def destination(self
, type, name
, arglist
):
30 classname
= "Function"
31 listname
= "functions"
34 if t
in OBJECTS
and m
== "InMode":
36 listname
= t
+ "_methods"
37 return classname
, listname
39 def writeinitialdefs(self
):
40 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
42 def makeblacklistnames(self
):
44 "TXNGetFontDefaults", # Arg is too difficult
45 "TXNSetFontDefaults", # Arg is too difficult
46 "TXNInitTextension", # done manually
49 def makegreylist(self
):
52 def makeblacklisttypes(self
):
56 "TXNControlData", #TBD
57 "TXNATSUIFeatures", #TBD
58 "TXNATSUIVariations", #TBD
59 "TXNAttributeData", #TBD
60 "TXNTypeAttributes", #TBD
61 "TXNMatchTextRecord", #TBD
67 def makerepairinstructions(self
):
69 # TXNNewObject has a lot of optional parameters
70 ([("FSSpec_ptr", "iFileSpec", "InMode")],
71 [("OptFSSpecPtr", "*", "*")]),
72 ([("Rect", "iFrame", "OutMode")],
73 [("OptRectPtr", "*", "InMode")]),
75 # In UH 332 some of the "const" are missing for input parameters passed
76 # by reference. We fix that up here.
77 ([("EventRecord", "iEvent", "OutMode")],
78 [("EventRecord_ptr", "*", "InMode")]),
79 ([("FSSpec", "iFileSpecification", "OutMode")],
80 [("FSSpec_ptr", "*", "InMode")]),
81 ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
82 [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
84 # In buffers are passed as void *
85 ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
86 [("MlteInBuffer", "*", "InMode")]),
89 if __name__
== "__main__":