blob: 822651d8a17c2d86d4bcd88fc2798eab60fd06ec [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():
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()
Jack Jansen87eea882002-08-15 21:48:16 +000020 print "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
Jack Jansene32596b1999-03-04 22:54:29 +000022 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[0]
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 writeinitialdefs(self):
40 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
41
42 def makeblacklistnames(self):
43 return [
Jack Jansend6bc4e71999-12-10 16:16:19 +000044 "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
Jack Jansen620e9142000-12-19 21:33:51 +000045 # Constants with funny definitions
46 "appearanceBadBrushIndexErr",
47 "appearanceProcessRegisteredErr",
48 "appearanceProcessNotRegisteredErr",
49 "appearanceBadTextColorIndexErr",
50 "appearanceThemeHasNoAccents",
51 "appearanceBadCursorIndexErr",
Jack Jansene32596b1999-03-04 22:54:29 +000052 ]
53
54 def makeblacklisttypes(self):
55 return [
56 "MenuTitleDrawingUPP",
57 "MenuItemDrawingUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000058 "ThemeIteratorUPP",
59 "ThemeTabTitleDrawUPP",
Just van Rossum6253a112002-01-06 23:03:39 +000060# "ThemeEraseUPP",
61# "ThemeButtonDrawUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000062 "WindowTitleDrawingUPP",
63 "ProcessSerialNumber_ptr", # Too much work for now.
64 "ThemeTrackDrawInfo_ptr", # Too much work
Just van Rossum6253a112002-01-06 23:03:39 +000065# "ThemeButtonDrawInfo_ptr", # ditto
Jack Jansend6bc4e71999-12-10 16:16:19 +000066 "ThemeWindowMetrics_ptr", # ditto
Just van Rossumeae95042002-01-05 23:37:19 +000067# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
Jack Jansend6bc4e71999-12-10 16:16:19 +000068 "Collection", # No interface to collection mgr yet.
Jack Jansen2168e9d2001-12-16 20:18:40 +000069 "BytePtr", # Not yet.
Jack Jansene32596b1999-03-04 22:54:29 +000070 ]
71
72 def makerepairinstructions(self):
73 return [
Just van Rossum4f6fe522002-01-02 15:11:44 +000074 ([("void", 'inContext', "OutMode")],
75 [("NULL", 'inContext', "InMode")]),
76 ([("Point", 'ioBounds', "OutMode")],
77 [("Point", 'ioBounds', "InOutMode")]),
Jack Jansene32596b1999-03-04 22:54:29 +000078 ]
79
80if __name__ == "__main__":
81 main()