1 # Scan an Apple header file, generating a Python file of generator calls.
5 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
6 sys
.path
.append(BGENDIR
)
7 from scantools
import Scanner
8 from bgenlocations
import TOOLBOXDIR
14 input = "Components.h"
15 output
= SHORT
+ "gen.py"
16 defsoutput
= TOOLBOXDIR
+ LONG
+ ".py"
17 scanner
= MyScanner(input, output
, 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
63 def makegreylist(self
):
65 ('#if !TARGET_API_MAC_CARBON', [
66 'SetComponentInstanceA5',
67 'GetComponentInstanceA5',
70 def makeblacklisttypes(self
):
74 "ComponentPlatformInfo",
75 "ComponentResourceExtension",
76 "ComponentPlatformInfoArray",
77 "ExtComponentResource",
78 "ComponentParameters",
80 "ComponentRoutineUPP",
81 "ComponentMPWorkFunctionUPP",
82 "ComponentFunctionUPP",
83 "GetMissingComponentResourceUPP",
86 def makerepairinstructions(self
):
88 ([('ComponentDescription', 'looking', 'OutMode')],
89 [('ComponentDescription', '*', 'InMode')]),
92 if __name__
== "__main__":