2001-11-05 10:44:23 -04:00
|
|
|
# IBCarbonscan.py
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import MacOS
|
2001-11-05 12:15:45 -04:00
|
|
|
import sys
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2002-08-05 12:39:30 -03:00
|
|
|
from bgenlocations import TOOLBOXDIR, BGENDIR
|
2001-11-05 10:44:23 -04:00
|
|
|
sys.path.append(BGENDIR)
|
|
|
|
|
|
|
|
from scantools import Scanner, Scanner_OSX
|
|
|
|
|
|
|
|
def main():
|
2004-07-18 03:16:08 -03:00
|
|
|
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"
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
RefObjectTypes = ["EventRef",
|
|
|
|
"EventQueueRef",
|
|
|
|
"EventLoopRef",
|
|
|
|
"EventLoopTimerRef",
|
|
|
|
"EventHandlerRef",
|
|
|
|
"EventHandlerCallRef",
|
|
|
|
"EventTargetRef",
|
|
|
|
"EventHotKeyRef",
|
|
|
|
]
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2001-12-12 16:48:53 -04:00
|
|
|
class CarbonEvents_Scanner(Scanner_OSX):
|
2004-07-18 03:16:08 -03:00
|
|
|
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
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
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")
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
|
|
|
"sHandler",
|
|
|
|
"MacCreateEvent",
|
|
|
|
# "TrackMouseLocationWithOptions",
|
|
|
|
# "TrackMouseLocation",
|
|
|
|
# "TrackMouseRegion",
|
|
|
|
"RegisterToolboxObjectClass",
|
|
|
|
"UnregisterToolboxObjectClass",
|
|
|
|
"ProcessHICommand",
|
|
|
|
"GetCFRunLoopFromEventLoop",
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
"InvokeEventHandlerUPP",
|
|
|
|
"InvokeEventComparatorUPP",
|
|
|
|
"InvokeEventLoopTimerUPP",
|
|
|
|
"NewEventComparatorUPP",
|
|
|
|
"NewEventLoopTimerUPP",
|
|
|
|
"NewEventHandlerUPP",
|
|
|
|
"DisposeEventComparatorUPP",
|
|
|
|
"DisposeEventLoopTimerUPP",
|
|
|
|
"DisposeEventHandlerUPP",
|
2001-11-05 10:44:23 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
# Wrote by hand
|
|
|
|
"InstallEventHandler",
|
|
|
|
"RemoveEventHandler",
|
2001-11-05 12:15:45 -04:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
# 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")]),
|
|
|
|
]
|
2002-01-09 14:54:16 -04:00
|
|
|
|
2001-11-05 10:44:23 -04:00
|
|
|
if __name__ == "__main__":
|
2004-07-18 03:16:08 -03:00
|
|
|
main()
|