source: trunk/essentials/dev-lang/python/Mac/Modules/mlte/mltescan.py@ 3404

Last change on this file since 3404 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 4.9 KB
Line 
1# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner_OSX
8
9LONG = "MacTextEditor"
10SHORT = "mlte"
11OBJECTS = ("TXNObject", "TXNFontMenuObject")
12# ADD object typenames here
13
14def main():
15 input = "MacTextEditor.h"
16 output = SHORT + "gen.py"
17 defsoutput = TOOLBOXDIR + LONG + ".py"
18 scanner = MyScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.gentypetest(SHORT+"typetest.py")
21 scanner.close()
22 print "=== Testing definitions output code ==="
23 execfile(defsoutput, {}, {})
24 print "=== Done scanning and generating, now importing the generated code... ==="
25 exec "import " + SHORT + "support"
26 print "=== Done. It's up to you to compile it now! ==="
27
28class MyScanner(Scanner_OSX):
29
30 def destination(self, type, name, arglist):
31 classname = "Function"
32 listname = "functions"
33 if arglist:
34 t, n, m = arglist[0]
35 if t in OBJECTS and m == "InMode":
36 classname = "Method"
37 listname = t + "_methods"
38 return classname, listname
39
40 def writeinitialdefs(self):
41 self.defsfile.write("""
42def FOUR_CHAR_CODE(x): return x
43false = 0
44true = 1
45kTXNClearThisControl = 0xFFFFFFFF
46kTXNClearTheseFontFeatures = 0x80000000
47kTXNDontCareTypeSize = 0xFFFFFFFF
48kTXNDecrementTypeSize = 0x80000000
49kTXNUseCurrentSelection = 0xFFFFFFFF
50kTXNStartOffset = 0
51kTXNEndOffset = 0x7FFFFFFF
52MovieFileType = FOUR_CHAR_CODE('moov')
53kTXNUseEncodingWordRulesMask = 0x80000000
54kTXNFontSizeAttributeSize = 4
55normal = 0
56""")
57
58 def makeblacklistnames(self):
59 return [
60 "TXNGetFontDefaults", # Arg is too difficult
61 "TXNSetFontDefaults", # Arg is too difficult
62 "TXNInitTextension", # done manually
63
64 # Constants with funny definitions
65 "kTXNClearThisControl",
66 "kTXNClearTheseFontFeatures",
67 "kTXNDontCareTypeSize",
68 "kTXNDecrementTypeSize",
69 "kTXNUseCurrentSelection",
70 "kTXNStartOffset",
71 "kTXNEndOffset",
72 "kTXNQDFontNameAttributeSize",
73 "kTXNQDFontFamilyIDAttributeSize",
74 "kTXNQDFontSizeAttributeSize",
75 "kTXNQDFontStyleAttributeSize",
76 "kTXNQDFontColorAttributeSize",
77 "kTXNTextEncodingAttributeSize",
78 "kTXNUseEncodingWordRulesMask",
79 "kTXNFontSizeAttributeSize",
80 "status",
81 "justification",
82 'TXNTSMCheck', # OS8
83 ]
84
85 def makeblacklisttypes(self):
86 return [
87 "TXNTab", # TBD
88 "TXNMargins", # TBD
89 "TXNControlData", #TBD
90 "TXNATSUIFeatures", #TBD
91 "TXNATSUIVariations", #TBD
92 "TXNAttributeData", #TBD
93 "TXNTypeAttributes", #TBD
94 "TXNMatchTextRecord", #TBD
95 "TXNBackground", #TBD
96 "TXNFindUPP",
97 "ATSUStyle", #TBD
98 "TXNBackground_ptr", #TBD
99 "TXNControlData_ptr", #TBD
100 "TXNControlTag_ptr", #TBD
101 "TXNLongRect", #TBD
102 "TXNLongRect_ptr", #TBD
103 "TXNTypeAttributes_ptr", #TBD
104
105 "TXNActionKeyMapperProcPtr",
106 "TXNActionKeyMapperUPP",
107 "TXNTextBoxOptionsData",
108 "TXNCountOptions",
109 "void_ptr",
110 ]
111
112 def makerepairinstructions(self):
113 return [
114 # TXNNewObject has a lot of optional parameters
115 ([("FSSpec_ptr", "iFileSpec", "InMode")],
116 [("OptFSSpecPtr", "*", "*")]),
117 ([("Rect", "iFrame", "OutMode")],
118 [("OptRectPtr", "*", "InMode")]),
119
120 # In UH 332 some of the "const" are missing for input parameters passed
121 # by reference. We fix that up here.
122 ([("EventRecord", "iEvent", "OutMode")],
123 [("EventRecord_ptr", "*", "InMode")]),
124 ([("FSSpec", "iFileSpecification", "OutMode")],
125 [("FSSpec_ptr", "*", "InMode")]),
126 ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
127 [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
128
129 # In buffers are passed as void *
130 ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
131 [("MlteInBuffer", "*", "InMode")]),
132
133 # The AdjustCursor region handle is optional
134 ([("RgnHandle", "ioCursorRgn", "InMode")],
135 [("OptRgnHandle", "*", "*")]),
136
137 # The GWorld for TXNDraw is optional
138 ([('GWorldPtr', 'iDrawPort', 'InMode')],
139 [('OptGWorldPtr', '*', '*')]),
140 ]
141
142if __name__ == "__main__":
143 main()
Note: See TracBrowser for help on using the repository browser.