[Python-checkins] python/dist/src/Mac/Modules/ae aescan.py, 1.16, 1.17 aesupport.py, 1.33, 1.34

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Sun Jul 18 07:58:40 CEST 2004


Update of /cvsroot/python/python/dist/src/Mac/Modules/ae
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Modules/ae
Modified Files:
	aescan.py aesupport.py 
Log Message:
Whitespace normalization, via reindent.py.
Index: aescan.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aescan.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** aescan.py	12 Dec 2002 10:31:50 -0000	1.16
--- aescan.py	18 Jul 2004 05:58:07 -0000	1.17
***************
*** 14,99 ****
 
 def main():
! 	print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
! 	input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
! 	output = "aegen.py"
! 	defsoutput = TOOLBOXDIR + "AppleEvents.py"
! 	scanner = AppleEventsScanner(input, output, defsoutput)
! 	scanner.scan()
! 	scanner.close()
! 	print "=== Testing definitions output code ==="
! 	execfile(defsoutput, {}, {})
! 	print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
! 	import aesupport
! 	print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
 
 class AppleEventsScanner(Scanner):
 
! 	def destination(self, type, name, arglist):
! 		classname = "AEFunction"
! 		listname = "functions"
! 		if arglist:
! 			t, n, m = arglist[0]
! 			if t[-4:] == "_ptr" and m == "InMode" and \
! 			 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
! 			 "AERecord", "AppleEvent"):
! 				classname = "AEMethod"
! 				listname = "aedescmethods"
! 		return classname, listname
 
! 	def makeblacklistnames(self):
! 		return [
! 			"AEDisposeDesc",
! #			"AEGetEventHandler",
! 			"AEGetDescData", # Use object.data
! 			"AEGetSpecialHandler",
! 			# Constants with funny definitions
! 			"kAEDontDisposeOnResume",
! 			"kAEUseStandardDispatch",
! 			]
 
! 	def makeblacklisttypes(self):
! 		return [
! 			"ProcPtr",
! 			"AEArrayType",
! 			"AECoercionHandlerUPP",
! 			"UniversalProcPtr",
! 			"OSLCompareUPP",
! 			"OSLAccessorUPP",
! 			]
 
! 	def makerepairinstructions(self):
! 		return [
! 			([("Boolean", "isSysHandler", "InMode")],
! 			 [("AlwaysFalse", "*", "*")]),
! 			
! 			([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
! 			 [("InBuffer", "*", "*")]),
! 			
! 			([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
! 			 [("EventHandler", "*", "*")]),
! 			
! 			([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
! 			 [("EventHandler", "*", "*")]),
! 			
! 			([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
! 			 [("EventHandler", "*", "*")]),
! 			
! 			([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
! 			 [("EventHandler", "*", "*")]),
! 			
! 			([("void", "*", "OutMode"), ("Size", "*", "InMode"),
! 			 ("Size", "*", "OutMode")],
! 			 [("VarVarOutBuffer", "*", "InOutMode")]),
! 			 
! 			([("AppleEvent", "theAppleEvent", "OutMode")],
! 			 [("AppleEvent_ptr", "*", "InMode")]),
! 			 
! 			([("AEDescList", "theAEDescList", "OutMode")],
! 			 [("AEDescList_ptr", "*", "InMode")]),
! 			]
 
! 	def writeinitialdefs(self):
! 		self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
 
 if __name__ == "__main__":
! 	main()
--- 14,99 ----
 
 def main():
! print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
! input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
! output = "aegen.py"
! defsoutput = TOOLBOXDIR + "AppleEvents.py"
! scanner = AppleEventsScanner(input, output, defsoutput)
! scanner.scan()
! scanner.close()
! print "=== Testing definitions output code ==="
! execfile(defsoutput, {}, {})
! print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
! import aesupport
! print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
 
 class AppleEventsScanner(Scanner):
 
! def destination(self, type, name, arglist):
! classname = "AEFunction"
! listname = "functions"
! if arglist:
! t, n, m = arglist[0]
! if t[-4:] == "_ptr" and m == "InMode" and \
! t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
! "AERecord", "AppleEvent"):
! classname = "AEMethod"
! listname = "aedescmethods"
! return classname, listname
 
! def makeblacklistnames(self):
! return [
! "AEDisposeDesc",
! # "AEGetEventHandler",
! "AEGetDescData", # Use object.data
! "AEGetSpecialHandler",
! # Constants with funny definitions
! "kAEDontDisposeOnResume",
! "kAEUseStandardDispatch",
! ]
 
! def makeblacklisttypes(self):
! return [
! "ProcPtr",
! "AEArrayType",
! "AECoercionHandlerUPP",
! "UniversalProcPtr",
! "OSLCompareUPP",
! "OSLAccessorUPP",
! ]
 
! def makerepairinstructions(self):
! return [
! ([("Boolean", "isSysHandler", "InMode")],
! [("AlwaysFalse", "*", "*")]),
 
! ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
! [("InBuffer", "*", "*")]),
! 
! ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
! [("EventHandler", "*", "*")]),
! 
! ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
! [("EventHandler", "*", "*")]),
! 
! ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
! [("EventHandler", "*", "*")]),
! 
! ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
! [("EventHandler", "*", "*")]),
! 
! ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
! ("Size", "*", "OutMode")],
! [("VarVarOutBuffer", "*", "InOutMode")]),
! 
! ([("AppleEvent", "theAppleEvent", "OutMode")],
! [("AppleEvent_ptr", "*", "InMode")]),
! 
! ([("AEDescList", "theAEDescList", "OutMode")],
! [("AEDescList_ptr", "*", "InMode")]),
! ]
! 
! def writeinitialdefs(self):
! self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
 
 if __name__ == "__main__":
! main()
Index: aesupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** aesupport.py	19 Nov 2003 16:34:03 -0000	1.33
--- aesupport.py	18 Jul 2004 05:58:07 -0000	1.34
***************
*** 40,66 ****
 
 class EHType(Type):
! 	def __init__(self, name = 'EventHandler', format = ''):
! 		Type.__init__(self, name, format)
! 	def declare(self, name):
! 		Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name)
! 		Output("PyObject *%s;", name)
! 	def getargsFormat(self):
! 		return "O"
! 	def getargsArgs(self, name):
! 		return "&%s" % name
! 	def passInput(self, name):
! 		return "%s__proc__, (long)%s" % (name, name)
! 	def passOutput(self, name):
! 		return "&%s__proc__, (long *)&%s" % (name, name)
! 	def mkvalueFormat(self):
! 		return "O"
! 	def mkvalueArgs(self, name):
! 		return name
! 	def cleanup(self, name):
! 		Output("Py_INCREF(%s); /* XXX leak, but needed */", name)
 
 class EHNoRefConType(EHType):
! 	def passInput(self, name):
! 		return "upp_GenericEventHandler"
 
 EventHandler = EHType()
--- 40,66 ----
 
 class EHType(Type):
! def __init__(self, name = 'EventHandler', format = ''):
! Type.__init__(self, name, format)
! def declare(self, name):
! Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name)
! Output("PyObject *%s;", name)
! def getargsFormat(self):
! return "O"
! def getargsArgs(self, name):
! return "&%s" % name
! def passInput(self, name):
! return "%s__proc__, (long)%s" % (name, name)
! def passOutput(self, name):
! return "&%s__proc__, (long *)&%s" % (name, name)
! def mkvalueFormat(self):
! return "O"
! def mkvalueArgs(self, name):
! return name
! def cleanup(self, name):
! Output("Py_INCREF(%s); /* XXX leak, but needed */", name)
 
 class EHNoRefConType(EHType):
! def passInput(self, name):
! return "upp_GenericEventHandler"
 
 EventHandler = EHType()
***************
*** 102,108 ****
 static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn)
 {
! 	if ( PyOS_InterruptOccurred() )
! 		return 1;
! 	return 0;
 }
 
--- 102,108 ----
 static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn)
 {
! if ( PyOS_InterruptOccurred() )
! return 1;
! return 0;
 }
 
***************
*** 114,155 ****
 GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon)
 {
! 	PyObject *handler = (PyObject *)refcon;
! 	AEDescObject *requestObject, *replyObject;
! 	PyObject *args, *res;
! 	if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) {
! 		return -1;
! 	}
! 	if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) {
! 		Py_DECREF(requestObject);
! 		return -1;
! 	}
! 	if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) {
! 		Py_DECREF(requestObject);
! 		Py_DECREF(replyObject);
! 		return -1;
! 	}
! 	res = PyEval_CallObject(handler, args);
! 	requestObject->ob_itself.descriptorType = 'null';
! 	requestObject->ob_itself.dataHandle = NULL;
! 	replyObject->ob_itself.descriptorType = 'null';
! 	replyObject->ob_itself.dataHandle = NULL;
! 	Py_DECREF(args);
! 	if (res == NULL) {
! 		PySys_WriteStderr("Exception in AE event handler function\\n");
! 		PyErr_Print();
! 		return -1;
! 	}
! 	Py_DECREF(res);
! 	return noErr;
 }
 
 PyObject *AEDesc_NewBorrowed(AEDesc *itself)
 {
! 	PyObject *it;
! 	
! 	it = AEDesc_New(itself);
! 	if (it)
! 		((AEDescObject *)it)->ob_owned = 0;
! 	return (PyObject *)it;
 }
 
--- 114,155 ----
 GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon)
 {
! PyObject *handler = (PyObject *)refcon;
! AEDescObject *requestObject, *replyObject;
! PyObject *args, *res;
! if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) {
! return -1;
! }
! if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) {
! Py_DECREF(requestObject);
! return -1;
! }
! if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) {
! Py_DECREF(requestObject);
! Py_DECREF(replyObject);
! return -1;
! }
! res = PyEval_CallObject(handler, args);
! requestObject->ob_itself.descriptorType = 'null';
! requestObject->ob_itself.dataHandle = NULL;
! replyObject->ob_itself.descriptorType = 'null';
! replyObject->ob_itself.dataHandle = NULL;
! Py_DECREF(args);
! if (res == NULL) {
! PySys_WriteStderr("Exception in AE event handler function\\n");
! PyErr_Print();
! return -1;
! }
! Py_DECREF(res);
! return noErr;
 }
 
 PyObject *AEDesc_NewBorrowed(AEDesc *itself)
 {
! PyObject *it;
! 
! it = AEDesc_New(itself);
! if (it)
! ((AEDescObject *)it)->ob_owned = 0;
! return (PyObject *)it;
 }
 
***************
*** 157,165 ****
 
 initstuff = initstuff + """
! 	upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
! 	upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
! 	PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
! 	PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
! 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
 """
 
--- 157,165 ----
 
 initstuff = initstuff + """
! upp_AEIdleProc = NewAEIdleUPP(AEIdleProc);
! upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler);
! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New);
! PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed);
! PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert);
 """
 
***************
*** 167,210 ****
 
 class AEDescDefinition(PEP253Mixin, GlobalObjectDefinition):
! 	getsetlist = [(
! 		'type',
! 		'return PyMac_BuildOSType(self->ob_itself.descriptorType);',
! 		None,
! 		'Type of this AEDesc'
! 		), (
! 		'data',
! 		"""
! 		PyObject *res;
! 		Size size;
! 		char *ptr;
! 		OSErr err;
! 		
! 		size = AEGetDescDataSize(&self->ob_itself);
! 		if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
! 			return NULL;
! 		if ( (ptr = PyString_AsString(res)) == NULL )
! 			return NULL;
! 		if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
! 			return PyMac_Error(err);	
! 		return res;
! 		""",
! 		None,
! 		'The raw data in this AEDesc'
! 		)]
 
! 	def __init__(self, name, prefix = None, itselftype = None):
! 		GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name)
! 		self.argref = "*"
 
! 	def outputStructMembers(self):
! 		GlobalObjectDefinition.outputStructMembers(self)
! 		Output("int ob_owned;")
! 		
! 	def outputInitStructMembers(self):
! 		GlobalObjectDefinition.outputInitStructMembers(self)
! 		Output("it->ob_owned = 1;")
! 		
! 	def outputCleanupStructMembers(self):
! 		Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);")
 
 aedescobject = AEDescDefinition('AEDesc')
--- 167,210 ----
 
 class AEDescDefinition(PEP253Mixin, GlobalObjectDefinition):
! getsetlist = [(
! 'type',
! 'return PyMac_BuildOSType(self->ob_itself.descriptorType);',
! None,
! 'Type of this AEDesc'
! ), (
! 'data',
! """
! PyObject *res;
! Size size;
! char *ptr;
! OSErr err;
 
! size = AEGetDescDataSize(&self->ob_itself);
! if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
! return NULL;
! if ( (ptr = PyString_AsString(res)) == NULL )
! return NULL;
! if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
! return PyMac_Error(err);
! return res;
! """,
! None,
! 'The raw data in this AEDesc'
! )]
 
! def __init__(self, name, prefix = None, itselftype = None):
! GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name)
! self.argref = "*"
! 
! def outputStructMembers(self):
! GlobalObjectDefinition.outputStructMembers(self)
! Output("int ob_owned;")
! 
! def outputInitStructMembers(self):
! GlobalObjectDefinition.outputInitStructMembers(self)
! Output("it->ob_owned = 1;")
! 
! def outputCleanupStructMembers(self):
! Output("if (self->ob_owned) AEDisposeDesc(&self->ob_itself);")
 
 aedescobject = AEDescDefinition('AEDesc')


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /