| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* =========================== Module _AE =========================== */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | #ifdef _WIN32
 | 
					
						
							|  |  |  | #include "pywintoolbox.h"
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | #include "macglue.h"
 | 
					
						
							|  |  |  | #include "pymactoolbox.h"
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Macro to test whether a weak-loaded CFM function exists */ | 
					
						
							|  |  |  | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
 | 
					
						
							|  |  |  |     	PyErr_SetString(PyExc_NotImplementedError, \ | 
					
						
							|  |  |  |     	"Not available in this shared library/OS version"); \ | 
					
						
							|  |  |  |     	return NULL; \ | 
					
						
							|  |  |  |     }} while(0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | #ifndef PyDoc_STR
 | 
					
						
							|  |  |  | #define PyDoc_STR(x) (x)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | #ifdef WITHOUT_FRAMEWORKS
 | 
					
						
							|  |  |  | #include <AppleEvents.h>
 | 
					
						
							|  |  |  | #include <AEObjects.h>
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #include <Carbon/Carbon.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_TOOLBOX_OBJECT_GLUE
 | 
					
						
							|  |  |  | extern PyObject *_AEDesc_New(AEDesc *); | 
					
						
							|  |  |  | extern int _AEDesc_Convert(PyObject *, AEDesc *); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_New _AEDesc_New
 | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | #define AEDesc_NewBorrowed _AEDesc_NewBorrowed
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | #define AEDesc_Convert _AEDesc_Convert
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | typedef long refcontype; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */ | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | AEEventHandlerUPP upp_GenericEventHandler; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if ( PyOS_InterruptOccurred() ) | 
					
						
							|  |  |  | 		return 1; | 
					
						
							| 
									
										
										
										
											2001-09-01 23:38:50 +00:00
										 |  |  | #if !TARGET_API_MAC_OSX
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if ( PyMac_HandleEvent(theEvent) < 0 ) { | 
					
						
							|  |  |  | 		PySys_WriteStderr("Exception in user event handler during AE processing\n"); | 
					
						
							|  |  |  | 		PyErr_Clear(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2001-09-01 23:38:50 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | AEIdleUPP upp_AEIdleProc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_Error; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ----------------------- Object type AEDesc ----------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyTypeObject AEDesc_Type; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-12-19 21:24:35 +00:00
										 |  |  | #define AEDesc_Check(x) ((x)->ob_type == &AEDesc_Type || PyObject_TypeCheck((x), &AEDesc_Type))
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct AEDescObject { | 
					
						
							|  |  |  | 	PyObject_HEAD | 
					
						
							|  |  |  | 	AEDesc ob_itself; | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | 	int ob_owned; | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | } AEDescObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *AEDesc_New(AEDesc *itself) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	AEDescObject *it; | 
					
						
							|  |  |  | 	it = PyObject_NEW(AEDescObject, &AEDesc_Type); | 
					
						
							|  |  |  | 	if (it == NULL) return NULL; | 
					
						
							|  |  |  | 	it->ob_itself = *itself; | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | 	it->ob_owned = 1; | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	return (PyObject *)it; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2001-09-04 22:19:18 +00:00
										 |  |  | int AEDesc_Convert(PyObject *v, AEDesc *p_itself) | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (!AEDesc_Check(v)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PyErr_SetString(PyExc_TypeError, "AEDesc required"); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	*p_itself = ((AEDescObject *)v)->ob_itself; | 
					
						
							|  |  |  | 	return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void AEDesc_dealloc(AEDescObject *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | 	if (self->ob_owned) AEDisposeDesc(&self->ob_itself); | 
					
						
							| 
									
										
										
										
											2002-12-23 23:16:25 +00:00
										 |  |  | 	self->ob_type->tp_free((PyObject *)self); | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AECoerceDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	DescType toType; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECoerceDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECoerceDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &toType)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AECoerceDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                    toType, | 
					
						
							|  |  |  | 	                    &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEDuplicateDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEDuplicateDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEDuplicateDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEDuplicateDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                       &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AECountItems(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long theCount; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECountItems
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECountItems); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AECountItems(&_self->ob_itself, | 
					
						
							|  |  |  | 	                    &theCount); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("l", | 
					
						
							|  |  |  | 	                     theCount); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutPtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutPtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutPtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "lO&s#", | 
					
						
							|  |  |  | 	                      &index, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEPutPtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                index, | 
					
						
							|  |  |  | 	                typeCode, | 
					
						
							|  |  |  | 	                dataPtr__in__, dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							|  |  |  | 	AEDesc theAEDesc; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "lO&", | 
					
						
							|  |  |  | 	                      &index, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &theAEDesc)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEPutDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                 index, | 
					
						
							|  |  |  | 	                 &theAEDesc); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetNthPtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__out__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetNthPtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetNthPtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "lO&i", | 
					
						
							|  |  |  | 	                      &index, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType, | 
					
						
							|  |  |  | 	                      &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PyErr_NoMemory(); | 
					
						
							|  |  |  | 		goto dataPtr__error__; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEGetNthPtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                   index, | 
					
						
							|  |  |  | 	                   desiredType, | 
					
						
							|  |  |  | 	                   &theAEKeyword, | 
					
						
							|  |  |  | 	                   &typeCode, | 
					
						
							|  |  |  | 	                   dataPtr__out__, dataPtr__len__, &dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&O&s#", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, theAEKeyword, | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataPtr__out__, (int)dataPtr__len__); | 
					
						
							|  |  |  | 	free(dataPtr__out__); | 
					
						
							|  |  |  |  dataPtr__error__: ; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetNthDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetNthDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetNthDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "lO&", | 
					
						
							|  |  |  | 	                      &index, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetNthDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                    index, | 
					
						
							|  |  |  | 	                    desiredType, | 
					
						
							|  |  |  | 	                    &theAEKeyword, | 
					
						
							|  |  |  | 	                    &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&O&", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, theAEKeyword, | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AESizeOfNthItem(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	Size dataSize; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESizeOfNthItem
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESizeOfNthItem); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "l", | 
					
						
							|  |  |  | 	                      &index)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESizeOfNthItem(&_self->ob_itself, | 
					
						
							|  |  |  | 	                       index, | 
					
						
							|  |  |  | 	                       &typeCode, | 
					
						
							|  |  |  | 	                       &dataSize); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&l", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataSize); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEDeleteItem(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long index; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEDeleteItem
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEDeleteItem); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "l", | 
					
						
							|  |  |  | 	                      &index)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEDeleteItem(&_self->ob_itself, | 
					
						
							|  |  |  | 	                    index); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutParamPtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutParamPtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutParamPtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&s#", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEPutParamPtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                     theAEKeyword, | 
					
						
							|  |  |  | 	                     typeCode, | 
					
						
							|  |  |  | 	                     dataPtr__in__, dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutParamDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	AEDesc theAEDesc; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutParamDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutParamDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &theAEDesc)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEPutParamDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                      theAEKeyword, | 
					
						
							|  |  |  | 	                      &theAEDesc); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetParamPtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__out__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetParamPtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetParamPtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&i", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType, | 
					
						
							|  |  |  | 	                      &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PyErr_NoMemory(); | 
					
						
							|  |  |  | 		goto dataPtr__error__; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEGetParamPtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                     theAEKeyword, | 
					
						
							|  |  |  | 	                     desiredType, | 
					
						
							|  |  |  | 	                     &typeCode, | 
					
						
							|  |  |  | 	                     dataPtr__out__, dataPtr__len__, &dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&s#", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataPtr__out__, (int)dataPtr__len__); | 
					
						
							|  |  |  | 	free(dataPtr__out__); | 
					
						
							|  |  |  |  dataPtr__error__: ; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetParamDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetParamDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetParamDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetParamDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                      theAEKeyword, | 
					
						
							|  |  |  | 	                      desiredType, | 
					
						
							|  |  |  | 	                      &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AESizeOfParam(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	Size dataSize; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESizeOfParam
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESizeOfParam); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESizeOfParam(&_self->ob_itself, | 
					
						
							|  |  |  | 	                     theAEKeyword, | 
					
						
							|  |  |  | 	                     &typeCode, | 
					
						
							|  |  |  | 	                     &dataSize); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&l", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataSize); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEDeleteParam(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEDeleteParam
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEDeleteParam); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEDeleteParam(&_self->ob_itself, | 
					
						
							|  |  |  | 	                     theAEKeyword); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetAttributePtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__out__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetAttributePtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetAttributePtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&i", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType, | 
					
						
							|  |  |  | 	                      &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PyErr_NoMemory(); | 
					
						
							|  |  |  | 		goto dataPtr__error__; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEGetAttributePtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                         theAEKeyword, | 
					
						
							|  |  |  | 	                         desiredType, | 
					
						
							|  |  |  | 	                         &typeCode, | 
					
						
							|  |  |  | 	                         dataPtr__out__, dataPtr__len__, &dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&s#", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataPtr__out__, (int)dataPtr__len__); | 
					
						
							|  |  |  | 	free(dataPtr__out__); | 
					
						
							|  |  |  |  dataPtr__error__: ; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetAttributeDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType desiredType; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetAttributeDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetAttributeDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredType)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetAttributeDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                          theAEKeyword, | 
					
						
							|  |  |  | 	                          desiredType, | 
					
						
							|  |  |  | 	                          &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AESizeOfAttribute(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	Size dataSize; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESizeOfAttribute
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESizeOfAttribute); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESizeOfAttribute(&_self->ob_itself, | 
					
						
							|  |  |  | 	                         theAEKeyword, | 
					
						
							|  |  |  | 	                         &typeCode, | 
					
						
							|  |  |  | 	                         &dataSize); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&l", | 
					
						
							|  |  |  | 	                     PyMac_BuildOSType, typeCode, | 
					
						
							|  |  |  | 	                     dataSize); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutAttributePtr(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutAttributePtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutAttributePtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&s#", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEPutAttributePtr(&_self->ob_itself, | 
					
						
							|  |  |  | 	                         theAEKeyword, | 
					
						
							|  |  |  | 	                         typeCode, | 
					
						
							|  |  |  | 	                         dataPtr__in__, dataPtr__len__); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEPutAttributeDesc(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword theAEKeyword; | 
					
						
							|  |  |  | 	AEDesc theAEDesc; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEPutAttributeDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEPutAttributeDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEKeyword, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &theAEDesc)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEPutAttributeDesc(&_self->ob_itself, | 
					
						
							|  |  |  | 	                          theAEKeyword, | 
					
						
							|  |  |  | 	                          &theAEDesc); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetDescDataSize(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	Size _rv; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetDescDataSize
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetDescDataSize); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_rv = AEGetDescDataSize(&_self->ob_itself); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("l", | 
					
						
							|  |  |  | 	                     _rv); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | static PyObject *AEDesc_AESend(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AppleEvent reply; | 
					
						
							|  |  |  | 	AESendMode sendMode; | 
					
						
							|  |  |  | 	AESendPriority sendPriority; | 
					
						
							|  |  |  | 	long timeOutInTicks; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESend
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESend); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "lhl", | 
					
						
							|  |  |  | 	                      &sendMode, | 
					
						
							|  |  |  | 	                      &sendPriority, | 
					
						
							|  |  |  | 	                      &timeOutInTicks)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESend(&_self->ob_itself, | 
					
						
							|  |  |  | 	              &reply, | 
					
						
							|  |  |  | 	              sendMode, | 
					
						
							|  |  |  | 	              sendPriority, | 
					
						
							|  |  |  | 	              timeOutInTicks, | 
					
						
							|  |  |  | 	              upp_AEIdleProc, | 
					
						
							|  |  |  | 	              (AEFilterUPP)0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &reply); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEResetTimer(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEResetTimer
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEResetTimer); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEResetTimer(&_self->ob_itself); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AESuspendTheCurrentEvent(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESuspendTheCurrentEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESuspendTheCurrentEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESuspendTheCurrentEvent(&_self->ob_itself); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEResumeTheCurrentEvent(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AppleEvent reply; | 
					
						
							|  |  |  | 	AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler; | 
					
						
							|  |  |  | 	PyObject *dispatcher; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEResumeTheCurrentEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEResumeTheCurrentEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O", | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &reply, | 
					
						
							|  |  |  | 	                      &dispatcher)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEResumeTheCurrentEvent(&_self->ob_itself, | 
					
						
							|  |  |  | 	                               &reply, | 
					
						
							|  |  |  | 	                               dispatcher__proc__, (long)dispatcher); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	Py_INCREF(dispatcher); /* XXX leak, but needed */ | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AEGetTheCurrentEvent(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetTheCurrentEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetTheCurrentEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetTheCurrentEvent(&_self->ob_itself); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_AESetTheCurrentEvent(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESetTheCurrentEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESetTheCurrentEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESetTheCurrentEvent(&_self->ob_itself); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | static PyObject *AEDesc_AEResolve(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	short callbackFlags; | 
					
						
							|  |  |  | 	AEDesc theToken; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEResolve
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEResolve); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "h", | 
					
						
							|  |  |  | 	                      &callbackFlags)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEResolve(&_self->ob_itself, | 
					
						
							|  |  |  | 	                 callbackFlags, | 
					
						
							|  |  |  | 	                 &theToken); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &theToken); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | static PyObject *AEDesc_AutoDispose(AEDescObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int onoff, old; | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(_args, "i", &onoff)) | 
					
						
							|  |  |  | 	        return NULL; | 
					
						
							|  |  |  | 	old = _self->ob_owned; | 
					
						
							|  |  |  | 	_self->ob_owned = onoff; | 
					
						
							|  |  |  | 	_res = Py_BuildValue("i", old); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | static PyMethodDef AEDesc_methods[] = { | 
					
						
							|  |  |  | 	{"AECoerceDesc", (PyCFunction)AEDesc_AECoerceDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(DescType toType) -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEDuplicateDesc", (PyCFunction)AEDesc_AEDuplicateDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AECountItems", (PyCFunction)AEDesc_AECountItems, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> (long theCount)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutPtr", (PyCFunction)AEDesc_AEPutPtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index, DescType typeCode, Buffer dataPtr) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutDesc", (PyCFunction)AEDesc_AEPutDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index, AEDesc theAEDesc) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetNthPtr", (PyCFunction)AEDesc_AEGetNthPtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index, DescType desiredType, Buffer dataPtr) -> (AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetNthDesc", (PyCFunction)AEDesc_AEGetNthDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index, DescType desiredType) -> (AEKeyword theAEKeyword, AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AESizeOfNthItem", (PyCFunction)AEDesc_AESizeOfNthItem, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index) -> (DescType typeCode, Size dataSize)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEDeleteItem", (PyCFunction)AEDesc_AEDeleteItem, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long index) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutParamPtr", (PyCFunction)AEDesc_AEPutParamPtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutParamDesc", (PyCFunction)AEDesc_AEPutParamDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetParamPtr", (PyCFunction)AEDesc_AEGetParamPtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetParamDesc", (PyCFunction)AEDesc_AEGetParamDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AESizeOfParam", (PyCFunction)AEDesc_AESizeOfParam, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEDeleteParam", (PyCFunction)AEDesc_AEDeleteParam, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetAttributePtr", (PyCFunction)AEDesc_AEGetAttributePtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetAttributeDesc", (PyCFunction)AEDesc_AEGetAttributeDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AESizeOfAttribute", (PyCFunction)AEDesc_AESizeOfAttribute, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutAttributePtr", (PyCFunction)AEDesc_AEPutAttributePtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEPutAttributeDesc", (PyCFunction)AEDesc_AEPutAttributeDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetDescDataSize", (PyCFunction)AEDesc_AEGetDescDataSize, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> (Size _rv)")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AESend", (PyCFunction)AEDesc_AESend, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks) -> (AppleEvent reply)")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEResetTimer", (PyCFunction)AEDesc_AEResetTimer, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEResumeTheCurrentEvent", (PyCFunction)AEDesc_AEResumeTheCurrentEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AppleEvent reply, EventHandler dispatcher) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEGetTheCurrentEvent", (PyCFunction)AEDesc_AEGetTheCurrentEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AESetTheCurrentEvent", (PyCFunction)AEDesc_AESetTheCurrentEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEResolve", (PyCFunction)AEDesc_AEResolve, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(short callbackFlags) -> (AEDesc theToken)")}, | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | 	{"AutoDispose", (PyCFunction)AEDesc_AutoDispose, 1, | 
					
						
							|  |  |  | 	 PyDoc_STR("(int)->int. Automatically AEDisposeDesc the object on Python object cleanup")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{NULL, NULL, 0} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | static PyObject *AEDesc_get_type(AEDescObject *self, void *closure) | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | 	return PyMac_BuildOSType(self->ob_itself.descriptorType); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | #define AEDesc_set_type NULL
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | static PyObject *AEDesc_get_data(AEDescObject *self, void *closure) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			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; | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | #define AEDesc_set_data NULL
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyGetSetDef AEDesc_getsetlist[] = { | 
					
						
							|  |  |  | 	{"type", (getter)AEDesc_get_type, (setter)AEDesc_set_type, "Type of this AEDesc"}, | 
					
						
							|  |  |  | 	{"data", (getter)AEDesc_get_data, (setter)AEDesc_set_data, "The raw data in this AEDesc"}, | 
					
						
							|  |  |  | 	{NULL, NULL, NULL, NULL}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_compare NULL
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_repr NULL
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_hash NULL
 | 
					
						
							| 
									
										
										
										
											2002-12-03 23:40:22 +00:00
										 |  |  | #define AEDesc_tp_init 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_tp_alloc PyType_GenericAlloc
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AEDesc_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	AEDesc itself; | 
					
						
							|  |  |  | 	char *kw[] = {"itself", 0}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, AEDesc_Convert, &itself)) return NULL; | 
					
						
							|  |  |  | 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; | 
					
						
							|  |  |  | 	((AEDescObject *)self)->ob_itself = itself; | 
					
						
							|  |  |  | 	return self; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AEDesc_tp_free PyObject_Del
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | PyTypeObject AEDesc_Type = { | 
					
						
							| 
									
										
										
										
											2001-11-30 14:16:36 +00:00
										 |  |  | 	PyObject_HEAD_INIT(NULL) | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	0, /*ob_size*/ | 
					
						
							| 
									
										
										
										
											2001-12-08 18:02:58 +00:00
										 |  |  | 	"_AE.AEDesc", /*tp_name*/ | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	sizeof(AEDescObject), /*tp_basicsize*/ | 
					
						
							|  |  |  | 	0, /*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor) AEDesc_dealloc, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0, /*tp_print*/ | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | 	(getattrfunc)0, /*tp_getattr*/ | 
					
						
							|  |  |  | 	(setattrfunc)0, /*tp_setattr*/ | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	(cmpfunc) AEDesc_compare, /*tp_compare*/ | 
					
						
							|  |  |  | 	(reprfunc) AEDesc_repr, /*tp_repr*/ | 
					
						
							|  |  |  | 	(PyNumberMethods *)0, /* tp_as_number */ | 
					
						
							|  |  |  | 	(PySequenceMethods *)0, /* tp_as_sequence */ | 
					
						
							|  |  |  | 	(PyMappingMethods *)0, /* tp_as_mapping */ | 
					
						
							|  |  |  | 	(hashfunc) AEDesc_hash, /*tp_hash*/ | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | 	0, /*tp_call*/ | 
					
						
							|  |  |  | 	0, /*tp_str*/ | 
					
						
							|  |  |  | 	PyObject_GenericGetAttr, /*tp_getattro*/ | 
					
						
							|  |  |  | 	PyObject_GenericSetAttr, /*tp_setattro */ | 
					
						
							| 
									
										
										
										
											2002-12-03 23:40:22 +00:00
										 |  |  | 	0, /*tp_as_buffer*/ | 
					
						
							|  |  |  | 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ | 
					
						
							|  |  |  | 	0, /*tp_doc*/ | 
					
						
							|  |  |  | 	0, /*tp_traverse*/ | 
					
						
							|  |  |  | 	0, /*tp_clear*/ | 
					
						
							|  |  |  | 	0, /*tp_richcompare*/ | 
					
						
							|  |  |  | 	0, /*tp_weaklistoffset*/ | 
					
						
							|  |  |  | 	0, /*tp_iter*/ | 
					
						
							|  |  |  | 	0, /*tp_iternext*/ | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | 	AEDesc_methods, /* tp_methods */ | 
					
						
							| 
									
										
										
										
											2002-12-03 23:40:22 +00:00
										 |  |  | 	0, /*tp_members*/ | 
					
						
							| 
									
										
										
										
											2002-11-29 23:40:48 +00:00
										 |  |  | 	AEDesc_getsetlist, /*tp_getset*/ | 
					
						
							| 
									
										
										
										
											2002-12-03 23:40:22 +00:00
										 |  |  | 	0, /*tp_base*/ | 
					
						
							|  |  |  | 	0, /*tp_dict*/ | 
					
						
							|  |  |  | 	0, /*tp_descr_get*/ | 
					
						
							|  |  |  | 	0, /*tp_descr_set*/ | 
					
						
							|  |  |  | 	0, /*tp_dictoffset*/ | 
					
						
							|  |  |  | 	AEDesc_tp_init, /* tp_init */ | 
					
						
							|  |  |  | 	AEDesc_tp_alloc, /* tp_alloc */ | 
					
						
							|  |  |  | 	AEDesc_tp_new, /* tp_new */ | 
					
						
							|  |  |  | 	AEDesc_tp_free, /* tp_free */ | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* --------------------- End object type AEDesc --------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AECoercePtr(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							|  |  |  | 	DescType toType; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECoercePtr
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECoercePtr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&s#O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &toType)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AECoercePtr(typeCode, | 
					
						
							|  |  |  | 	                   dataPtr__in__, dataPtr__len__, | 
					
						
							|  |  |  | 	                   toType, | 
					
						
							|  |  |  | 	                   &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AECreateDesc(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							|  |  |  | 	AEDesc result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECreateDesc
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECreateDesc); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&s#", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AECreateDesc(typeCode, | 
					
						
							|  |  |  | 	                    dataPtr__in__, dataPtr__len__, | 
					
						
							|  |  |  | 	                    &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AECreateList(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	char *factoringPtr__in__; | 
					
						
							|  |  |  | 	long factoringPtr__len__; | 
					
						
							|  |  |  | 	int factoringPtr__in_len__; | 
					
						
							|  |  |  | 	Boolean isRecord; | 
					
						
							|  |  |  | 	AEDescList resultList; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECreateList
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECreateList); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "s#b", | 
					
						
							|  |  |  | 	                      &factoringPtr__in__, &factoringPtr__in_len__, | 
					
						
							|  |  |  | 	                      &isRecord)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	factoringPtr__len__ = factoringPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AECreateList(factoringPtr__in__, factoringPtr__len__, | 
					
						
							|  |  |  | 	                    isRecord, | 
					
						
							|  |  |  | 	                    &resultList); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &resultList); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AECreateAppleEvent(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEEventClass theAEEventClass; | 
					
						
							|  |  |  | 	AEEventID theAEEventID; | 
					
						
							|  |  |  | 	AEAddressDesc target; | 
					
						
							|  |  |  | 	AEReturnID returnID; | 
					
						
							|  |  |  | 	AETransactionID transactionID; | 
					
						
							|  |  |  | 	AppleEvent result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECreateAppleEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECreateAppleEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&O&hl", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventClass, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventID, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &target, | 
					
						
							|  |  |  | 	                      &returnID, | 
					
						
							|  |  |  | 	                      &transactionID)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AECreateAppleEvent(theAEEventClass, | 
					
						
							|  |  |  | 	                          theAEEventID, | 
					
						
							|  |  |  | 	                          &target, | 
					
						
							|  |  |  | 	                          returnID, | 
					
						
							|  |  |  | 	                          transactionID, | 
					
						
							|  |  |  | 	                          &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEReplaceDescData(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	DescType typeCode; | 
					
						
							|  |  |  | 	char *dataPtr__in__; | 
					
						
							|  |  |  | 	long dataPtr__len__; | 
					
						
							|  |  |  | 	int dataPtr__in_len__; | 
					
						
							|  |  |  | 	AEDesc theAEDesc; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEReplaceDescData
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEReplaceDescData); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&s#", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &typeCode, | 
					
						
							|  |  |  | 	                      &dataPtr__in__, &dataPtr__in_len__)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	dataPtr__len__ = dataPtr__in_len__; | 
					
						
							|  |  |  | 	_err = AEReplaceDescData(typeCode, | 
					
						
							|  |  |  | 	                         dataPtr__in__, dataPtr__len__, | 
					
						
							|  |  |  | 	                         &theAEDesc); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &theAEDesc); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | static PyObject *AE_AEProcessAppleEvent(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	EventRecord theEventRecord; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEProcessAppleEvent
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEProcessAppleEvent); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetEventRecord, &theEventRecord)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEProcessAppleEvent(&theEventRecord); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEGetInteractionAllowed(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEInteractAllowed level; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetInteractionAllowed
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetInteractionAllowed); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetInteractionAllowed(&level); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("b", | 
					
						
							|  |  |  | 	                     level); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AESetInteractionAllowed(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEInteractAllowed level; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AESetInteractionAllowed
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AESetInteractionAllowed); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "b", | 
					
						
							|  |  |  | 	                      &level)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AESetInteractionAllowed(level); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEInteractWithUser(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	long timeOutInTicks; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEInteractWithUser
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEInteractWithUser); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "l", | 
					
						
							|  |  |  | 	                      &timeOutInTicks)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEInteractWithUser(timeOutInTicks, | 
					
						
							|  |  |  | 	                          (NMRecPtr)0, | 
					
						
							|  |  |  | 	                          upp_AEIdleProc); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | static PyObject *AE_AEInstallEventHandler(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEEventClass theAEEventClass; | 
					
						
							|  |  |  | 	AEEventID theAEEventID; | 
					
						
							|  |  |  | 	AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; | 
					
						
							|  |  |  | 	PyObject *handler; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEInstallEventHandler
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEInstallEventHandler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&O", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventClass, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventID, | 
					
						
							|  |  |  | 	                      &handler)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEInstallEventHandler(theAEEventClass, | 
					
						
							|  |  |  | 	                             theAEEventID, | 
					
						
							|  |  |  | 	                             handler__proc__, (long)handler, | 
					
						
							|  |  |  | 	                             0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	Py_INCREF(handler); /* XXX leak, but needed */ | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AERemoveEventHandler(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEEventClass theAEEventClass; | 
					
						
							|  |  |  | 	AEEventID theAEEventID; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AERemoveEventHandler
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AERemoveEventHandler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventClass, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventID)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AERemoveEventHandler(theAEEventClass, | 
					
						
							|  |  |  | 	                            theAEEventID, | 
					
						
							|  |  |  | 	                            upp_GenericEventHandler, | 
					
						
							|  |  |  | 	                            0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEGetEventHandler(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEEventClass theAEEventClass; | 
					
						
							|  |  |  | 	AEEventID theAEEventID; | 
					
						
							|  |  |  | 	AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; | 
					
						
							|  |  |  | 	PyObject *handler; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEGetEventHandler
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEGetEventHandler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventClass, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &theAEEventID)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEGetEventHandler(theAEEventClass, | 
					
						
							|  |  |  | 	                         theAEEventID, | 
					
						
							|  |  |  | 	                         &handler__proc__, (long *)&handler, | 
					
						
							|  |  |  | 	                         0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O", | 
					
						
							|  |  |  | 	                     handler); | 
					
						
							|  |  |  | 	Py_INCREF(handler); /* XXX leak, but needed */ | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEInstallSpecialHandler(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword functionClass; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEInstallSpecialHandler
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEInstallSpecialHandler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &functionClass)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEInstallSpecialHandler(functionClass, | 
					
						
							|  |  |  | 	                               upp_GenericEventHandler, | 
					
						
							|  |  |  | 	                               0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AERemoveSpecialHandler(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword functionClass; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AERemoveSpecialHandler
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AERemoveSpecialHandler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &functionClass)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AERemoveSpecialHandler(functionClass, | 
					
						
							|  |  |  | 	                              upp_GenericEventHandler, | 
					
						
							|  |  |  | 	                              0); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEManagerInfo(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEKeyword keyWord; | 
					
						
							|  |  |  | 	long result; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEManagerInfo
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEManagerInfo); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &keyWord)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEManagerInfo(keyWord, | 
					
						
							|  |  |  | 	                     &result); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("l", | 
					
						
							|  |  |  | 	                     result); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEObjectInit(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEObjectInit
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEObjectInit); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEObjectInit(); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	_res = Py_None; | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AEDisposeToken(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	AEDesc theToken; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AEDisposeToken
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AEDisposeToken); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AEDisposeToken(&theToken); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &theToken); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *AE_AECallObjectAccessor(PyObject *_self, PyObject *_args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *_res = NULL; | 
					
						
							|  |  |  | 	OSErr _err; | 
					
						
							|  |  |  | 	DescType desiredClass; | 
					
						
							|  |  |  | 	AEDesc containerToken; | 
					
						
							|  |  |  | 	DescType containerClass; | 
					
						
							|  |  |  | 	DescType keyForm; | 
					
						
							|  |  |  | 	AEDesc keyData; | 
					
						
							|  |  |  | 	AEDesc token; | 
					
						
							| 
									
										
										
										
											2002-03-24 23:04:18 +00:00
										 |  |  | #ifndef AECallObjectAccessor
 | 
					
						
							|  |  |  | 	PyMac_PRECHECK(AECallObjectAccessor); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &desiredClass, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &containerToken, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &containerClass, | 
					
						
							|  |  |  | 	                      PyMac_GetOSType, &keyForm, | 
					
						
							|  |  |  | 	                      AEDesc_Convert, &keyData)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	_err = AECallObjectAccessor(desiredClass, | 
					
						
							|  |  |  | 	                            &containerToken, | 
					
						
							|  |  |  | 	                            containerClass, | 
					
						
							|  |  |  | 	                            keyForm, | 
					
						
							|  |  |  | 	                            &keyData, | 
					
						
							|  |  |  | 	                            &token); | 
					
						
							|  |  |  | 	if (_err != noErr) return PyMac_Error(_err); | 
					
						
							|  |  |  | 	_res = Py_BuildValue("O&", | 
					
						
							|  |  |  | 	                     AEDesc_New, &token); | 
					
						
							|  |  |  | 	return _res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef AE_methods[] = { | 
					
						
							|  |  |  | 	{"AECoercePtr", (PyCFunction)AE_AECoercePtr, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(DescType typeCode, Buffer dataPtr, DescType toType) -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AECreateDesc", (PyCFunction)AE_AECreateDesc, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(DescType typeCode, Buffer dataPtr) -> (AEDesc result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AECreateList", (PyCFunction)AE_AECreateList, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(Buffer factoringPtr, Boolean isRecord) -> (AEDescList resultList)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AECreateAppleEvent", (PyCFunction)AE_AECreateAppleEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID, AEAddressDesc target, AEReturnID returnID, AETransactionID transactionID) -> (AppleEvent result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEReplaceDescData", (PyCFunction)AE_AEReplaceDescData, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(DescType typeCode, Buffer dataPtr) -> (AEDesc theAEDesc)")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEProcessAppleEvent", (PyCFunction)AE_AEProcessAppleEvent, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(EventRecord theEventRecord) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEGetInteractionAllowed", (PyCFunction)AE_AEGetInteractionAllowed, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> (AEInteractAllowed level)")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AESetInteractionAllowed", (PyCFunction)AE_AESetInteractionAllowed, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEInteractAllowed level) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-12-17 11:47:27 +00:00
										 |  |  | 	{"AEInteractWithUser", (PyCFunction)AE_AEInteractWithUser, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(long timeOutInTicks) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEInstallEventHandler", (PyCFunction)AE_AEInstallEventHandler, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID, EventHandler handler) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AERemoveEventHandler", (PyCFunction)AE_AERemoveEventHandler, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEInstallSpecialHandler", (PyCFunction)AE_AEInstallSpecialHandler, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword functionClass) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AERemoveSpecialHandler", (PyCFunction)AE_AERemoveSpecialHandler, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword functionClass) -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(AEKeyword keyWord) -> (long result)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEObjectInit", (PyCFunction)AE_AEObjectInit, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> None")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AEDisposeToken", (PyCFunction)AE_AEDisposeToken, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("() -> (AEDesc theToken)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{"AECallObjectAccessor", (PyCFunction)AE_AECallObjectAccessor, 1, | 
					
						
							| 
									
										
										
										
											2002-08-16 09:09:31 +00:00
										 |  |  | 	 PyDoc_STR("(DescType desiredClass, AEDesc containerToken, DescType containerClass, DescType keyForm, AEDesc keyData) -> (AEDesc token)")}, | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	{NULL, NULL, 0} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static pascal OSErr | 
					
						
							|  |  |  | 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); | 
					
						
							| 
									
										
										
										
											2002-01-04 13:49:36 +00:00
										 |  |  | 	if (res == NULL) { | 
					
						
							|  |  |  | 		PySys_WriteStderr("Exception in AE event handler function\n"); | 
					
						
							|  |  |  | 		PyErr_Print(); | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2002-01-04 13:49:36 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	Py_DECREF(res); | 
					
						
							|  |  |  | 	return noErr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | PyObject *AEDesc_NewBorrowed(AEDesc *itself) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *it; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	it = AEDesc_New(itself); | 
					
						
							|  |  |  | 	if (it) | 
					
						
							|  |  |  | 		((AEDescObject *)it)->ob_owned = 0; | 
					
						
							|  |  |  | 	return (PyObject *)it; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void init_AE(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *m; | 
					
						
							|  |  |  | 	PyObject *d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); | 
					
						
							|  |  |  | 		upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); | 
					
						
							|  |  |  | 		PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); | 
					
						
							| 
									
										
										
										
											2003-01-17 23:11:17 +00:00
										 |  |  | 		PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 		PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m = Py_InitModule("_AE", AE_methods); | 
					
						
							|  |  |  | 	d = PyModule_GetDict(m); | 
					
						
							|  |  |  | 	AE_Error = PyMac_GetOSErrException(); | 
					
						
							|  |  |  | 	if (AE_Error == NULL || | 
					
						
							|  |  |  | 	    PyDict_SetItemString(d, "Error", AE_Error) != 0) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	AEDesc_Type.ob_type = &PyType_Type; | 
					
						
							| 
									
										
										
										
											2002-12-23 23:16:25 +00:00
										 |  |  | 	if (PyType_Ready(&AEDesc_Type) < 0) return; | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | 	Py_INCREF(&AEDesc_Type); | 
					
						
							| 
									
										
										
										
											2002-12-03 23:40:22 +00:00
										 |  |  | 	PyModule_AddObject(m, "AEDesc", (PyObject *)&AEDesc_Type); | 
					
						
							|  |  |  | 	/* Backward-compatible name */ | 
					
						
							|  |  |  | 	Py_INCREF(&AEDesc_Type); | 
					
						
							|  |  |  | 	PyModule_AddObject(m, "AEDescType", (PyObject *)&AEDesc_Type); | 
					
						
							| 
									
										
										
										
											2001-08-23 14:02:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ========================= End module _AE ========================= */ | 
					
						
							|  |  |  | 
 |