ยปCore Development>Code coverage>Mac/Modules/cm/cmscan.py

Python code coverage for Mac/Modules/cm/cmscan.py

#countcontent
1n/a# Scan an Apple header file, generating a Python file of generator calls.
2n/a
3n/aimport sys
4n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
5n/asys.path.append(BGENDIR)
6n/afrom scantools import Scanner
7n/a
8n/aLONG = "Components"
9n/aSHORT = "cm"
10n/a
11n/adef main():
12n/a input = "Components.h"
13n/a output = SHORT + "gen.py"
14n/a defsoutput = TOOLBOXDIR + LONG + ".py"
15n/a scanner = MyScanner(input, output, defsoutput)
16n/a scanner.scan()
17n/a scanner.close()
18n/a print "=== Testing definitions output code ==="
19n/a execfile(defsoutput, {}, {})
20n/a print "=== Done scanning and generating, now importing the generated code... ==="
21n/a exec "import " + SHORT + "support"
22n/a print "=== Done. It's up to you to compile it now! ==="
23n/a
24n/aclass MyScanner(Scanner):
25n/a
26n/a def destination(self, type, name, arglist):
27n/a classname = "Function"
28n/a listname = "functions"
29n/a if arglist:
30n/a t, n, m = arglist[0]
31n/a #
32n/a # FindNextComponent is a special case, since it call also be called
33n/a # with None as the argument. Hence, we make it a function
34n/a #
35n/a if t == "Component" and m == "InMode" and name != "FindNextComponent":
36n/a classname = "Method"
37n/a listname = "c_methods"
38n/a elif t == "ComponentInstance" and m == "InMode":
39n/a classname = "Method"
40n/a listname = "ci_methods"
41n/a return classname, listname
42n/a
43n/a def writeinitialdefs(self):
44n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
45n/a
46n/a def makeblacklistnames(self):
47n/a return [
48n/a "OpenADefaultComponent",
49n/a "GetComponentTypeModSeed",
50n/a "OpenAComponentResFile",
51n/a "CallComponentUnregister",
52n/a "CallComponentTarget",
53n/a "CallComponentRegister",
54n/a "CallComponentVersion",
55n/a "CallComponentCanDo",
56n/a "CallComponentClose",
57n/a "CallComponentOpen",
58n/a "OpenAComponent",
59n/a "GetComponentPublicResource", # Missing in CW Pro 6
60n/a "CallComponentGetPublicResource", # Missing in CW Pro 6
61n/a 'SetComponentInstanceA5',
62n/a 'GetComponentInstanceA5',
63n/a ]
64n/a
65n/a def makeblacklisttypes(self):
66n/a return [
67n/a "ResourceSpec",
68n/a "ComponentResource",
69n/a "ComponentPlatformInfo",
70n/a "ComponentResourceExtension",
71n/a "ComponentPlatformInfoArray",
72n/a "ExtComponentResource",
73n/a "ComponentParameters",
74n/a
75n/a "ComponentRoutineUPP",
76n/a "ComponentMPWorkFunctionUPP",
77n/a "ComponentFunctionUPP",
78n/a "GetMissingComponentResourceUPP",
79n/a ]
80n/a
81n/a def makerepairinstructions(self):
82n/a return [
83n/a ([('ComponentDescription', 'looking', 'OutMode')],
84n/a [('ComponentDescription', '*', 'InMode')]),
85n/a ]
86n/a
87n/aif __name__ == "__main__":
88n/a main()