Jack Jansen | 6259af9 | 1996-01-09 17:15:16 +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 |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 6 | from bgenlocations import TOOLBOXDIR |
Jack Jansen | 6259af9 | 1996-01-09 17:15:16 +0000 | [diff] [blame] | 7 | |
| 8 | LONG = "Fonts" |
| 9 | SHORT = "Fm" |
| 10 | |
| 11 | def main(): |
| 12 | input = "Fonts.h" |
| 13 | output = SHORT + "gen.py" |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 14 | defsoutput = TOOLBOXDIR + LONG + ".py" |
Jack Jansen | 6259af9 | 1996-01-09 17:15:16 +0000 | [diff] [blame] | 15 | scanner = MyScanner(input, output, defsoutput) |
| 16 | scanner.scan() |
| 17 | scanner.close() |
| 18 | print "=== Done scanning and generating, now importing the generated code... ===" |
| 19 | exec "import " + SHORT + "support" |
| 20 | print "=== Done. It's up to you to compile it now! ===" |
| 21 | |
| 22 | class MyScanner(Scanner): |
| 23 | |
| 24 | def destination(self, type, name, arglist): |
| 25 | classname = "Function" |
| 26 | listname = "functions" |
| 27 | return classname, listname |
| 28 | |
| 29 | def makeblacklistnames(self): |
| 30 | return [ |
| 31 | "OutlineMetrics", # Too complicated |
| 32 | ] |
| 33 | |
| 34 | def makeblacklisttypes(self): |
| 35 | return [ |
| 36 | "FMInput_ptr", # Not needed for now |
| 37 | "FMOutPtr", # Ditto |
| 38 | ] |
| 39 | |
| 40 | def makerepairinstructions(self): |
| 41 | return [ |
| 42 | ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]), |
| 43 | ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]), |
| 44 | ] |
| 45 | |
| 46 | if __name__ == "__main__": |
| 47 | main() |