blob: 467b8a848af7bca2299092cc0649131c16bbadb6 [file] [log] [blame]
Jack Jansen52e90452001-11-05 14:44:23 +00001# IBCarbonscan.py
2
3import sys
4import os
5import string
6import MacOS
Jack Jansen34cbe712001-11-05 16:15:45 +00007import sys
Jack Jansen52e90452001-11-05 14:44:23 +00008
Jack Jansenaaebdd62002-08-05 15:39:30 +00009from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen52e90452001-11-05 14:44:23 +000010sys.path.append(BGENDIR)
11
Jack Jansen52e90452001-11-05 14:44:23 +000012from scantools import Scanner, Scanner_OSX
13
14def main():
15 print "---Scanning CarbonEvents.h---"
16 input = ["CarbonEvents.h"]
17 output = "CarbonEventsgen.py"
18 defsoutput = TOOLBOXDIR + "CarbonEvents.py"
19 scanner = CarbonEvents_Scanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
22 print "--done scanning, importing--"
Jack Jansen34cbe712001-11-05 16:15:45 +000023 import CarbonEvtsupport
Jack Jansen52e90452001-11-05 14:44:23 +000024 print "done"
25
26RefObjectTypes = ["EventRef",
27 "EventQueueRef",
28 "EventLoopRef",
29 "EventLoopTimerRef",
30 "EventHandlerRef",
31 "EventHandlerCallRef",
32 "EventTargetRef",
33 "EventHotKeyRef",
34 ]
35
Just van Rossumf8d64732001-12-12 20:48:53 +000036class CarbonEvents_Scanner(Scanner_OSX):
Jack Jansen52e90452001-11-05 14:44:23 +000037 def destination(self, type, name, arglist):
38 classname = "CarbonEventsFunction"
39 listname = "functions"
40 if arglist:
41 t, n, m = arglist[0]
Jack Jansen52e90452001-11-05 14:44:23 +000042 if t in RefObjectTypes and m == "InMode":
Just van Rossum2c391152001-12-14 23:16:04 +000043 if t == "EventHandlerRef":
44 classname = "EventHandlerRefMethod"
45 else:
46 classname = "CarbonEventsMethod"
Jack Jansen52e90452001-11-05 14:44:23 +000047 listname = t + "methods"
Just van Rossum2c391152001-12-14 23:16:04 +000048 #else:
49 # print "not method"
Jack Jansen52e90452001-11-05 14:44:23 +000050 return classname, listname
51
Just van Rossumf8d64732001-12-12 20:48:53 +000052 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
Jack Jansen52e90452001-11-05 14:44:23 +000060 def makeblacklistnames(self):
61 return [
Just van Rossumf8d64732001-12-12 20:48:53 +000062 "sHandler",
Jack Jansen52e90452001-11-05 14:44:23 +000063 "MacCreateEvent",
Just van Rossumec0107f2002-01-08 11:49:31 +000064# "TrackMouseLocationWithOptions",
65# "TrackMouseLocation",
66# "TrackMouseRegion",
Jack Jansen52e90452001-11-05 14:44:23 +000067 "RegisterToolboxObjectClass",
68 "UnregisterToolboxObjectClass",
69 "ProcessHICommand",
70 "GetCFRunLoopFromEventLoop",
71
72 "InvokeEventHandlerUPP",
73 "InvokeEventComparatorUPP",
74 "InvokeEventLoopTimerUPP",
Just van Rossumf8d64732001-12-12 20:48:53 +000075 "NewEventComparatorUPP",
76 "NewEventLoopTimerUPP",
77 "NewEventHandlerUPP",
78 "DisposeEventComparatorUPP",
79 "DisposeEventLoopTimerUPP",
80 "DisposeEventHandlerUPP",
Jack Jansen52e90452001-11-05 14:44:23 +000081
82 # Wrote by hand
83 "InstallEventHandler",
Just van Rossum2c391152001-12-14 23:16:04 +000084 "RemoveEventHandler",
Jack Jansen52e90452001-11-05 14:44:23 +000085 "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 Jansen34cbe712001-11-05 16:15:45 +0000106
107 def makerepairinstructions(self):
Just van Rossum43c2de22002-01-03 20:45:47 +0000108 return [
109 ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
Just van Rossum4b367352002-01-09 18:54:16 +0000110 [("MyInBuffer", 'inDataPtr', "InMode")]),
111 ([("Boolean", 'ioWasInRgn', "OutMode")],
112 [("Boolean", 'ioWasInRgn', "InOutMode")]),
Just van Rossum43c2de22002-01-03 20:45:47 +0000113 ]
Just van Rossum4b367352002-01-09 18:54:16 +0000114
Jack Jansen52e90452001-11-05 14:44:23 +0000115if __name__ == "__main__":
116 main()