append(): Fixing the test for convertability after consultation with
[python/dscho.git] / Mac / Modules / cm / cmscan.py
blob7ca15f24fb17ffbf509444977917c17ba321eceb
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 import os
5 from bgenlocations import TOOLBOXDIR, BGENDIR
6 sys.path.append(BGENDIR)
7 from scantools import Scanner
9 LONG = "Components"
10 SHORT = "cm"
12 def main():
13 input = "Components.h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
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"
30 if arglist:
31 t, n, m = arglist[0]
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":
37 classname = "Method"
38 listname = "c_methods"
39 elif t == "ComponentInstance" and m == "InMode":
40 classname = "Method"
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):
48 return [
49 "OpenADefaultComponent",
50 "GetComponentTypeModSeed",
51 "OpenAComponentResFile",
52 "CallComponentUnregister",
53 "CallComponentTarget",
54 "CallComponentRegister",
55 "CallComponentVersion",
56 "CallComponentCanDo",
57 "CallComponentClose",
58 "CallComponentOpen",
59 "OpenAComponent",
60 "GetComponentPublicResource", # Missing in CW Pro 6
61 "CallComponentGetPublicResource", # Missing in CW Pro 6
64 def makegreylist(self):
65 return [
66 ('#if !TARGET_API_MAC_CARBON', [
67 'SetComponentInstanceA5',
68 'GetComponentInstanceA5',
69 ])]
71 def makeblacklisttypes(self):
72 return [
73 "ResourceSpec",
74 "ComponentResource",
75 "ComponentPlatformInfo",
76 "ComponentResourceExtension",
77 "ComponentPlatformInfoArray",
78 "ExtComponentResource",
79 "ComponentParameters",
81 "ComponentRoutineUPP",
82 "ComponentMPWorkFunctionUPP",
83 "ComponentFunctionUPP",
84 "GetMissingComponentResourceUPP",
87 def makerepairinstructions(self):
88 return [
89 ([('ComponentDescription', 'looking', 'OutMode')],
90 [('ComponentDescription', '*', 'InMode')]),
93 if __name__ == "__main__":
94 main()