1 # Scan an Apple header file, generating a Python file of generator calls.
4 from bgenlocations
import TOOLBOXDIR
, BGENDIR
5 sys
.path
.append(BGENDIR
)
6 from scantools
import Scanner
12 input = "Components.h"
13 output
= SHORT
+ "gen.py"
14 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
15 scanner
= MyScanner(input, output
, defsoutput
)
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! ==="
24 class MyScanner(Scanner
):
26 def destination(self
, type, name
, arglist
):
27 classname
= "Function"
28 listname
= "functions"
32 # FindNextComponent is a special case, since it call also be called
33 # with None as the argument. Hence, we make it a function
35 if t
== "Component" and m
== "InMode" and name
!= "FindNextComponent":
37 listname
= "c_methods"
38 elif t
== "ComponentInstance" and m
== "InMode":
40 listname
= "ci_methods"
41 return classname
, listname
43 def writeinitialdefs(self
):
44 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
46 def makeblacklistnames(self
):
48 "OpenADefaultComponent",
49 "GetComponentTypeModSeed",
50 "OpenAComponentResFile",
51 "CallComponentUnregister",
52 "CallComponentTarget",
53 "CallComponentRegister",
54 "CallComponentVersion",
59 "GetComponentPublicResource", # Missing in CW Pro 6
60 "CallComponentGetPublicResource", # Missing in CW Pro 6
61 'SetComponentInstanceA5',
62 'GetComponentInstanceA5',
65 def makeblacklisttypes(self
):
69 "ComponentPlatformInfo",
70 "ComponentResourceExtension",
71 "ComponentPlatformInfoArray",
72 "ExtComponentResource",
73 "ComponentParameters",
75 "ComponentRoutineUPP",
76 "ComponentMPWorkFunctionUPP",
77 "ComponentFunctionUPP",
78 "GetMissingComponentResourceUPP",
81 def makerepairinstructions(self
):
83 ([('ComponentDescription', 'looking', 'OutMode')],
84 [('ComponentDescription', '*', 'InMode')]),
87 if __name__
== "__main__":