blob: 695e0d94636ba704cbd23465121287610a795609 [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
Jack Jansenf7d5aa62000-12-10 23:43:49 +000054 def makegreylist(self):
55 return [
56 ('#if TARGET_API_MAC_CARBON', [
57 'GetThemeMetric',
Jack Jansen2168e9d2001-12-16 20:18:40 +000058 'GetThemeTextShadowOutset',
59 'GetThemeTextDimensions',
60 'TruncateThemeText',
Just van Rossum4f6fe522002-01-02 15:11:44 +000061 'DrawThemeTextBox',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000062 ])]
63
Jack Jansene32596b1999-03-04 22:54:29 +000064 def makeblacklisttypes(self):
65 return [
66 "MenuTitleDrawingUPP",
67 "MenuItemDrawingUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000068 "ThemeIteratorUPP",
69 "ThemeTabTitleDrawUPP",
Just van Rossum6253a112002-01-06 23:03:39 +000070# "ThemeEraseUPP",
71# "ThemeButtonDrawUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000072 "WindowTitleDrawingUPP",
73 "ProcessSerialNumber_ptr", # Too much work for now.
74 "ThemeTrackDrawInfo_ptr", # Too much work
Just van Rossum6253a112002-01-06 23:03:39 +000075# "ThemeButtonDrawInfo_ptr", # ditto
Jack Jansend6bc4e71999-12-10 16:16:19 +000076 "ThemeWindowMetrics_ptr", # ditto
Just van Rossumeae95042002-01-05 23:37:19 +000077# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
Jack Jansend6bc4e71999-12-10 16:16:19 +000078 "Collection", # No interface to collection mgr yet.
Jack Jansen2168e9d2001-12-16 20:18:40 +000079 "BytePtr", # Not yet.
Jack Jansene32596b1999-03-04 22:54:29 +000080 ]
81
82 def makerepairinstructions(self):
83 return [
Just van Rossum4f6fe522002-01-02 15:11:44 +000084 ([("void", 'inContext', "OutMode")],
85 [("NULL", 'inContext', "InMode")]),
86 ([("Point", 'ioBounds', "OutMode")],
87 [("Point", 'ioBounds', "InOutMode")]),
Jack Jansene32596b1999-03-04 22:54:29 +000088 ]
89
90if __name__ == "__main__":
91 main()