Jack Jansen | b996856 | 1995-11-30 15:03:09 +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 | |
| 7 | LONG = "Components" |
| 8 | SHORT = "Cm" |
| 9 | |
| 10 | def main(): |
| 11 | input = "Components.h" |
| 12 | output = SHORT + "gen.py" |
| 13 | defsoutput = LONG + ".py" |
| 14 | scanner = MyScanner(input, output, defsoutput) |
| 15 | scanner.scan() |
| 16 | scanner.close() |
| 17 | print "=== Done scanning and generating, now importing the generated code... ===" |
| 18 | exec "import " + SHORT + "support" |
| 19 | print "=== Done. It's up to you to compile it now! ===" |
| 20 | |
| 21 | class MyScanner(Scanner): |
| 22 | |
| 23 | def destination(self, type, name, arglist): |
| 24 | classname = "Function" |
| 25 | listname = "functions" |
| 26 | if arglist: |
| 27 | t, n, m = arglist[0] |
| 28 | # |
| 29 | # FindNextComponent is a special case, since it call also be called |
| 30 | # with None as the argument. Hence, we make it a function |
| 31 | # |
| 32 | if t == "Component" and m == "InMode" and name != "FindNextComponent": |
| 33 | classname = "Method" |
| 34 | listname = "c_methods" |
| 35 | elif t == "ComponentInstance" and m == "InMode": |
| 36 | classname = "Method" |
| 37 | listname = "ci_methods" |
| 38 | return classname, listname |
| 39 | |
| 40 | def makeblacklistnames(self): |
| 41 | return [ |
| 42 | # "GetComponentInfo" # XXXX I dont know how the Handle args are expected... |
| 43 | ] |
| 44 | |
| 45 | def makeblacklisttypes(self): |
| 46 | return [ |
| 47 | "ResourceSpec", |
| 48 | "ComponentResource", |
| 49 | "ComponentPlatformInfo", |
| 50 | "ComponentResourceExtension", |
| 51 | "ComponentPlatformInfoArray", |
| 52 | "ExtComponentResource", |
| 53 | "ComponentParameters", |
| 54 | |
| 55 | "ComponentRoutineUPP", |
| 56 | ] |
| 57 | |
| 58 | def makerepairinstructions(self): |
| 59 | return [ |
| 60 | ([('ComponentDescription', 'looking', 'OutMode')], |
| 61 | [('ComponentDescription', '*', 'InMode')]), |
| 62 | ] |
| 63 | |
| 64 | if __name__ == "__main__": |
| 65 | main() |