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 | |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 6 | import sys |
| 7 | import os |
| 8 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 9 | sys.path.append(BGENDIR) |
Jack Jansen | da6a971 | 1996-04-12 16:25:30 +0000 | [diff] [blame] | 10 | from scantools import Scanner |
| 11 | from bgenlocations import TOOLBOXDIR |
| 12 | |
| 13 | LONG = "Scrap" |
| 14 | SHORT = "Scrap" |
| 15 | |
| 16 | def main(): |
| 17 | input = "Scrap.h" |
| 18 | output = SHORT + "gen.py" |
| 19 | defsoutput = "@Scrap.py" |
| 20 | scanner = MyScanner(input, output, defsoutput) |
| 21 | scanner.scan() |
| 22 | scanner.close() |
| 23 | print "=== Done scanning and generating, now importing the generated code... ===" |
| 24 | exec "import " + SHORT + "support" |
| 25 | print "=== Done. It's up to you to compile it now! ===" |
| 26 | |
| 27 | class MyScanner(Scanner): |
| 28 | |
| 29 | def destination(self, type, name, arglist): |
| 30 | classname = "Function" |
| 31 | listname = "functions" |
| 32 | return classname, listname |
| 33 | |
| 34 | def makeblacklistnames(self): |
| 35 | return [ |
| 36 | ] |
| 37 | |
| 38 | def makeblacklisttypes(self): |
| 39 | return [ |
| 40 | ] |
| 41 | |
| 42 | def makerepairinstructions(self): |
| 43 | return [ |
| 44 | ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), |
| 45 | ] |
| 46 | |
| 47 | if __name__ == "__main__": |
| 48 | main() |