2020 }} while(0)
2121
2222
23+ #ifndef PyDoc_STR
24+ #define PyDoc_STR (x ) (x)
25+ #endif
2326#ifdef WITHOUT_FRAMEWORKS
2427#include <AppleEvents.h>
2528#include <AEObjects.h>
@@ -35,7 +38,13 @@ extern int _AEDesc_Convert(PyObject *, AEDesc *);
3538#define AEDesc_Convert _AEDesc_Convert
3639#endif
3740
38- static pascal OSErr GenericEventHandler (); /* Forward */
41+ #if UNIVERSAL_INTERFACES_VERSION >= 0x0340
42+ typedef long refcontype ;
43+ #else
44+ typedef unsigned long refcontype ;
45+ #endif
46+
47+ static pascal OSErr GenericEventHandler (const AppleEvent * request , AppleEvent * reply , refcontype refcon ); /* Forward */
3948
4049AEEventHandlerUPP upp_GenericEventHandler ;
4150
@@ -820,46 +829,40 @@ static PyMethodDef AEDesc_methods[] = {
820829 {NULL , NULL , 0 }
821830};
822831
823- PyMethodChain AEDesc_chain = { AEDesc_methods , NULL };
824-
825- static PyObject * AEDesc_getattr (AEDescObject * self , char * name )
832+ static PyObject * AEDesc_get_type (AEDescObject * self , void * closure )
826833{
834+ return PyMac_BuildOSType (self -> ob_itself .descriptorType );
835+ }
827836
828- if (strcmp (name , "type" ) == 0 )
829- return PyMac_BuildOSType (self -> ob_itself .descriptorType );
830- if (strcmp (name , "data" ) == 0 ) {
831- PyObject * res ;
832- #if !TARGET_API_MAC_CARBON
833- char state ;
834- state = HGetState (self -> ob_itself .dataHandle );
835- HLock (self -> ob_itself .dataHandle );
836- res = PyString_FromStringAndSize (
837- * self -> ob_itself .dataHandle ,
838- GetHandleSize (self -> ob_itself .dataHandle ));
839- HUnlock (self -> ob_itself .dataHandle );
840- HSetState (self -> ob_itself .dataHandle , state );
841- #else
842- Size size ;
843- char * ptr ;
844- OSErr err ;
845-
846- size = AEGetDescDataSize (& self -> ob_itself );
847- if ( (res = PyString_FromStringAndSize (NULL , size )) == NULL )
848- return NULL ;
849- if ( (ptr = PyString_AsString (res )) == NULL )
850- return NULL ;
851- if ( (err = AEGetDescData (& self -> ob_itself , ptr , size )) < 0 )
852- return PyMac_Error (err );
853- #endif
854- return res ;
855- }
856- if (strcmp (name , "__members__" ) == 0 )
857- return Py_BuildValue ("[ss]" , "data" , "type" );
837+ #define AEDesc_set_type NULL
858838
859- return Py_FindMethodInChain (& AEDesc_chain , (PyObject * )self , name );
839+ static PyObject * AEDesc_get_data (AEDescObject * self , void * closure )
840+ {
841+
842+ PyObject * res ;
843+ Size size ;
844+ char * ptr ;
845+ OSErr err ;
846+
847+ size = AEGetDescDataSize (& self -> ob_itself );
848+ if ( (res = PyString_FromStringAndSize (NULL , size )) == NULL )
849+ return NULL ;
850+ if ( (ptr = PyString_AsString (res )) == NULL )
851+ return NULL ;
852+ if ( (err = AEGetDescData (& self -> ob_itself , ptr , size )) < 0 )
853+ return PyMac_Error (err );
854+ return res ;
855+
860856}
861857
862- #define AEDesc_setattr NULL
858+ #define AEDesc_set_data NULL
859+
860+ static PyGetSetDef AEDesc_getsetlist [] = {
861+ {"type" , (getter )AEDesc_get_type , (setter )AEDesc_set_type , "Type of this AEDesc" },
862+ {"data" , (getter )AEDesc_get_data , (setter )AEDesc_set_data , "The raw data in this AEDesc" },
863+ {NULL , NULL , NULL , NULL },
864+ };
865+
863866
864867#define AEDesc_compare NULL
865868
@@ -876,14 +879,31 @@ PyTypeObject AEDesc_Type = {
876879 /* methods */
877880 (destructor ) AEDesc_dealloc , /*tp_dealloc*/
878881 0 , /*tp_print*/
879- (getattrfunc ) AEDesc_getattr , /*tp_getattr*/
880- (setattrfunc ) AEDesc_setattr , /*tp_setattr*/
882+ (getattrfunc )0 , /*tp_getattr*/
883+ (setattrfunc )0 , /*tp_setattr*/
881884 (cmpfunc ) AEDesc_compare , /*tp_compare*/
882885 (reprfunc ) AEDesc_repr , /*tp_repr*/
883886 (PyNumberMethods * )0 , /* tp_as_number */
884887 (PySequenceMethods * )0 , /* tp_as_sequence */
885888 (PyMappingMethods * )0 , /* tp_as_mapping */
886889 (hashfunc ) AEDesc_hash , /*tp_hash*/
890+ 0 , /*tp_call*/
891+ 0 , /*tp_str*/
892+ PyObject_GenericGetAttr , /*tp_getattro*/
893+ PyObject_GenericSetAttr , /*tp_setattro */
894+ 0 , /*outputHook_tp_as_buffer*/
895+ 0 , /*outputHook_tp_flags*/
896+ 0 , /*outputHook_tp_doc*/
897+ 0 , /*outputHook_tp_traverse*/
898+ 0 , /*outputHook_tp_clear*/
899+ 0 , /*outputHook_tp_richcompare*/
900+ 0 , /*outputHook_tp_weaklistoffset*/
901+ 0 , /*outputHook_tp_iter*/
902+ 0 , /*outputHook_tp_iternext*/
903+ AEDesc_methods , /* tp_methods */
904+ 0 , /*outputHook_tp_members*/
905+ AEDesc_getsetlist , /*tp_getset*/
906+ 0 , /*outputHook_tp_base*/
887907};
888908
889909/* --------------------- End object type AEDesc --------------------- */
@@ -1350,12 +1370,6 @@ static PyMethodDef AE_methods[] = {
13501370
13511371
13521372
1353- #if UNIVERSAL_INTERFACES_VERSION >= 0x0340
1354- typedef long refcontype ;
1355- #else
1356- typedef unsigned long refcontype ;
1357- #endif
1358-
13591373static pascal OSErr
13601374GenericEventHandler (const AppleEvent * request , AppleEvent * reply , refcontype refcon )
13611375{
0 commit comments