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