blob: 37faa5467bb6d321396c6c1423179d977f946807 [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 Jansen34cbe712001-11-05 16:15:45 +00009BGENDIR= os.path.join(sys.prefix, ':Tools:bgen:bgen:')
Jack Jansen52e90452001-11-05 14:44:23 +000010sys.path.append(BGENDIR)
11
12from bgenlocations import TOOLBOXDIR
13
14from scantools import Scanner, Scanner_OSX
15
16def 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 Jansen34cbe712001-11-05 16:15:45 +000025 import CarbonEvtsupport
Jack Jansen52e90452001-11-05 14:44:23 +000026 print "done"
27
28RefObjectTypes = ["EventRef",
29 "EventQueueRef",
30 "EventLoopRef",
31 "EventLoopTimerRef",
32 "EventHandlerRef",
33 "EventHandlerCallRef",
34 "EventTargetRef",
35 "EventHotKeyRef",
36 ]
37
Just van Rossumf8d64732001-12-12 20:48:53 +000038class CarbonEvents_Scanner(Scanner_OSX):
Jack Jansen52e90452001-11-05 14:44:23 +000039 def destination(self, type, name, arglist):
40 classname = "CarbonEventsFunction"
41 listname = "functions"
42 if arglist:
43 t, n, m = arglist[0]
Jack Jansen52e90452001-11-05 14:44:23 +000044 if t in RefObjectTypes and m == "InMode":
Just van Rossum2c391152001-12-14 23:16:04 +000045 if t == "EventHandlerRef":
46 classname = "EventHandlerRefMethod"
47 else:
48 classname = "CarbonEventsMethod"
Jack Jansen52e90452001-11-05 14:44:23 +000049 listname = t + "methods"
Just van Rossum2c391152001-12-14 23:16:04 +000050 #else:
51 # print "not method"
Jack Jansen52e90452001-11-05 14:44:23 +000052 return classname, listname
53
Just van Rossumf8d64732001-12-12 20:48:53 +000054 def writeinitialdefs(self):
55 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
56 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
57 self.defsfile.write("false = 0\n")
58 self.defsfile.write("true = 1\n")
59 self.defsfile.write("keyAEEventClass = FOUR_CHAR_CODE('evcl')\n")
60 self.defsfile.write("keyAEEventID = FOUR_CHAR_CODE('evti')\n")
61
Jack Jansen52e90452001-11-05 14:44:23 +000062 def makeblacklistnames(self):
63 return [
Just van Rossumf8d64732001-12-12 20:48:53 +000064 "sHandler",
Jack Jansen52e90452001-11-05 14:44:23 +000065 "MacCreateEvent",
66 "TrackMouseLocationWithOptions",
67 "TrackMouseLocation",
68 "TrackMouseRegion",
69 "RegisterToolboxObjectClass",
70 "UnregisterToolboxObjectClass",
71 "ProcessHICommand",
72 "GetCFRunLoopFromEventLoop",
73
74 "InvokeEventHandlerUPP",
75 "InvokeEventComparatorUPP",
76 "InvokeEventLoopTimerUPP",
Just van Rossumf8d64732001-12-12 20:48:53 +000077 "NewEventComparatorUPP",
78 "NewEventLoopTimerUPP",
79 "NewEventHandlerUPP",
80 "DisposeEventComparatorUPP",
81 "DisposeEventLoopTimerUPP",
82 "DisposeEventHandlerUPP",
Jack Jansen52e90452001-11-05 14:44:23 +000083
84 # Wrote by hand
85 "InstallEventHandler",
Just van Rossum2c391152001-12-14 23:16:04 +000086 "RemoveEventHandler",
Jack Jansen52e90452001-11-05 14:44:23 +000087 "RunApplicationEventLoop",
88
89 # Write by hand?
90 "GetEventParameter",
91 "FlushSpecificEventsFromQueue",
92 "FindSpecificEventInQueue",
93 "InstallEventLoopTimer",
94
95 # Don't do these because they require a CFRelease
96 "CreateTypeStringWithOSType",
97 "CopyEvent",
98 ]
99
100# def makeblacklisttypes(self):
101# return ["EventComparatorUPP",
102# "EventLoopTimerUPP",
103# #"EventHandlerUPP",
104# "EventComparatorProcPtr",
105# "EventLoopTimerProcPtr",
106# "EventHandlerProcPtr",
107# ]
Jack Jansen34cbe712001-11-05 16:15:45 +0000108
109 def makerepairinstructions(self):
Just van Rossum43c2de232002-01-03 20:45:47 +0000110 return [
111 ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")],
112 [("MyInBuffer", 'inDataPtr', "InMode")])
113 ]
Jack Jansen34cbe712001-11-05 16:15:45 +0000114
Jack Jansen52e90452001-11-05 14:44:23 +0000115if __name__ == "__main__":
116 main()