| 
									
										
										
										
											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) | 
					
						
							| 
									
										
										
										
											1996-04-12 16:29:23 +00:00
										 |  |  | from bgenlocations import TOOLBOXDIR | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | from scantools import Scanner | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											1998-02-20 16:02:09 +00:00
										 |  |  | 	input = "MacWindows.h" | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 	output = "wingen.py" | 
					
						
							| 
									
										
										
										
											1996-04-12 16:29:23 +00:00
										 |  |  | 	defsoutput = TOOLBOXDIR + "Windows.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... ===" | 
					
						
							|  |  |  | 	import winsupport | 
					
						
							|  |  |  | 	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] | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode": | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 				classname = "Method" | 
					
						
							|  |  |  | 				listname = "methods" | 
					
						
							|  |  |  | 		return classname, listname | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-02-20 16:02:09 +00:00
										 |  |  | 	def writeinitialdefs(self): | 
					
						
							|  |  |  | 		self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 	def makeblacklistnames(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							|  |  |  | 			'DisposeWindow', # Implied when the object is deleted | 
					
						
							|  |  |  | 			'CloseWindow', | 
					
						
							| 
									
										
										
										
											1999-12-12 21:41:51 +00:00
										 |  |  | 			'SetWindowProperty',	# For the moment | 
					
						
							|  |  |  | 			'GetWindowProperty', | 
					
						
							|  |  |  | 			'GetWindowPropertySize', | 
					
						
							|  |  |  | 			'RemoveWindowProperty', | 
					
						
							| 
									
										
										
										
											2000-06-02 21:35:07 +00:00
										 |  |  | 			'MacCloseWindow', | 
					
						
							| 
									
										
										
										
											1999-12-14 15:47:01 +00:00
										 |  |  | 			# Constants with funny definitions | 
					
						
							|  |  |  | 			'kMouseUpOutOfSlop', | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							| 
									
										
										
										
											2000-06-02 21:35:07 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 	def makegreylist(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							| 
									
										
										
										
											2000-07-14 22:37:27 +00:00
										 |  |  | 			('#if !TARGET_API_MAC_CARBON', [ | 
					
						
							| 
									
										
										
										
											2000-06-02 21:35:07 +00:00
										 |  |  | 				'GetAuxWin', | 
					
						
							|  |  |  | 				'GetWindowDataHandle', | 
					
						
							|  |  |  | 				'SaveOld', | 
					
						
							|  |  |  | 				'DrawNew', | 
					
						
							|  |  |  | 				'SetWinColor', | 
					
						
							|  |  |  | 				'SetDeskCPat', | 
					
						
							|  |  |  | 				'InitWindows', | 
					
						
							|  |  |  | 				'InitFloatingWindows', | 
					
						
							|  |  |  | 				'GetWMgrPort', | 
					
						
							|  |  |  | 				'GetCWMgrPort', | 
					
						
							|  |  |  | 				'ValidRgn',		# Use versions with Window in their name | 
					
						
							|  |  |  | 				'ValidRect', | 
					
						
							|  |  |  | 				'InvalRgn', | 
					
						
							|  |  |  | 				'InvalRect', | 
					
						
							| 
									
										
										
										
											2000-06-21 22:07:06 +00:00
										 |  |  | 				'IsValidWindowPtr', # I think this is useless for Python, but not sure... | 
					
						
							| 
									
										
										
										
											2000-06-02 21:35:07 +00:00
										 |  |  | 			])] | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 	def makeblacklisttypes(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							|  |  |  | 			'ProcPtr', | 
					
						
							| 
									
										
										
										
											1995-11-15 15:18:47 +00:00
										 |  |  | 			'DragGrayRgnUPP', | 
					
						
							| 
									
										
										
										
											1999-12-12 21:41:51 +00:00
										 |  |  | 			'Collection',		# For now, to be done later | 
					
						
							|  |  |  | 			'DragReference',	# Ditto, dragmodule doesn't export it yet. | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	def makerepairinstructions(self): | 
					
						
							|  |  |  | 		return [ | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			# GetWTitle | 
					
						
							|  |  |  | 			([("Str255", "*", "InMode")], | 
					
						
							|  |  |  | 			 [("*", "*", "OutMode")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], | 
					
						
							|  |  |  | 			 [("InBuffer", "*", "*")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("void", "*", "OutMode"), ("long", "*", "InMode"), | 
					
						
							|  |  |  | 			                            ("long", "*", "OutMode")], | 
					
						
							|  |  |  | 			 [("VarVarOutBuffer", "*", "InOutMode")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("void", "wStorage", "OutMode")], | 
					
						
							|  |  |  | 			 [("NullStorage", "*", "InMode")]), | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			([("WindowPtr", "*", "OutMode")], | 
					
						
							|  |  |  | 			 [("ExistingWindowPtr", "*", "*")]), | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			([("WindowRef", "*", "OutMode")],	# Same, but other style headerfiles | 
					
						
							|  |  |  | 			 [("ExistingWindowPtr", "*", "*")]), | 
					
						
							| 
									
										
										
										
											1995-02-28 09:49:02 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			([("WindowPtr", "FrontWindow", "ReturnMode")], | 
					
						
							|  |  |  | 			 [("ExistingWindowPtr", "*", "*")]), | 
					
						
							| 
									
										
										
										
											1995-06-06 13:08:40 +00:00
										 |  |  | 			([("WindowRef", "FrontWindow", "ReturnMode")],	# Ditto | 
					
						
							|  |  |  | 			 [("ExistingWindowPtr", "*", "*")]), | 
					
						
							| 
									
										
										
										
											1995-01-30 11:53:55 +00:00
										 |  |  | 			] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == "__main__": | 
					
						
							|  |  |  | 	main() | 
					
						
							| 
									
										
										
										
											1995-02-28 09:49:02 +00:00
										 |  |  | 
 |