ยปCore Development>Code coverage>Mac/Modules/ae/aescan.py

Python code coverage for Mac/Modules/ae/aescan.py

#countcontent
1n/a# Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
2n/a# Then run aesupport to generate AEmodule.c.
3n/a# (Should learn how to tell the compiler to compile it as well.)
4n/a
5n/aimport sys
6n/aimport MacOS
7n/a
8n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
9n/asys.path.append(BGENDIR)
10n/a
11n/afrom scantools import Scanner
12n/a
13n/adef main():
14n/a print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
15n/a input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
16n/a output = "aegen.py"
17n/a defsoutput = TOOLBOXDIR + "AppleEvents.py"
18n/a scanner = AppleEventsScanner(input, output, defsoutput)
19n/a scanner.scan()
20n/a scanner.close()
21n/a print "=== Testing definitions output code ==="
22n/a execfile(defsoutput, {}, {})
23n/a print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
24n/a import aesupport
25n/a print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
26n/a
27n/aclass AppleEventsScanner(Scanner):
28n/a
29n/a def destination(self, type, name, arglist):
30n/a classname = "AEFunction"
31n/a listname = "functions"
32n/a if arglist:
33n/a t, n, m = arglist[0]
34n/a if t[-4:] == "_ptr" and m == "InMode" and \
35n/a t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
36n/a "AERecord", "AppleEvent"):
37n/a classname = "AEMethod"
38n/a listname = "aedescmethods"
39n/a return classname, listname
40n/a
41n/a def makeblacklistnames(self):
42n/a return [
43n/a "AEDisposeDesc",
44n/a# "AEGetEventHandler",
45n/a "AEGetDescData", # Use object.data
46n/a "AEGetSpecialHandler",
47n/a # Constants with funny definitions
48n/a "kAEDontDisposeOnResume",
49n/a "kAEUseStandardDispatch",
50n/a ]
51n/a
52n/a def makeblacklisttypes(self):
53n/a return [
54n/a "ProcPtr",
55n/a "AEArrayType",
56n/a "AECoercionHandlerUPP",
57n/a "UniversalProcPtr",
58n/a "OSLCompareUPP",
59n/a "OSLAccessorUPP",
60n/a ]
61n/a
62n/a def makerepairinstructions(self):
63n/a return [
64n/a ([("Boolean", "isSysHandler", "InMode")],
65n/a [("AlwaysFalse", "*", "*")]),
66n/a
67n/a ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
68n/a [("InBuffer", "*", "*")]),
69n/a
70n/a ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
71n/a [("EventHandler", "*", "*")]),
72n/a
73n/a ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
74n/a [("EventHandler", "*", "*")]),
75n/a
76n/a ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
77n/a [("EventHandler", "*", "*")]),
78n/a
79n/a ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
80n/a [("EventHandler", "*", "*")]),
81n/a
82n/a ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
83n/a ("Size", "*", "OutMode")],
84n/a [("VarVarOutBuffer", "*", "InOutMode")]),
85n/a
86n/a ([("AppleEvent", "theAppleEvent", "OutMode")],
87n/a [("AppleEvent_ptr", "*", "InMode")]),
88n/a
89n/a ([("AEDescList", "theAEDescList", "OutMode")],
90n/a [("AEDescList_ptr", "*", "InMode")]),
91n/a ]
92n/a
93n/a def writeinitialdefs(self):
94n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
95n/a
96n/aif __name__ == "__main__":
97n/a main()