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