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