py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Modules / mlte / mltescan.py
blob25e7d62ed28cd84b07481e0f15f6acbc1575cf86
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("def FOUR_CHAR_CODE(x): return x\n")
42 def makeblacklistnames(self):
43 return [
44 "TXNGetFontDefaults", # Arg is too difficult
45 "TXNSetFontDefaults", # Arg is too difficult
46 "TXNInitTextension", # done manually
49 def makegreylist(self):
50 return []
52 def makeblacklisttypes(self):
53 return [
54 "TXNTab", # TBD
55 "TXNMargins", # TBD
56 "TXNControlData", #TBD
57 "TXNATSUIFeatures", #TBD
58 "TXNATSUIVariations", #TBD
59 "TXNAttributeData", #TBD
60 "TXNTypeAttributes", #TBD
61 "TXNMatchTextRecord", #TBD
62 "TXNBackground", #TBD
63 "UniChar", #TBD
64 "TXNFindUPP",
67 def makerepairinstructions(self):
68 return [
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__":
90 main()