move sections
[python/dscho.git] / Mac / Modules / app / appscan.py
blob94eee474c12ffb5f2c368748238aafa08ca71352
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5 sys.path.append(BGENDIR)
6 from scantools import Scanner
8 LONG = "Appearance"
9 SHORT = "app"
10 OBJECT = "ThemeDrawingState"
12 def main():
13 input = LONG + ".h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
21 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
25 class MyScanner(Scanner):
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 # This is non-functional today
33 if t == OBJECT and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
38 def writeinitialdefs(self):
39 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
41 def makeblacklistnames(self):
42 return [
43 "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
44 # Constants with funny definitions
45 "appearanceBadBrushIndexErr",
46 "appearanceProcessRegisteredErr",
47 "appearanceProcessNotRegisteredErr",
48 "appearanceBadTextColorIndexErr",
49 "appearanceThemeHasNoAccents",
50 "appearanceBadCursorIndexErr",
53 def makeblacklisttypes(self):
54 return [
55 "MenuTitleDrawingUPP",
56 "MenuItemDrawingUPP",
57 "ThemeIteratorUPP",
58 "ThemeTabTitleDrawUPP",
59 # "ThemeEraseUPP",
60 # "ThemeButtonDrawUPP",
61 "WindowTitleDrawingUPP",
62 "ProcessSerialNumber_ptr", # Too much work for now.
63 "ThemeTrackDrawInfo_ptr", # Too much work
64 # "ThemeButtonDrawInfo_ptr", # ditto
65 "ThemeWindowMetrics_ptr", # ditto
66 # "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
67 "Collection", # No interface to collection mgr yet.
68 "BytePtr", # Not yet.
71 def makerepairinstructions(self):
72 return [
73 ([("void", 'inContext', "OutMode")],
74 [("NULL", 'inContext', "InMode")]),
75 ([("Point", 'ioBounds', "OutMode")],
76 [("Point", 'ioBounds', "InOutMode")]),
79 if __name__ == "__main__":
80 main()