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