blob: 1b04859ef2d074064ee888c32b20864a0140b53f [file] [log] [blame]
Jack Jansene32596b1999-03-04 22:54:29 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansene32596b1999-03-04 22:54:29 +00006sys.path.append(BGENDIR)
7from scantools import Scanner
Jack Jansene32596b1999-03-04 22:54:29 +00008
9LONG = "Appearance"
10SHORT = "app"
Just van Rossumeae95042002-01-05 23:37:19 +000011OBJECT = "ThemeDrawingState"
Jack Jansene32596b1999-03-04 22:54:29 +000012
13def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000014 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! ==="
Jack Jansene32596b1999-03-04 22:54:29 +000025
26class MyScanner(Scanner):
27
Tim Peters182b5ac2004-07-18 06:16:08 +000028 def destination(self, type, name, arglist):
29 classname = "Function"
30 listname = "functions"
31 if arglist:
32 t, n, m = arglist[0]
33 # This is non-functional today
34 if t == OBJECT and m == "InMode":
35 classname = "Method"
36 listname = "methods"
37 return classname, listname
Jack Jansene32596b1999-03-04 22:54:29 +000038
Tim Peters182b5ac2004-07-18 06:16:08 +000039 def writeinitialdefs(self):
40 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansene32596b1999-03-04 22:54:29 +000041
Tim Peters182b5ac2004-07-18 06:16:08 +000042 def makeblacklistnames(self):
43 return [
44 "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
45 # Constants with funny definitions
46 "appearanceBadBrushIndexErr",
47 "appearanceProcessRegisteredErr",
48 "appearanceProcessNotRegisteredErr",
49 "appearanceBadTextColorIndexErr",
50 "appearanceThemeHasNoAccents",
51 "appearanceBadCursorIndexErr",
52 ]
Jack Jansene32596b1999-03-04 22:54:29 +000053
Tim Peters182b5ac2004-07-18 06:16:08 +000054 def makeblacklisttypes(self):
55 return [
56 "MenuTitleDrawingUPP",
57 "MenuItemDrawingUPP",
58 "ThemeIteratorUPP",
59 "ThemeTabTitleDrawUPP",
60# "ThemeEraseUPP",
61# "ThemeButtonDrawUPP",
62 "WindowTitleDrawingUPP",
63 "ProcessSerialNumber_ptr", # Too much work for now.
64 "ThemeTrackDrawInfo_ptr", # Too much work
65# "ThemeButtonDrawInfo_ptr", # ditto
66 "ThemeWindowMetrics_ptr", # ditto
67# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
68 "Collection", # No interface to collection mgr yet.
69 "BytePtr", # Not yet.
70 ]
Jack Jansene32596b1999-03-04 22:54:29 +000071
Tim Peters182b5ac2004-07-18 06:16:08 +000072 def makerepairinstructions(self):
73 return [
74 ([("void", 'inContext', "OutMode")],
75 [("NULL", 'inContext', "InMode")]),
76 ([("Point", 'ioBounds', "OutMode")],
77 [("Point", 'ioBounds', "InOutMode")]),
78 ]
79
Jack Jansene32596b1999-03-04 22:54:29 +000080if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000081 main()