2001-11-05 10:44:23 -04:00
|
|
|
# IBCarbonscan.py
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import string
|
|
|
|
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():
|
|
|
|
print "---Scanning CarbonEvents.h---"
|
|
|
|
input = ["CarbonEvents.h"]
|
|
|
|
output = "CarbonEventsgen.py"
|
|
|
|
defsoutput = TOOLBOXDIR + "CarbonEvents.py"
|
|
|
|
scanner = CarbonEvents_Scanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
2002-08-15 18:48:16 -03:00
|
|
|
print "=== Testing definitions output code ==="
|
|
|
|
execfile(defsoutput, {}, {})
|
2001-11-05 10:44:23 -04:00
|
|
|
print "--done scanning, importing--"
|
2001-11-05 12:15:45 -04:00
|
|
|
import CarbonEvtsupport
|
2001-11-05 10:44:23 -04:00
|
|
|
print "done"
|
|
|
|
|
|
|
|
RefObjectTypes = ["EventRef",
|
|
|
|
"EventQueueRef",
|
|
|
|
"EventLoopRef",
|
|
|
|
"EventLoopTimerRef",
|
|
|
|
"EventHandlerRef",
|
|
|
|
"EventHandlerCallRef",
|
|
|
|
"EventTargetRef",
|
|
|
|
"EventHotKeyRef",
|
|
|
|
]
|
|
|
|
|
2001-12-12 16:48:53 -04:00
|
|
|
class CarbonEvents_Scanner(Scanner_OSX):
|
2001-11-05 10:44:23 -04: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":
|
2001-12-14 19:16:04 -04:00
|
|
|
if t == "EventHandlerRef":
|
|
|
|
classname = "EventHandlerRefMethod"
|
|
|
|
else:
|
|
|
|
classname = "CarbonEventsMethod"
|
2001-11-05 10:44:23 -04:00
|
|
|
listname = t + "methods"
|
2001-12-14 19:16:04 -04:00
|
|
|
#else:
|
|
|
|
# print "not method"
|
2001-11-05 10:44:23 -04:00
|
|
|
return classname, listname
|
|
|
|
|
2001-12-12 16:48:53 -04: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
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
2001-12-12 16:48:53 -04:00
|
|
|
"sHandler",
|
2001-11-05 10:44:23 -04:00
|
|
|
"MacCreateEvent",
|
2002-01-08 07:49:31 -04:00
|
|
|
# "TrackMouseLocationWithOptions",
|
|
|
|
# "TrackMouseLocation",
|
|
|
|
# "TrackMouseRegion",
|
2001-11-05 10:44:23 -04:00
|
|
|
"RegisterToolboxObjectClass",
|
|
|
|
"UnregisterToolboxObjectClass",
|
|
|
|
"ProcessHICommand",
|
|
|
|
"GetCFRunLoopFromEventLoop",
|
|
|
|
|
|
|
|
"InvokeEventHandlerUPP",
|
|
|
|
"InvokeEventComparatorUPP",
|
|
|
|
"InvokeEventLoopTimerUPP",
|
2001-12-12 16:48:53 -04:00
|
|
|
"NewEventComparatorUPP",
|
|
|
|
"NewEventLoopTimerUPP",
|
|
|
|
"NewEventHandlerUPP",
|
|
|
|
"DisposeEventComparatorUPP",
|
|
|
|
"DisposeEventLoopTimerUPP",
|
|
|
|
"DisposeEventHandlerUPP",
|
2001-11-05 10:44:23 -04:00
|
|
|
|
|
|
|
# Wrote by hand
|
|
|
|
"InstallEventHandler",
|
2001-12-14 19:16:04 -04:00
|
|
|
"RemoveEventHandler",
|
2001-11-05 10:44:23 -04: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",
|
|
|
|
# ]
|
2001-11-05 12:15:45 -04:00
|
|
|
|
|
|
|
def makerepairinstructions(self):
|
2002-01-03 16:45:47 -04:00
|
|
|
return [
|
|
|
|
([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
|
2002-01-09 14:54:16 -04:00
|
|
|
[("MyInBuffer", 'inDataPtr', "InMode")]),
|
|
|
|
([("Boolean", 'ioWasInRgn', "OutMode")],
|
|
|
|
[("Boolean", 'ioWasInRgn', "InOutMode")]),
|
2002-01-03 16:45:47 -04:00
|
|
|
]
|
2002-01-09 14:54:16 -04:00
|
|
|
|
2001-11-05 10:44:23 -04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|