| 1 | n/a | # Scan an Apple header file, generating a Python file of generator calls. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | import sys |
|---|
| 4 | n/a | from bgenlocations import TOOLBOXDIR, BGENDIR |
|---|
| 5 | n/a | sys.path.append(BGENDIR) |
|---|
| 6 | n/a | from scantools import Scanner |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | LONG = "Components" |
|---|
| 9 | n/a | SHORT = "cm" |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | def main(): |
|---|
| 12 | n/a | input = "Components.h" |
|---|
| 13 | n/a | output = SHORT + "gen.py" |
|---|
| 14 | n/a | defsoutput = TOOLBOXDIR + LONG + ".py" |
|---|
| 15 | n/a | scanner = MyScanner(input, output, defsoutput) |
|---|
| 16 | n/a | scanner.scan() |
|---|
| 17 | n/a | scanner.close() |
|---|
| 18 | n/a | print "=== Testing definitions output code ===" |
|---|
| 19 | n/a | execfile(defsoutput, {}, {}) |
|---|
| 20 | n/a | print "=== Done scanning and generating, now importing the generated code... ===" |
|---|
| 21 | n/a | exec "import " + SHORT + "support" |
|---|
| 22 | n/a | print "=== Done. It's up to you to compile it now! ===" |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | class MyScanner(Scanner): |
|---|
| 25 | n/a | |
|---|
| 26 | n/a | def destination(self, type, name, arglist): |
|---|
| 27 | n/a | classname = "Function" |
|---|
| 28 | n/a | listname = "functions" |
|---|
| 29 | n/a | if arglist: |
|---|
| 30 | n/a | t, n, m = arglist[0] |
|---|
| 31 | n/a | # |
|---|
| 32 | n/a | # FindNextComponent is a special case, since it call also be called |
|---|
| 33 | n/a | # with None as the argument. Hence, we make it a function |
|---|
| 34 | n/a | # |
|---|
| 35 | n/a | if t == "Component" and m == "InMode" and name != "FindNextComponent": |
|---|
| 36 | n/a | classname = "Method" |
|---|
| 37 | n/a | listname = "c_methods" |
|---|
| 38 | n/a | elif t == "ComponentInstance" and m == "InMode": |
|---|
| 39 | n/a | classname = "Method" |
|---|
| 40 | n/a | listname = "ci_methods" |
|---|
| 41 | n/a | return classname, listname |
|---|
| 42 | n/a | |
|---|
| 43 | n/a | def writeinitialdefs(self): |
|---|
| 44 | n/a | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
|---|
| 45 | n/a | |
|---|
| 46 | n/a | def makeblacklistnames(self): |
|---|
| 47 | n/a | return [ |
|---|
| 48 | n/a | "OpenADefaultComponent", |
|---|
| 49 | n/a | "GetComponentTypeModSeed", |
|---|
| 50 | n/a | "OpenAComponentResFile", |
|---|
| 51 | n/a | "CallComponentUnregister", |
|---|
| 52 | n/a | "CallComponentTarget", |
|---|
| 53 | n/a | "CallComponentRegister", |
|---|
| 54 | n/a | "CallComponentVersion", |
|---|
| 55 | n/a | "CallComponentCanDo", |
|---|
| 56 | n/a | "CallComponentClose", |
|---|
| 57 | n/a | "CallComponentOpen", |
|---|
| 58 | n/a | "OpenAComponent", |
|---|
| 59 | n/a | "GetComponentPublicResource", # Missing in CW Pro 6 |
|---|
| 60 | n/a | "CallComponentGetPublicResource", # Missing in CW Pro 6 |
|---|
| 61 | n/a | 'SetComponentInstanceA5', |
|---|
| 62 | n/a | 'GetComponentInstanceA5', |
|---|
| 63 | n/a | ] |
|---|
| 64 | n/a | |
|---|
| 65 | n/a | def makeblacklisttypes(self): |
|---|
| 66 | n/a | return [ |
|---|
| 67 | n/a | "ResourceSpec", |
|---|
| 68 | n/a | "ComponentResource", |
|---|
| 69 | n/a | "ComponentPlatformInfo", |
|---|
| 70 | n/a | "ComponentResourceExtension", |
|---|
| 71 | n/a | "ComponentPlatformInfoArray", |
|---|
| 72 | n/a | "ExtComponentResource", |
|---|
| 73 | n/a | "ComponentParameters", |
|---|
| 74 | n/a | |
|---|
| 75 | n/a | "ComponentRoutineUPP", |
|---|
| 76 | n/a | "ComponentMPWorkFunctionUPP", |
|---|
| 77 | n/a | "ComponentFunctionUPP", |
|---|
| 78 | n/a | "GetMissingComponentResourceUPP", |
|---|
| 79 | n/a | ] |
|---|
| 80 | n/a | |
|---|
| 81 | n/a | def makerepairinstructions(self): |
|---|
| 82 | n/a | return [ |
|---|
| 83 | n/a | ([('ComponentDescription', 'looking', 'OutMode')], |
|---|
| 84 | n/a | [('ComponentDescription', '*', 'InMode')]), |
|---|
| 85 | n/a | ] |
|---|
| 86 | n/a | |
|---|
| 87 | n/a | if __name__ == "__main__": |
|---|
| 88 | n/a | main() |
|---|