Jack Jansen | da6a971 | 1996-04-12 16:25:30 +0000 | [diff] [blame^] | 1 | # Scan an Apple header file, generating a Python file of generator calls. |
| 2 | # |
| 3 | # Note that the scrap-manager include file is so weird that this |
| 4 | # generates a boilerplate to be edited by hand. |
| 5 | |
| 6 | import addpack |
| 7 | addpack.addpack(':tools:bgen:bgen') |
| 8 | from scantools import Scanner |
| 9 | from bgenlocations import TOOLBOXDIR |
| 10 | |
| 11 | LONG = "Scrap" |
| 12 | SHORT = "Scrap" |
| 13 | |
| 14 | def main(): |
| 15 | input = "Scrap.h" |
| 16 | output = SHORT + "gen.py" |
| 17 | defsoutput = "@Scrap.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 | return classname, listname |
| 31 | |
| 32 | def makeblacklistnames(self): |
| 33 | return [ |
| 34 | ] |
| 35 | |
| 36 | def makeblacklisttypes(self): |
| 37 | return [ |
| 38 | ] |
| 39 | |
| 40 | def makerepairinstructions(self): |
| 41 | return [ |
| 42 | ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), |
| 43 | ] |
| 44 | |
| 45 | if __name__ == "__main__": |
| 46 | main() |