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