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