blob: e7bb74b3b04ac5f09ac70b7b10e7e398faf9cbff [file] [log] [blame]
Jack Jansen8a452d61996-04-10 14:41:08 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import addpack
4addpack.addpack(':tools:bgen:bgen')
5from scantools import Scanner
6
7LONG = "TextEdit"
8SHORT = "te"
9OBJECT = "TEHandle"
10
11def main():
12 input = LONG + ".h"
13 output = SHORT + "gen.py"
14 defsoutput = LONG + ".py"
15 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now importing the generated code... ==="
19 exec "import " + SHORT + "support"
20 print "=== Done. It's up to you to compile it now! ==="
21
22class MyScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[-1]
29 # This is non-functional today
30 if t == OBJECT and m == "InMode":
31 classname = "Method"
32 listname = "methods"
33 return classname, listname
34
35 def makeblacklistnames(self):
36 return [
37 "TEDispose",
38 "TEInit",
39 "TEGetHiliteRgn",
40 ]
41
42 def makeblacklisttypes(self):
43 return [
44 "TEClickLoopUPP",
45 "UniversalProcPtr",
46 "WordBreakUPP"
47 ]
48
49 def makerepairinstructions(self):
50 return [
51 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
52 [("InBuffer", "*", "*")]),
53
54 # TEContinuousStyle
55 ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
56 [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
57 ]
58
59if __name__ == "__main__":
60 main()