source: trunk/essentials/dev-lang/python/Mac/Modules/te/tescan.py

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

Python 2.5

File size: 1.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
8
9LONG = "TextEdit"
10SHORT = "te"
11OBJECT = "TEHandle"
12
13def main():
14 input = LONG + ".h"
15 output = SHORT + "gen.py"
16 defsoutput = TOOLBOXDIR + LONG + ".py"
17 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
20 print "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
22 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT + "support"
24 print "=== Done. It's up to you to compile it now! ==="
25
26class MyScanner(Scanner):
27
28 def destination(self, type, name, arglist):
29 classname = "Function"
30 listname = "functions"
31 if arglist:
32 t, n, m = arglist[-1]
33 # This is non-functional today
34 if t == OBJECT and m == "InMode":
35 classname = "Method"
36 listname = "methods"
37 return classname, listname
38
39 def makeblacklistnames(self):
40 return [
41 "TEDispose",
42 "TEInit",
43## "TEGetHiliteRgn",
44 ]
45
46 def makeblacklisttypes(self):
47 return [
48 "TEClickLoopUPP",
49 "UniversalProcPtr",
50 "WordBreakUPP",
51 "TEDoTextUPP",
52 "TERecalcUPP",
53 "TEFindWordUPP",
54 ]
55
56 def makerepairinstructions(self):
57 return [
58 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
59 [("InBuffer", "*", "*")]),
60
61 # TEContinuousStyle
62 ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
63 [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
64 ]
65
66if __name__ == "__main__":
67 main()
Note: See TracBrowser for help on using the repository browser.