Jack Jansen | bf2f602 | 1997-09-09 13:52:47 +0000 | [diff] [blame] | 1 | # Scan an Apple header file, generating a Python file of generator calls. |
| 2 | |
| 3 | import addpack |
| 4 | addpack.addpack(':tools:bgen:bgen') |
| 5 | from scantools import Scanner |
| 6 | from bgenlocations import TOOLBOXDIR |
| 7 | |
| 8 | LONG = "Balloons" |
| 9 | SHORT = "help" |
| 10 | OBJECT = "NOTUSED" |
| 11 | |
| 12 | def main(): |
| 13 | input = LONG + ".h" |
| 14 | output = SHORT + "gen.py" |
| 15 | defsoutput = TOOLBOXDIR + LONG + ".py" |
| 16 | scanner = MyScanner(input, output, defsoutput) |
| 17 | scanner.scan() |
| 18 | scanner.close() |
| 19 | print "=== Done scanning and generating, now importing the generated code... ===" |
| 20 | exec "import " + SHORT + "support" |
| 21 | print "=== Done. It's up to you to compile it now! ===" |
| 22 | |
| 23 | class MyScanner(Scanner): |
| 24 | |
| 25 | def destination(self, type, name, arglist): |
| 26 | classname = "Function" |
| 27 | listname = "functions" |
| 28 | if arglist: |
| 29 | t, n, m = arglist[0] |
| 30 | # This is non-functional today |
| 31 | if t == OBJECT and m == "InMode": |
| 32 | classname = "Method" |
| 33 | listname = "methods" |
| 34 | return classname, listname |
| 35 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame^] | 36 | def writeinitialdefs(self): |
| 37 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 38 | |
Jack Jansen | bf2f602 | 1997-09-09 13:52:47 +0000 | [diff] [blame] | 39 | def makeblacklistnames(self): |
| 40 | return [ |
| 41 | ] |
| 42 | |
| 43 | def makeblacklisttypes(self): |
| 44 | return [ |
| 45 | "TipFunctionUPP", |
| 46 | "HMMessageRecord", |
| 47 | "HMMessageRecord_ptr", |
| 48 | ] |
| 49 | |
| 50 | def makerepairinstructions(self): |
| 51 | return [ |
| 52 | ] |
| 53 | |
| 54 | if __name__ == "__main__": |
| 55 | main() |