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