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
64 def makegreylist(self
):
66 ('#if !TARGET_API_MAC_CARBON', [
67 'SetComponentInstanceA5',
68 'GetComponentInstanceA5',
71 def makeblacklisttypes(self
):
75 "ComponentPlatformInfo",
76 "ComponentResourceExtension",
77 "ComponentPlatformInfoArray",
78 "ExtComponentResource",
79 "ComponentParameters",
81 "ComponentRoutineUPP",
82 "ComponentMPWorkFunctionUPP",
83 "ComponentFunctionUPP",
84 "GetMissingComponentResourceUPP",
87 def makerepairinstructions(self
):
89 ([('ComponentDescription', 'looking', 'OutMode')],
90 [('ComponentDescription', '*', 'InMode')]),
93 if __name__
== "__main__":