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