blob: 286d3ce5167daa12953afbec88cd3f7044774b6d [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()
20 print "=== Done scanning and generating, now importing the generated code... ==="
21 exec "import " + SHORT + "support"
22 print "=== Done. It's up to you to compile it now! ==="
23
24class MyScanner(Scanner):
25
26 def destination(self, type, name, arglist):
27 classname = "Function"
28 listname = "functions"
29 if arglist:
30 t, n, m = arglist[0]
31 # This is non-functional today
32 if t == OBJECT and m == "InMode":
33 classname = "Method"
34 listname = "methods"
35 return classname, listname
36
37 def writeinitialdefs(self):
38 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
39
40 def makeblacklistnames(self):
41 return [
Jack Jansend6bc4e71999-12-10 16:16:19 +000042 "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
Jack Jansen620e9142000-12-19 21:33:51 +000043 # Constants with funny definitions
44 "appearanceBadBrushIndexErr",
45 "appearanceProcessRegisteredErr",
46 "appearanceProcessNotRegisteredErr",
47 "appearanceBadTextColorIndexErr",
48 "appearanceThemeHasNoAccents",
49 "appearanceBadCursorIndexErr",
Jack Jansene32596b1999-03-04 22:54:29 +000050 ]
51
Jack Jansenf7d5aa62000-12-10 23:43:49 +000052 def makegreylist(self):
53 return [
54 ('#if TARGET_API_MAC_CARBON', [
55 'GetThemeMetric',
Jack Jansen2168e9d2001-12-16 20:18:40 +000056 'GetThemeTextShadowOutset',
57 'GetThemeTextDimensions',
58 'TruncateThemeText',
Just van Rossum4f6fe522002-01-02 15:11:44 +000059 'DrawThemeTextBox',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000060 ])]
61
Jack Jansene32596b1999-03-04 22:54:29 +000062 def makeblacklisttypes(self):
63 return [
64 "MenuTitleDrawingUPP",
65 "MenuItemDrawingUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000066 "ThemeIteratorUPP",
67 "ThemeTabTitleDrawUPP",
Just van Rossum6253a112002-01-06 23:03:39 +000068# "ThemeEraseUPP",
69# "ThemeButtonDrawUPP",
Jack Jansend6bc4e71999-12-10 16:16:19 +000070 "WindowTitleDrawingUPP",
71 "ProcessSerialNumber_ptr", # Too much work for now.
72 "ThemeTrackDrawInfo_ptr", # Too much work
Just van Rossum6253a112002-01-06 23:03:39 +000073# "ThemeButtonDrawInfo_ptr", # ditto
Jack Jansend6bc4e71999-12-10 16:16:19 +000074 "ThemeWindowMetrics_ptr", # ditto
Just van Rossumeae95042002-01-05 23:37:19 +000075# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
Jack Jansend6bc4e71999-12-10 16:16:19 +000076 "Collection", # No interface to collection mgr yet.
Jack Jansen2168e9d2001-12-16 20:18:40 +000077 "BytePtr", # Not yet.
Jack Jansene32596b1999-03-04 22:54:29 +000078 ]
79
80 def makerepairinstructions(self):
81 return [
Just van Rossum4f6fe522002-01-02 15:11:44 +000082 ([("void", 'inContext', "OutMode")],
83 [("NULL", 'inContext', "InMode")]),
84 ([("Point", 'ioBounds', "OutMode")],
85 [("Point", 'ioBounds', "InOutMode")]),
Jack Jansene32596b1999-03-04 22:54:29 +000086 ]
87
88if __name__ == "__main__":
89 main()