| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | # Scan an Apple header file, generating a Python file of generator calls. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 14:07:56 +00:00
										 |  |  | import sys | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') | 
					
						
							|  |  |  | sys.path.append(BGENDIR) | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | from scantools import Scanner | 
					
						
							| 
									
										
										
										
											1996-04-12 16:29:23 +00:00
										 |  |  | from bgenlocations import TOOLBOXDIR | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | LONG = "Events" | 
					
						
							|  |  |  | SHORT = "evt" | 
					
						
							|  |  |  | OBJECT = "NOTUSED" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							|  |  |  | 	input = LONG + ".h" | 
					
						
							|  |  |  | 	output = SHORT + "gen.py" | 
					
						
							| 
									
										
										
										
											1996-04-12 16:29:23 +00:00
										 |  |  | 	defsoutput = TOOLBOXDIR + LONG + ".py" | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 	scanner = MyScanner(input, output, defsoutput) | 
					
						
							|  |  |  | 	scanner.scan() | 
					
						
							|  |  |  | 	scanner.close() | 
					
						
							|  |  |  | 	print "=== Done scanning and generating, now importing the generated code... ===" | 
					
						
							|  |  |  | 	exec "import " + SHORT + "support" | 
					
						
							|  |  |  | 	print "=== Done.  It's up to you to compile it now! ===" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyScanner(Scanner): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	def destination(self, type, name, arglist): | 
					
						
							|  |  |  | 		classname = "Function" | 
					
						
							|  |  |  | 		listname = "functions" | 
					
						
							|  |  |  | 		if arglist: | 
					
						
							|  |  |  | 			t, n, m = arglist[0] | 
					
						
							|  |  |  | 			# This is non-functional today | 
					
						
							|  |  |  | 			if t == OBJECT and m == "InMode": | 
					
						
							|  |  |  | 				classname = "Method" | 
					
						
							|  |  |  | 				listname = "methods" | 
					
						
							|  |  |  | 		return classname, listname | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-20 07:42:23 +00:00
										 |  |  | 	def makegreylist(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							| 
									
										
										
										
											2000-07-14 22:37:27 +00:00
										 |  |  | 			('#if !TARGET_API_MAC_CARBON', [ | 
					
						
							| 
									
										
										
										
											2000-06-20 07:42:23 +00:00
										 |  |  | 				'SystemEvent', | 
					
						
							|  |  |  | 				'SystemTask', | 
					
						
							|  |  |  | 				'SystemClick', | 
					
						
							|  |  |  | 				'GetOSEvent', | 
					
						
							|  |  |  | 				'OSEventAvail', | 
					
						
							| 
									
										
										
										
											2000-12-10 23:43:49 +00:00
										 |  |  | 			]), | 
					
						
							|  |  |  | 			('#if TARGET_API_MAC_CARBON', [ | 
					
						
							|  |  |  | 				'CheckEventQueueForUserCancel', | 
					
						
							|  |  |  | 				'GetCurrentKeyModifiers', | 
					
						
							|  |  |  | 				'GetGlobalMouse', | 
					
						
							| 
									
										
										
										
											2000-06-20 07:42:23 +00:00
										 |  |  | 			])] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 	def makeblacklistnames(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							| 
									
										
										
										
											1995-06-09 20:56:31 +00:00
										 |  |  | 			"KeyTranslate", | 
					
						
							|  |  |  | 			"GetEventMask",		# I cannot seem to find this routine... | 
					
						
							| 
									
										
										
										
											1999-12-14 15:47:01 +00:00
										 |  |  | 			"WaitNextEvent",	# Manually generated because of optional region | 
					
						
							|  |  |  | 			# Constants with funny definitions | 
					
						
							|  |  |  | 			"osEvtMessageMask", | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	def makeblacklisttypes(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			"EvQElPtr", "QHdrPtr" | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	def makerepairinstructions(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							|  |  |  | 			([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], | 
					
						
							|  |  |  | 			 [("InBuffer", "*", "*")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("void", "*", "OutMode"), ("long", "*", "InMode"), | 
					
						
							|  |  |  | 			                            ("long", "*", "OutMode")], | 
					
						
							|  |  |  | 			 [("VarVarOutBuffer", "*", "InOutMode")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("void", "wStorage", "OutMode")], | 
					
						
							|  |  |  | 			 [("NullStorage", "*", "InMode")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			# GetKeys | 
					
						
							|  |  |  | 			([('KeyMap', 'theKeys', 'InMode')], | 
					
						
							|  |  |  | 			 [('*', '*', 'OutMode')]), | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			  | 
					
						
							|  |  |  | 			# GetTicker | 
					
						
							|  |  |  | 			([('unsigned long', '*', '*')], | 
					
						
							|  |  |  | 			 [('unsigned_long', '*', '*')]), | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			 | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | if __name__ == "__main__": | 
					
						
							|  |  |  | 	main() |