blob: 856f9b10c397613f2344efbbd7e24997b46ddf8f [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]
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 Rossumf8d64732001-12-12 20:48:53 +000053 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 Jansen52e90452001-11-05 14:44:23 +000061 def makeblacklistnames(self):
62 return [
Just van Rossumf8d64732001-12-12 20:48:53 +000063 "sHandler",
Jack Jansen52e90452001-11-05 14:44:23 +000064 "MacCreateEvent",
65 "TrackMouseLocationWithOptions",
66 "TrackMouseLocation",
67 "TrackMouseRegion",
68 "RegisterToolboxObjectClass",
69 "UnregisterToolboxObjectClass",
70 "ProcessHICommand",
71 "GetCFRunLoopFromEventLoop",
72
73 "InvokeEventHandlerUPP",
74 "InvokeEventComparatorUPP",
75 "InvokeEventLoopTimerUPP",
Just van Rossumf8d64732001-12-12 20:48:53 +000076 "NewEventComparatorUPP",
77 "NewEventLoopTimerUPP",
78 "NewEventHandlerUPP",
79 "DisposeEventComparatorUPP",
80 "DisposeEventLoopTimerUPP",
81 "DisposeEventHandlerUPP",
Jack Jansen52e90452001-11-05 14:44:23 +000082
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 Jansen34cbe712001-11-05 16:15:45 +0000106
107 def makerepairinstructions(self):
108 return []
109
Jack Jansen52e90452001-11-05 14:44:23 +0000110if __name__ == "__main__":
111 main()