ยปCore Development>Code coverage>Mac/Modules/carbonevt/CarbonEvtscan.py

Python code coverage for Mac/Modules/carbonevt/CarbonEvtscan.py

#countcontent
1n/a# IBCarbonscan.py
2n/a
3n/aimport sys
4n/aimport MacOS
5n/aimport sys
6n/a
7n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
8n/asys.path.append(BGENDIR)
9n/a
10n/afrom scantools import Scanner, Scanner_OSX
11n/a
12n/adef main():
13n/a print "---Scanning CarbonEvents.h---"
14n/a input = ["CarbonEvents.h"]
15n/a output = "CarbonEventsgen.py"
16n/a defsoutput = TOOLBOXDIR + "CarbonEvents.py"
17n/a scanner = CarbonEvents_Scanner(input, output, defsoutput)
18n/a scanner.scan()
19n/a scanner.close()
20n/a print "=== Testing definitions output code ==="
21n/a execfile(defsoutput, {}, {})
22n/a print "--done scanning, importing--"
23n/a import CarbonEvtsupport
24n/a print "done"
25n/a
26n/aRefObjectTypes = ["EventRef",
27n/a "EventQueueRef",
28n/a "EventLoopRef",
29n/a "EventLoopTimerRef",
30n/a "EventHandlerRef",
31n/a "EventHandlerCallRef",
32n/a "EventTargetRef",
33n/a "EventHotKeyRef",
34n/a ]
35n/a
36n/aclass CarbonEvents_Scanner(Scanner_OSX):
37n/a def destination(self, type, name, arglist):
38n/a classname = "CarbonEventsFunction"
39n/a listname = "functions"
40n/a if arglist:
41n/a t, n, m = arglist[0]
42n/a if t in RefObjectTypes and m == "InMode":
43n/a if t == "EventHandlerRef":
44n/a classname = "EventHandlerRefMethod"
45n/a else:
46n/a classname = "CarbonEventsMethod"
47n/a listname = t + "methods"
48n/a #else:
49n/a # print "not method"
50n/a return classname, listname
51n/a
52n/a def writeinitialdefs(self):
53n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
54n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
55n/a self.defsfile.write("false = 0\n")
56n/a self.defsfile.write("true = 1\n")
57n/a self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n")
58n/a self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n")
59n/a
60n/a def makeblacklistnames(self):
61n/a return [
62n/a "sHandler",
63n/a "MacCreateEvent",
64n/a# "TrackMouseLocationWithOptions",
65n/a# "TrackMouseLocation",
66n/a# "TrackMouseRegion",
67n/a "RegisterToolboxObjectClass",
68n/a "UnregisterToolboxObjectClass",
69n/a "ProcessHICommand",
70n/a "GetCFRunLoopFromEventLoop",
71n/a
72n/a "InvokeEventHandlerUPP",
73n/a "InvokeEventComparatorUPP",
74n/a "InvokeEventLoopTimerUPP",
75n/a "NewEventComparatorUPP",
76n/a "NewEventLoopTimerUPP",
77n/a "NewEventHandlerUPP",
78n/a "DisposeEventComparatorUPP",
79n/a "DisposeEventLoopTimerUPP",
80n/a "DisposeEventHandlerUPP",
81n/a
82n/a # Wrote by hand
83n/a "InstallEventHandler",
84n/a "RemoveEventHandler",
85n/a
86n/a # Write by hand?
87n/a "GetEventParameter",
88n/a "FlushSpecificEventsFromQueue",
89n/a "FindSpecificEventInQueue",
90n/a "InstallEventLoopTimer",
91n/a
92n/a # Don't do these because they require a CFRelease
93n/a "CreateTypeStringWithOSType",
94n/a "CopyEvent",
95n/a ]
96n/a
97n/a# def makeblacklisttypes(self):
98n/a# return ["EventComparatorUPP",
99n/a# "EventLoopTimerUPP",
100n/a# #"EventHandlerUPP",
101n/a# "EventComparatorProcPtr",
102n/a# "EventLoopTimerProcPtr",
103n/a# "EventHandlerProcPtr",
104n/a# ]
105n/a
106n/a def makerepairinstructions(self):
107n/a return [
108n/a ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
109n/a [("MyInBuffer", 'inDataPtr', "InMode")]),
110n/a ([("Boolean", 'ioWasInRgn', "OutMode")],
111n/a [("Boolean", 'ioWasInRgn', "InOutMode")]),
112n/a ]
113n/a
114n/aif __name__ == "__main__":
115n/a main()