This commit was manufactured by cvs2svn to create tag 'r222'.
[python/dscho.git] / Mac / Modules / mlte / mltescan.py
blob80c966eb327ff2a2f1309ce56f381aa9d715b3ad
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 import os
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"
11 SHORT = "mlte"
12 OBJECTS = ("TXNObject", "TXNFontMenuObject")
13 # ADD object typenames here
15 def main():
16 input = "MacTextEditor.h"
17 output = SHORT + "gen.py"
18 defsoutput = TOOLBOXDIR + LONG + ".py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.gentypetest(SHORT+"typetest.py")
22 scanner.close()
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"
32 if arglist:
33 t, n, m = arglist[0]
34 if t in OBJECTS and m == "InMode":
35 classname = "Method"
36 listname = t + "_methods"
37 return classname, listname
39 def writeinitialdefs(self):
40 self.defsfile.write("""
41 def FOUR_CHAR_CODE(x): return x
42 false = 0
43 true = 1
44 kTXNClearThisControl = 0xFFFFFFFF
45 kTXNClearTheseFontFeatures = 0x80000000
46 kTXNDontCareTypeSize = 0xFFFFFFFF
47 kTXNDecrementTypeSize = 0x80000000
48 kTXNUseCurrentSelection = 0xFFFFFFFF
49 kTXNStartOffset = 0
50 kTXNEndOffset = 0x7FFFFFFF
51 MovieFileType = FOUR_CHAR_CODE('moov')
52 """)
54 def makeblacklistnames(self):
55 return [
56 "TXNGetFontDefaults", # Arg is too difficult
57 "TXNSetFontDefaults", # Arg is too difficult
58 "TXNInitTextension", # done manually
60 # Constants with funny definitions
61 "kTXNClearThisControl",
62 "kTXNClearTheseFontFeatures",
63 "kTXNDontCareTypeSize",
64 "kTXNDecrementTypeSize",
65 "kTXNUseCurrentSelection",
66 "kTXNStartOffset",
67 "kTXNEndOffset",
68 "kTXNQDFontNameAttributeSize",
69 "kTXNQDFontFamilyIDAttributeSize",
70 "kTXNQDFontSizeAttributeSize",
71 "kTXNQDFontStyleAttributeSize",
72 "kTXNQDFontColorAttributeSize",
73 "kTXNTextEncodingAttributeSize",
74 "status",
75 "justification",
78 def makegreylist(self):
79 return [
80 ('#if TARGET_API_MAC_OS8', [
81 'TXNTSMCheck',
82 ])]
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 "TXNActionKeyMapperProcPtr",
99 "TXNActionKeyMapperUPP",
100 "TXNTextBoxOptionsData",
101 "TXNCountOptions",
104 def makerepairinstructions(self):
105 return [
106 # TXNNewObject has a lot of optional parameters
107 ([("FSSpec_ptr", "iFileSpec", "InMode")],
108 [("OptFSSpecPtr", "*", "*")]),
109 ([("Rect", "iFrame", "OutMode")],
110 [("OptRectPtr", "*", "InMode")]),
112 # In UH 332 some of the "const" are missing for input parameters passed
113 # by reference. We fix that up here.
114 ([("EventRecord", "iEvent", "OutMode")],
115 [("EventRecord_ptr", "*", "InMode")]),
116 ([("FSSpec", "iFileSpecification", "OutMode")],
117 [("FSSpec_ptr", "*", "InMode")]),
118 ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
119 [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
121 # In buffers are passed as void *
122 ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
123 [("MlteInBuffer", "*", "InMode")]),
125 # The AdjustCursor region handle is optional
126 ([("RgnHandle", "ioCursorRgn", "InMode")],
127 [("OptRgnHandle", "*", "*")]),
129 # The GWorld for TXNDraw is optional
130 ([('GWorldPtr', 'iDrawPort', 'InMode')],
131 [('OptGWorldPtr', '*', '*')]),
134 if __name__ == "__main__":
135 main()