Jack Jansen | 31000dd | 1999-01-18 09:34:50 +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 = "Icons" |
| 11 | SHORT = "icn" |
| 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 makeblacklistnames(self): |
| 39 | return [ |
| 40 | "GetIconCacheData", |
| 41 | "SetIconCacheData", |
Jack Jansen | b1b78d8 | 1999-12-14 15:47:01 +0000 | [diff] [blame] | 42 | # Constants with funny definitions |
| 43 | "kSelectorAllHugeData", |
| 44 | "kSelectorAllAvailableData", |
| 45 | "svAllAvailableData", |
Jack Jansen | 31000dd | 1999-01-18 09:34:50 +0000 | [diff] [blame] | 46 | ] |
| 47 | |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 48 | def makegreylist(self): |
| 49 | return [ |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame^] | 50 | ('#if !TARGET_API_MAC_CARBON', [ |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 51 | 'IconServicesTerminate', |
| 52 | ])] |
| 53 | |
Jack Jansen | 31000dd | 1999-01-18 09:34:50 +0000 | [diff] [blame] | 54 | def makeblacklisttypes(self): |
| 55 | return [ |
| 56 | "IconActionUPP", |
| 57 | "IconGetterUPP", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 58 | "CFragInitBlockPtr", |
Jack Jansen | 31000dd | 1999-01-18 09:34:50 +0000 | [diff] [blame] | 59 | ] |
| 60 | |
| 61 | def makerepairinstructions(self): |
| 62 | return [ |
| 63 | ] |
Jack Jansen | b1b78d8 | 1999-12-14 15:47:01 +0000 | [diff] [blame] | 64 | |
| 65 | def writeinitialdefs(self): |
| 66 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
Jack Jansen | 31000dd | 1999-01-18 09:34:50 +0000 | [diff] [blame] | 67 | |
| 68 | if __name__ == "__main__": |
| 69 | main() |