| 1 | n/a | |
|---|
| 2 | n/a | /* =========================== Module _AE =========================== */ |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | #include "Python.h" |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | #include "pymactoolbox.h" |
|---|
| 9 | n/a | |
|---|
| 10 | n/a | #ifndef HAVE_OSX105_SDK |
|---|
| 11 | n/a | typedef SInt32 SRefCon; |
|---|
| 12 | n/a | #endif |
|---|
| 13 | n/a | |
|---|
| 14 | n/a | /* Macro to test whether a weak-loaded CFM function exists */ |
|---|
| 15 | n/a | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
|---|
| 16 | n/a | PyErr_SetString(PyExc_NotImplementedError, \ |
|---|
| 17 | n/a | "Not available in this shared library/OS version"); \ |
|---|
| 18 | n/a | return NULL; \ |
|---|
| 19 | n/a | }} while(0) |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | #include <Carbon/Carbon.h> |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | #ifdef USE_TOOLBOX_OBJECT_GLUE |
|---|
| 25 | n/a | extern PyObject *_AEDesc_New(AEDesc *); |
|---|
| 26 | n/a | extern int _AEDesc_Convert(PyObject *, AEDesc *); |
|---|
| 27 | n/a | |
|---|
| 28 | n/a | #define AEDesc_New _AEDesc_New |
|---|
| 29 | n/a | #define AEDesc_NewBorrowed _AEDesc_NewBorrowed |
|---|
| 30 | n/a | #define AEDesc_Convert _AEDesc_Convert |
|---|
| 31 | n/a | #endif |
|---|
| 32 | n/a | |
|---|
| 33 | n/a | typedef long refcontype; |
|---|
| 34 | n/a | |
|---|
| 35 | n/a | static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */ |
|---|
| 36 | n/a | |
|---|
| 37 | n/a | AEEventHandlerUPP upp_GenericEventHandler; |
|---|
| 38 | n/a | |
|---|
| 39 | n/a | static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) |
|---|
| 40 | n/a | { |
|---|
| 41 | n/a | if ( PyOS_InterruptOccurred() ) |
|---|
| 42 | n/a | return 1; |
|---|
| 43 | n/a | return 0; |
|---|
| 44 | n/a | } |
|---|
| 45 | n/a | |
|---|
| 46 | n/a | AEIdleUPP upp_AEIdleProc; |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | static PyObject *AE_Error; |
|---|
| 49 | n/a | |
|---|
| 50 | n/a | /* ----------------------- Object type AEDesc ----------------------- */ |
|---|
| 51 | n/a | |
|---|
| 52 | n/a | PyTypeObject AEDesc_Type; |
|---|
| 53 | n/a | |
|---|
| 54 | n/a | #define AEDesc_Check(x) ((x)->ob_type == &AEDesc_Type || PyObject_TypeCheck((x), &AEDesc_Type)) |
|---|
| 55 | n/a | |
|---|
| 56 | n/a | typedef struct AEDescObject { |
|---|
| 57 | n/a | PyObject_HEAD |
|---|
| 58 | n/a | AEDesc ob_itself; |
|---|
| 59 | n/a | int ob_owned; |
|---|
| 60 | n/a | } AEDescObject; |
|---|
| 61 | n/a | |
|---|
| 62 | n/a | PyObject *AEDesc_New(AEDesc *itself) |
|---|
| 63 | n/a | { |
|---|
| 64 | n/a | AEDescObject *it; |
|---|
| 65 | n/a | it = PyObject_NEW(AEDescObject, &AEDesc_Type); |
|---|
| 66 | n/a | if (it == NULL) return NULL; |
|---|
| 67 | n/a | it->ob_itself = *itself; |
|---|
| 68 | n/a | it->ob_owned = 1; |
|---|
| 69 | n/a | return (PyObject *)it; |
|---|
| 70 | n/a | } |
|---|
| 71 | n/a | |
|---|
| 72 | n/a | int AEDesc_Convert(PyObject *v, AEDesc *p_itself) |
|---|
| 73 | n/a | { |
|---|
| 74 | n/a | if (!AEDesc_Check(v)) |
|---|
| 75 | n/a | { |
|---|
| 76 | n/a | PyErr_SetString(PyExc_TypeError, "AEDesc required"); |
|---|
| 77 | n/a | return 0; |
|---|
| 78 | n/a | } |
|---|
| 79 | n/a | *p_itself = ((AEDescObject *)v)->ob_itself; |
|---|
| 80 | n/a | return 1; |
|---|
| 81 | n/a | } |
|---|
| 82 | n/a | |
|---|
| 83 | n/a | static void AEDesc_dealloc(AEDescObject *self) |
|---|
| 84 | n/a | { |
|---|
| 85 | n/a | if (self->ob_owned) AEDisposeDesc(&self->ob_itself); |
|---|
| 86 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 87 | n/a | } |
|---|
| 88 | n/a | |
|---|
| 89 | n/a | static PyObject *AEDesc_AECoerceDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 90 | n/a | { |
|---|
| 91 | n/a | PyObject *_res = NULL; |
|---|
| 92 | n/a | OSErr _err; |
|---|
| 93 | n/a | DescType toType; |
|---|
| 94 | n/a | AEDesc result; |
|---|
| 95 | n/a | #ifndef AECoerceDesc |
|---|
| 96 | n/a | PyMac_PRECHECK(AECoerceDesc); |
|---|
| 97 | n/a | #endif |
|---|
| 98 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 99 | n/a | PyMac_GetOSType, &toType)) |
|---|
| 100 | n/a | return NULL; |
|---|
| 101 | n/a | _err = AECoerceDesc(&_self->ob_itself, |
|---|
| 102 | n/a | toType, |
|---|
| 103 | n/a | &result); |
|---|
| 104 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 105 | n/a | _res = Py_BuildValue("O&", |
|---|
| 106 | n/a | AEDesc_New, &result); |
|---|
| 107 | n/a | return _res; |
|---|
| 108 | n/a | } |
|---|
| 109 | n/a | |
|---|
| 110 | n/a | static PyObject *AEDesc_AEDuplicateDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 111 | n/a | { |
|---|
| 112 | n/a | PyObject *_res = NULL; |
|---|
| 113 | n/a | OSErr _err; |
|---|
| 114 | n/a | AEDesc result; |
|---|
| 115 | n/a | #ifndef AEDuplicateDesc |
|---|
| 116 | n/a | PyMac_PRECHECK(AEDuplicateDesc); |
|---|
| 117 | n/a | #endif |
|---|
| 118 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 119 | n/a | return NULL; |
|---|
| 120 | n/a | _err = AEDuplicateDesc(&_self->ob_itself, |
|---|
| 121 | n/a | &result); |
|---|
| 122 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 123 | n/a | _res = Py_BuildValue("O&", |
|---|
| 124 | n/a | AEDesc_New, &result); |
|---|
| 125 | n/a | return _res; |
|---|
| 126 | n/a | } |
|---|
| 127 | n/a | |
|---|
| 128 | n/a | static PyObject *AEDesc_AECountItems(AEDescObject *_self, PyObject *_args) |
|---|
| 129 | n/a | { |
|---|
| 130 | n/a | PyObject *_res = NULL; |
|---|
| 131 | n/a | OSErr _err; |
|---|
| 132 | n/a | long theCount; |
|---|
| 133 | n/a | #ifndef AECountItems |
|---|
| 134 | n/a | PyMac_PRECHECK(AECountItems); |
|---|
| 135 | n/a | #endif |
|---|
| 136 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 137 | n/a | return NULL; |
|---|
| 138 | n/a | _err = AECountItems(&_self->ob_itself, |
|---|
| 139 | n/a | &theCount); |
|---|
| 140 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 141 | n/a | _res = Py_BuildValue("l", |
|---|
| 142 | n/a | theCount); |
|---|
| 143 | n/a | return _res; |
|---|
| 144 | n/a | } |
|---|
| 145 | n/a | |
|---|
| 146 | n/a | static PyObject *AEDesc_AEPutPtr(AEDescObject *_self, PyObject *_args) |
|---|
| 147 | n/a | { |
|---|
| 148 | n/a | PyObject *_res = NULL; |
|---|
| 149 | n/a | OSErr _err; |
|---|
| 150 | n/a | long index; |
|---|
| 151 | n/a | DescType typeCode; |
|---|
| 152 | n/a | char *dataPtr__in__; |
|---|
| 153 | n/a | long dataPtr__len__; |
|---|
| 154 | n/a | int dataPtr__in_len__; |
|---|
| 155 | n/a | #ifndef AEPutPtr |
|---|
| 156 | n/a | PyMac_PRECHECK(AEPutPtr); |
|---|
| 157 | n/a | #endif |
|---|
| 158 | n/a | if (!PyArg_ParseTuple(_args, "lO&s#", |
|---|
| 159 | n/a | &index, |
|---|
| 160 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 161 | n/a | &dataPtr__in__, &dataPtr__in_len__)) |
|---|
| 162 | n/a | return NULL; |
|---|
| 163 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 164 | n/a | _err = AEPutPtr(&_self->ob_itself, |
|---|
| 165 | n/a | index, |
|---|
| 166 | n/a | typeCode, |
|---|
| 167 | n/a | dataPtr__in__, dataPtr__len__); |
|---|
| 168 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 169 | n/a | Py_INCREF(Py_None); |
|---|
| 170 | n/a | _res = Py_None; |
|---|
| 171 | n/a | return _res; |
|---|
| 172 | n/a | } |
|---|
| 173 | n/a | |
|---|
| 174 | n/a | static PyObject *AEDesc_AEPutDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 175 | n/a | { |
|---|
| 176 | n/a | PyObject *_res = NULL; |
|---|
| 177 | n/a | OSErr _err; |
|---|
| 178 | n/a | long index; |
|---|
| 179 | n/a | AEDesc theAEDesc; |
|---|
| 180 | n/a | #ifndef AEPutDesc |
|---|
| 181 | n/a | PyMac_PRECHECK(AEPutDesc); |
|---|
| 182 | n/a | #endif |
|---|
| 183 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 184 | n/a | &index, |
|---|
| 185 | n/a | AEDesc_Convert, &theAEDesc)) |
|---|
| 186 | n/a | return NULL; |
|---|
| 187 | n/a | _err = AEPutDesc(&_self->ob_itself, |
|---|
| 188 | n/a | index, |
|---|
| 189 | n/a | &theAEDesc); |
|---|
| 190 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 191 | n/a | Py_INCREF(Py_None); |
|---|
| 192 | n/a | _res = Py_None; |
|---|
| 193 | n/a | return _res; |
|---|
| 194 | n/a | } |
|---|
| 195 | n/a | |
|---|
| 196 | n/a | static PyObject *AEDesc_AEGetNthPtr(AEDescObject *_self, PyObject *_args) |
|---|
| 197 | n/a | { |
|---|
| 198 | n/a | PyObject *_res = NULL; |
|---|
| 199 | n/a | OSErr _err; |
|---|
| 200 | n/a | long index; |
|---|
| 201 | n/a | DescType desiredType; |
|---|
| 202 | n/a | AEKeyword theAEKeyword; |
|---|
| 203 | n/a | DescType typeCode; |
|---|
| 204 | n/a | char *dataPtr__out__; |
|---|
| 205 | n/a | long dataPtr__len__; |
|---|
| 206 | n/a | int dataPtr__in_len__; |
|---|
| 207 | n/a | #ifndef AEGetNthPtr |
|---|
| 208 | n/a | PyMac_PRECHECK(AEGetNthPtr); |
|---|
| 209 | n/a | #endif |
|---|
| 210 | n/a | if (!PyArg_ParseTuple(_args, "lO&i", |
|---|
| 211 | n/a | &index, |
|---|
| 212 | n/a | PyMac_GetOSType, &desiredType, |
|---|
| 213 | n/a | &dataPtr__in_len__)) |
|---|
| 214 | n/a | return NULL; |
|---|
| 215 | n/a | if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) |
|---|
| 216 | n/a | { |
|---|
| 217 | n/a | PyErr_NoMemory(); |
|---|
| 218 | n/a | goto dataPtr__error__; |
|---|
| 219 | n/a | } |
|---|
| 220 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 221 | n/a | _err = AEGetNthPtr(&_self->ob_itself, |
|---|
| 222 | n/a | index, |
|---|
| 223 | n/a | desiredType, |
|---|
| 224 | n/a | &theAEKeyword, |
|---|
| 225 | n/a | &typeCode, |
|---|
| 226 | n/a | dataPtr__out__, dataPtr__len__, &dataPtr__len__); |
|---|
| 227 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 228 | n/a | _res = Py_BuildValue("O&O&s#", |
|---|
| 229 | n/a | PyMac_BuildOSType, theAEKeyword, |
|---|
| 230 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 231 | n/a | dataPtr__out__, (int)dataPtr__len__); |
|---|
| 232 | n/a | free(dataPtr__out__); |
|---|
| 233 | n/a | dataPtr__error__: ; |
|---|
| 234 | n/a | return _res; |
|---|
| 235 | n/a | } |
|---|
| 236 | n/a | |
|---|
| 237 | n/a | static PyObject *AEDesc_AEGetNthDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 238 | n/a | { |
|---|
| 239 | n/a | PyObject *_res = NULL; |
|---|
| 240 | n/a | OSErr _err; |
|---|
| 241 | n/a | long index; |
|---|
| 242 | n/a | DescType desiredType; |
|---|
| 243 | n/a | AEKeyword theAEKeyword; |
|---|
| 244 | n/a | AEDesc result; |
|---|
| 245 | n/a | #ifndef AEGetNthDesc |
|---|
| 246 | n/a | PyMac_PRECHECK(AEGetNthDesc); |
|---|
| 247 | n/a | #endif |
|---|
| 248 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 249 | n/a | &index, |
|---|
| 250 | n/a | PyMac_GetOSType, &desiredType)) |
|---|
| 251 | n/a | return NULL; |
|---|
| 252 | n/a | _err = AEGetNthDesc(&_self->ob_itself, |
|---|
| 253 | n/a | index, |
|---|
| 254 | n/a | desiredType, |
|---|
| 255 | n/a | &theAEKeyword, |
|---|
| 256 | n/a | &result); |
|---|
| 257 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 258 | n/a | _res = Py_BuildValue("O&O&", |
|---|
| 259 | n/a | PyMac_BuildOSType, theAEKeyword, |
|---|
| 260 | n/a | AEDesc_New, &result); |
|---|
| 261 | n/a | return _res; |
|---|
| 262 | n/a | } |
|---|
| 263 | n/a | |
|---|
| 264 | n/a | static PyObject *AEDesc_AESizeOfNthItem(AEDescObject *_self, PyObject *_args) |
|---|
| 265 | n/a | { |
|---|
| 266 | n/a | PyObject *_res = NULL; |
|---|
| 267 | n/a | OSErr _err; |
|---|
| 268 | n/a | long index; |
|---|
| 269 | n/a | DescType typeCode; |
|---|
| 270 | n/a | Size dataSize; |
|---|
| 271 | n/a | #ifndef AESizeOfNthItem |
|---|
| 272 | n/a | PyMac_PRECHECK(AESizeOfNthItem); |
|---|
| 273 | n/a | #endif |
|---|
| 274 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 275 | n/a | &index)) |
|---|
| 276 | n/a | return NULL; |
|---|
| 277 | n/a | _err = AESizeOfNthItem(&_self->ob_itself, |
|---|
| 278 | n/a | index, |
|---|
| 279 | n/a | &typeCode, |
|---|
| 280 | n/a | &dataSize); |
|---|
| 281 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 282 | n/a | _res = Py_BuildValue("O&l", |
|---|
| 283 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 284 | n/a | dataSize); |
|---|
| 285 | n/a | return _res; |
|---|
| 286 | n/a | } |
|---|
| 287 | n/a | |
|---|
| 288 | n/a | static PyObject *AEDesc_AEDeleteItem(AEDescObject *_self, PyObject *_args) |
|---|
| 289 | n/a | { |
|---|
| 290 | n/a | PyObject *_res = NULL; |
|---|
| 291 | n/a | OSErr _err; |
|---|
| 292 | n/a | long index; |
|---|
| 293 | n/a | #ifndef AEDeleteItem |
|---|
| 294 | n/a | PyMac_PRECHECK(AEDeleteItem); |
|---|
| 295 | n/a | #endif |
|---|
| 296 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 297 | n/a | &index)) |
|---|
| 298 | n/a | return NULL; |
|---|
| 299 | n/a | _err = AEDeleteItem(&_self->ob_itself, |
|---|
| 300 | n/a | index); |
|---|
| 301 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 302 | n/a | Py_INCREF(Py_None); |
|---|
| 303 | n/a | _res = Py_None; |
|---|
| 304 | n/a | return _res; |
|---|
| 305 | n/a | } |
|---|
| 306 | n/a | |
|---|
| 307 | n/a | static PyObject *AEDesc_AEPutParamPtr(AEDescObject *_self, PyObject *_args) |
|---|
| 308 | n/a | { |
|---|
| 309 | n/a | PyObject *_res = NULL; |
|---|
| 310 | n/a | OSErr _err; |
|---|
| 311 | n/a | AEKeyword theAEKeyword; |
|---|
| 312 | n/a | DescType typeCode; |
|---|
| 313 | n/a | char *dataPtr__in__; |
|---|
| 314 | n/a | long dataPtr__len__; |
|---|
| 315 | n/a | int dataPtr__in_len__; |
|---|
| 316 | n/a | #ifndef AEPutParamPtr |
|---|
| 317 | n/a | PyMac_PRECHECK(AEPutParamPtr); |
|---|
| 318 | n/a | #endif |
|---|
| 319 | n/a | if (!PyArg_ParseTuple(_args, "O&O&s#", |
|---|
| 320 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 321 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 322 | n/a | &dataPtr__in__, &dataPtr__in_len__)) |
|---|
| 323 | n/a | return NULL; |
|---|
| 324 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 325 | n/a | _err = AEPutParamPtr(&_self->ob_itself, |
|---|
| 326 | n/a | theAEKeyword, |
|---|
| 327 | n/a | typeCode, |
|---|
| 328 | n/a | dataPtr__in__, dataPtr__len__); |
|---|
| 329 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 330 | n/a | Py_INCREF(Py_None); |
|---|
| 331 | n/a | _res = Py_None; |
|---|
| 332 | n/a | return _res; |
|---|
| 333 | n/a | } |
|---|
| 334 | n/a | |
|---|
| 335 | n/a | static PyObject *AEDesc_AEPutParamDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 336 | n/a | { |
|---|
| 337 | n/a | PyObject *_res = NULL; |
|---|
| 338 | n/a | OSErr _err; |
|---|
| 339 | n/a | AEKeyword theAEKeyword; |
|---|
| 340 | n/a | AEDesc theAEDesc; |
|---|
| 341 | n/a | #ifndef AEPutParamDesc |
|---|
| 342 | n/a | PyMac_PRECHECK(AEPutParamDesc); |
|---|
| 343 | n/a | #endif |
|---|
| 344 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 345 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 346 | n/a | AEDesc_Convert, &theAEDesc)) |
|---|
| 347 | n/a | return NULL; |
|---|
| 348 | n/a | _err = AEPutParamDesc(&_self->ob_itself, |
|---|
| 349 | n/a | theAEKeyword, |
|---|
| 350 | n/a | &theAEDesc); |
|---|
| 351 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 352 | n/a | Py_INCREF(Py_None); |
|---|
| 353 | n/a | _res = Py_None; |
|---|
| 354 | n/a | return _res; |
|---|
| 355 | n/a | } |
|---|
| 356 | n/a | |
|---|
| 357 | n/a | static PyObject *AEDesc_AEGetParamPtr(AEDescObject *_self, PyObject *_args) |
|---|
| 358 | n/a | { |
|---|
| 359 | n/a | PyObject *_res = NULL; |
|---|
| 360 | n/a | OSErr _err; |
|---|
| 361 | n/a | AEKeyword theAEKeyword; |
|---|
| 362 | n/a | DescType desiredType; |
|---|
| 363 | n/a | DescType typeCode; |
|---|
| 364 | n/a | char *dataPtr__out__; |
|---|
| 365 | n/a | long dataPtr__len__; |
|---|
| 366 | n/a | int dataPtr__in_len__; |
|---|
| 367 | n/a | #ifndef AEGetParamPtr |
|---|
| 368 | n/a | PyMac_PRECHECK(AEGetParamPtr); |
|---|
| 369 | n/a | #endif |
|---|
| 370 | n/a | if (!PyArg_ParseTuple(_args, "O&O&i", |
|---|
| 371 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 372 | n/a | PyMac_GetOSType, &desiredType, |
|---|
| 373 | n/a | &dataPtr__in_len__)) |
|---|
| 374 | n/a | return NULL; |
|---|
| 375 | n/a | if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) |
|---|
| 376 | n/a | { |
|---|
| 377 | n/a | PyErr_NoMemory(); |
|---|
| 378 | n/a | goto dataPtr__error__; |
|---|
| 379 | n/a | } |
|---|
| 380 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 381 | n/a | _err = AEGetParamPtr(&_self->ob_itself, |
|---|
| 382 | n/a | theAEKeyword, |
|---|
| 383 | n/a | desiredType, |
|---|
| 384 | n/a | &typeCode, |
|---|
| 385 | n/a | dataPtr__out__, dataPtr__len__, &dataPtr__len__); |
|---|
| 386 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 387 | n/a | _res = Py_BuildValue("O&s#", |
|---|
| 388 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 389 | n/a | dataPtr__out__, (int)dataPtr__len__); |
|---|
| 390 | n/a | free(dataPtr__out__); |
|---|
| 391 | n/a | dataPtr__error__: ; |
|---|
| 392 | n/a | return _res; |
|---|
| 393 | n/a | } |
|---|
| 394 | n/a | |
|---|
| 395 | n/a | static PyObject *AEDesc_AEGetParamDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 396 | n/a | { |
|---|
| 397 | n/a | PyObject *_res = NULL; |
|---|
| 398 | n/a | OSErr _err; |
|---|
| 399 | n/a | AEKeyword theAEKeyword; |
|---|
| 400 | n/a | DescType desiredType; |
|---|
| 401 | n/a | AEDesc result; |
|---|
| 402 | n/a | #ifndef AEGetParamDesc |
|---|
| 403 | n/a | PyMac_PRECHECK(AEGetParamDesc); |
|---|
| 404 | n/a | #endif |
|---|
| 405 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 406 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 407 | n/a | PyMac_GetOSType, &desiredType)) |
|---|
| 408 | n/a | return NULL; |
|---|
| 409 | n/a | _err = AEGetParamDesc(&_self->ob_itself, |
|---|
| 410 | n/a | theAEKeyword, |
|---|
| 411 | n/a | desiredType, |
|---|
| 412 | n/a | &result); |
|---|
| 413 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 414 | n/a | _res = Py_BuildValue("O&", |
|---|
| 415 | n/a | AEDesc_New, &result); |
|---|
| 416 | n/a | return _res; |
|---|
| 417 | n/a | } |
|---|
| 418 | n/a | |
|---|
| 419 | n/a | static PyObject *AEDesc_AESizeOfParam(AEDescObject *_self, PyObject *_args) |
|---|
| 420 | n/a | { |
|---|
| 421 | n/a | PyObject *_res = NULL; |
|---|
| 422 | n/a | OSErr _err; |
|---|
| 423 | n/a | AEKeyword theAEKeyword; |
|---|
| 424 | n/a | DescType typeCode; |
|---|
| 425 | n/a | Size dataSize; |
|---|
| 426 | n/a | #ifndef AESizeOfParam |
|---|
| 427 | n/a | PyMac_PRECHECK(AESizeOfParam); |
|---|
| 428 | n/a | #endif |
|---|
| 429 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 430 | n/a | PyMac_GetOSType, &theAEKeyword)) |
|---|
| 431 | n/a | return NULL; |
|---|
| 432 | n/a | _err = AESizeOfParam(&_self->ob_itself, |
|---|
| 433 | n/a | theAEKeyword, |
|---|
| 434 | n/a | &typeCode, |
|---|
| 435 | n/a | &dataSize); |
|---|
| 436 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 437 | n/a | _res = Py_BuildValue("O&l", |
|---|
| 438 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 439 | n/a | dataSize); |
|---|
| 440 | n/a | return _res; |
|---|
| 441 | n/a | } |
|---|
| 442 | n/a | |
|---|
| 443 | n/a | static PyObject *AEDesc_AEDeleteParam(AEDescObject *_self, PyObject *_args) |
|---|
| 444 | n/a | { |
|---|
| 445 | n/a | PyObject *_res = NULL; |
|---|
| 446 | n/a | OSErr _err; |
|---|
| 447 | n/a | AEKeyword theAEKeyword; |
|---|
| 448 | n/a | #ifndef AEDeleteParam |
|---|
| 449 | n/a | PyMac_PRECHECK(AEDeleteParam); |
|---|
| 450 | n/a | #endif |
|---|
| 451 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 452 | n/a | PyMac_GetOSType, &theAEKeyword)) |
|---|
| 453 | n/a | return NULL; |
|---|
| 454 | n/a | _err = AEDeleteParam(&_self->ob_itself, |
|---|
| 455 | n/a | theAEKeyword); |
|---|
| 456 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 457 | n/a | Py_INCREF(Py_None); |
|---|
| 458 | n/a | _res = Py_None; |
|---|
| 459 | n/a | return _res; |
|---|
| 460 | n/a | } |
|---|
| 461 | n/a | |
|---|
| 462 | n/a | static PyObject *AEDesc_AEGetAttributePtr(AEDescObject *_self, PyObject *_args) |
|---|
| 463 | n/a | { |
|---|
| 464 | n/a | PyObject *_res = NULL; |
|---|
| 465 | n/a | OSErr _err; |
|---|
| 466 | n/a | AEKeyword theAEKeyword; |
|---|
| 467 | n/a | DescType desiredType; |
|---|
| 468 | n/a | DescType typeCode; |
|---|
| 469 | n/a | char *dataPtr__out__; |
|---|
| 470 | n/a | long dataPtr__len__; |
|---|
| 471 | n/a | int dataPtr__in_len__; |
|---|
| 472 | n/a | #ifndef AEGetAttributePtr |
|---|
| 473 | n/a | PyMac_PRECHECK(AEGetAttributePtr); |
|---|
| 474 | n/a | #endif |
|---|
| 475 | n/a | if (!PyArg_ParseTuple(_args, "O&O&i", |
|---|
| 476 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 477 | n/a | PyMac_GetOSType, &desiredType, |
|---|
| 478 | n/a | &dataPtr__in_len__)) |
|---|
| 479 | n/a | return NULL; |
|---|
| 480 | n/a | if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) |
|---|
| 481 | n/a | { |
|---|
| 482 | n/a | PyErr_NoMemory(); |
|---|
| 483 | n/a | goto dataPtr__error__; |
|---|
| 484 | n/a | } |
|---|
| 485 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 486 | n/a | _err = AEGetAttributePtr(&_self->ob_itself, |
|---|
| 487 | n/a | theAEKeyword, |
|---|
| 488 | n/a | desiredType, |
|---|
| 489 | n/a | &typeCode, |
|---|
| 490 | n/a | dataPtr__out__, dataPtr__len__, &dataPtr__len__); |
|---|
| 491 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 492 | n/a | _res = Py_BuildValue("O&s#", |
|---|
| 493 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 494 | n/a | dataPtr__out__, (int)dataPtr__len__); |
|---|
| 495 | n/a | free(dataPtr__out__); |
|---|
| 496 | n/a | dataPtr__error__: ; |
|---|
| 497 | n/a | return _res; |
|---|
| 498 | n/a | } |
|---|
| 499 | n/a | |
|---|
| 500 | n/a | static PyObject *AEDesc_AEGetAttributeDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 501 | n/a | { |
|---|
| 502 | n/a | PyObject *_res = NULL; |
|---|
| 503 | n/a | OSErr _err; |
|---|
| 504 | n/a | AEKeyword theAEKeyword; |
|---|
| 505 | n/a | DescType desiredType; |
|---|
| 506 | n/a | AEDesc result; |
|---|
| 507 | n/a | #ifndef AEGetAttributeDesc |
|---|
| 508 | n/a | PyMac_PRECHECK(AEGetAttributeDesc); |
|---|
| 509 | n/a | #endif |
|---|
| 510 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 511 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 512 | n/a | PyMac_GetOSType, &desiredType)) |
|---|
| 513 | n/a | return NULL; |
|---|
| 514 | n/a | _err = AEGetAttributeDesc(&_self->ob_itself, |
|---|
| 515 | n/a | theAEKeyword, |
|---|
| 516 | n/a | desiredType, |
|---|
| 517 | n/a | &result); |
|---|
| 518 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 519 | n/a | _res = Py_BuildValue("O&", |
|---|
| 520 | n/a | AEDesc_New, &result); |
|---|
| 521 | n/a | return _res; |
|---|
| 522 | n/a | } |
|---|
| 523 | n/a | |
|---|
| 524 | n/a | static PyObject *AEDesc_AESizeOfAttribute(AEDescObject *_self, PyObject *_args) |
|---|
| 525 | n/a | { |
|---|
| 526 | n/a | PyObject *_res = NULL; |
|---|
| 527 | n/a | OSErr _err; |
|---|
| 528 | n/a | AEKeyword theAEKeyword; |
|---|
| 529 | n/a | DescType typeCode; |
|---|
| 530 | n/a | Size dataSize; |
|---|
| 531 | n/a | #ifndef AESizeOfAttribute |
|---|
| 532 | n/a | PyMac_PRECHECK(AESizeOfAttribute); |
|---|
| 533 | n/a | #endif |
|---|
| 534 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 535 | n/a | PyMac_GetOSType, &theAEKeyword)) |
|---|
| 536 | n/a | return NULL; |
|---|
| 537 | n/a | _err = AESizeOfAttribute(&_self->ob_itself, |
|---|
| 538 | n/a | theAEKeyword, |
|---|
| 539 | n/a | &typeCode, |
|---|
| 540 | n/a | &dataSize); |
|---|
| 541 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 542 | n/a | _res = Py_BuildValue("O&l", |
|---|
| 543 | n/a | PyMac_BuildOSType, typeCode, |
|---|
| 544 | n/a | dataSize); |
|---|
| 545 | n/a | return _res; |
|---|
| 546 | n/a | } |
|---|
| 547 | n/a | |
|---|
| 548 | n/a | static PyObject *AEDesc_AEPutAttributePtr(AEDescObject *_self, PyObject *_args) |
|---|
| 549 | n/a | { |
|---|
| 550 | n/a | PyObject *_res = NULL; |
|---|
| 551 | n/a | OSErr _err; |
|---|
| 552 | n/a | AEKeyword theAEKeyword; |
|---|
| 553 | n/a | DescType typeCode; |
|---|
| 554 | n/a | char *dataPtr__in__; |
|---|
| 555 | n/a | long dataPtr__len__; |
|---|
| 556 | n/a | int dataPtr__in_len__; |
|---|
| 557 | n/a | #ifndef AEPutAttributePtr |
|---|
| 558 | n/a | PyMac_PRECHECK(AEPutAttributePtr); |
|---|
| 559 | n/a | #endif |
|---|
| 560 | n/a | if (!PyArg_ParseTuple(_args, "O&O&s#", |
|---|
| 561 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 562 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 563 | n/a | &dataPtr__in__, &dataPtr__in_len__)) |
|---|
| 564 | n/a | return NULL; |
|---|
| 565 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 566 | n/a | _err = AEPutAttributePtr(&_self->ob_itself, |
|---|
| 567 | n/a | theAEKeyword, |
|---|
| 568 | n/a | typeCode, |
|---|
| 569 | n/a | dataPtr__in__, dataPtr__len__); |
|---|
| 570 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 571 | n/a | Py_INCREF(Py_None); |
|---|
| 572 | n/a | _res = Py_None; |
|---|
| 573 | n/a | return _res; |
|---|
| 574 | n/a | } |
|---|
| 575 | n/a | |
|---|
| 576 | n/a | static PyObject *AEDesc_AEPutAttributeDesc(AEDescObject *_self, PyObject *_args) |
|---|
| 577 | n/a | { |
|---|
| 578 | n/a | PyObject *_res = NULL; |
|---|
| 579 | n/a | OSErr _err; |
|---|
| 580 | n/a | AEKeyword theAEKeyword; |
|---|
| 581 | n/a | AEDesc theAEDesc; |
|---|
| 582 | n/a | #ifndef AEPutAttributeDesc |
|---|
| 583 | n/a | PyMac_PRECHECK(AEPutAttributeDesc); |
|---|
| 584 | n/a | #endif |
|---|
| 585 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 586 | n/a | PyMac_GetOSType, &theAEKeyword, |
|---|
| 587 | n/a | AEDesc_Convert, &theAEDesc)) |
|---|
| 588 | n/a | return NULL; |
|---|
| 589 | n/a | _err = AEPutAttributeDesc(&_self->ob_itself, |
|---|
| 590 | n/a | theAEKeyword, |
|---|
| 591 | n/a | &theAEDesc); |
|---|
| 592 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 593 | n/a | Py_INCREF(Py_None); |
|---|
| 594 | n/a | _res = Py_None; |
|---|
| 595 | n/a | return _res; |
|---|
| 596 | n/a | } |
|---|
| 597 | n/a | |
|---|
| 598 | n/a | static PyObject *AEDesc_AEGetDescDataSize(AEDescObject *_self, PyObject *_args) |
|---|
| 599 | n/a | { |
|---|
| 600 | n/a | PyObject *_res = NULL; |
|---|
| 601 | n/a | Size _rv; |
|---|
| 602 | n/a | #ifndef AEGetDescDataSize |
|---|
| 603 | n/a | PyMac_PRECHECK(AEGetDescDataSize); |
|---|
| 604 | n/a | #endif |
|---|
| 605 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 606 | n/a | return NULL; |
|---|
| 607 | n/a | _rv = AEGetDescDataSize(&_self->ob_itself); |
|---|
| 608 | n/a | _res = Py_BuildValue("l", |
|---|
| 609 | n/a | _rv); |
|---|
| 610 | n/a | return _res; |
|---|
| 611 | n/a | } |
|---|
| 612 | n/a | |
|---|
| 613 | n/a | static PyObject *AEDesc_AESend(AEDescObject *_self, PyObject *_args) |
|---|
| 614 | n/a | { |
|---|
| 615 | n/a | PyObject *_res = NULL; |
|---|
| 616 | n/a | OSErr _err; |
|---|
| 617 | n/a | AppleEvent reply; |
|---|
| 618 | n/a | AESendMode sendMode; |
|---|
| 619 | n/a | AESendPriority sendPriority; |
|---|
| 620 | n/a | long timeOutInTicks; |
|---|
| 621 | n/a | #ifndef AESend |
|---|
| 622 | n/a | PyMac_PRECHECK(AESend); |
|---|
| 623 | n/a | #endif |
|---|
| 624 | n/a | if (!PyArg_ParseTuple(_args, "lhl", |
|---|
| 625 | n/a | &sendMode, |
|---|
| 626 | n/a | &sendPriority, |
|---|
| 627 | n/a | &timeOutInTicks)) |
|---|
| 628 | n/a | return NULL; |
|---|
| 629 | n/a | _err = AESend(&_self->ob_itself, |
|---|
| 630 | n/a | &reply, |
|---|
| 631 | n/a | sendMode, |
|---|
| 632 | n/a | sendPriority, |
|---|
| 633 | n/a | timeOutInTicks, |
|---|
| 634 | n/a | upp_AEIdleProc, |
|---|
| 635 | n/a | (AEFilterUPP)0); |
|---|
| 636 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 637 | n/a | _res = Py_BuildValue("O&", |
|---|
| 638 | n/a | AEDesc_New, &reply); |
|---|
| 639 | n/a | return _res; |
|---|
| 640 | n/a | } |
|---|
| 641 | n/a | |
|---|
| 642 | n/a | static PyObject *AEDesc_AEResetTimer(AEDescObject *_self, PyObject *_args) |
|---|
| 643 | n/a | { |
|---|
| 644 | n/a | PyObject *_res = NULL; |
|---|
| 645 | n/a | OSErr _err; |
|---|
| 646 | n/a | #ifndef AEResetTimer |
|---|
| 647 | n/a | PyMac_PRECHECK(AEResetTimer); |
|---|
| 648 | n/a | #endif |
|---|
| 649 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 650 | n/a | return NULL; |
|---|
| 651 | n/a | _err = AEResetTimer(&_self->ob_itself); |
|---|
| 652 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 653 | n/a | Py_INCREF(Py_None); |
|---|
| 654 | n/a | _res = Py_None; |
|---|
| 655 | n/a | return _res; |
|---|
| 656 | n/a | } |
|---|
| 657 | n/a | |
|---|
| 658 | n/a | static PyObject *AEDesc_AESuspendTheCurrentEvent(AEDescObject *_self, PyObject *_args) |
|---|
| 659 | n/a | { |
|---|
| 660 | n/a | PyObject *_res = NULL; |
|---|
| 661 | n/a | OSErr _err; |
|---|
| 662 | n/a | #ifndef AESuspendTheCurrentEvent |
|---|
| 663 | n/a | PyMac_PRECHECK(AESuspendTheCurrentEvent); |
|---|
| 664 | n/a | #endif |
|---|
| 665 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 666 | n/a | return NULL; |
|---|
| 667 | n/a | _err = AESuspendTheCurrentEvent(&_self->ob_itself); |
|---|
| 668 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 669 | n/a | Py_INCREF(Py_None); |
|---|
| 670 | n/a | _res = Py_None; |
|---|
| 671 | n/a | return _res; |
|---|
| 672 | n/a | } |
|---|
| 673 | n/a | |
|---|
| 674 | n/a | static PyObject *AEDesc_AEResumeTheCurrentEvent(AEDescObject *_self, PyObject *_args) |
|---|
| 675 | n/a | { |
|---|
| 676 | n/a | PyObject *_res = NULL; |
|---|
| 677 | n/a | OSErr _err; |
|---|
| 678 | n/a | AppleEvent reply; |
|---|
| 679 | n/a | AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler; |
|---|
| 680 | n/a | PyObject *dispatcher; |
|---|
| 681 | n/a | #ifndef AEResumeTheCurrentEvent |
|---|
| 682 | n/a | PyMac_PRECHECK(AEResumeTheCurrentEvent); |
|---|
| 683 | n/a | #endif |
|---|
| 684 | n/a | if (!PyArg_ParseTuple(_args, "O&O", |
|---|
| 685 | n/a | AEDesc_Convert, &reply, |
|---|
| 686 | n/a | &dispatcher)) |
|---|
| 687 | n/a | return NULL; |
|---|
| 688 | n/a | _err = AEResumeTheCurrentEvent(&_self->ob_itself, |
|---|
| 689 | n/a | &reply, |
|---|
| 690 | n/a | dispatcher__proc__, |
|---|
| 691 | n/a | (SRefCon)dispatcher); |
|---|
| 692 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 693 | n/a | Py_INCREF(Py_None); |
|---|
| 694 | n/a | _res = Py_None; |
|---|
| 695 | n/a | Py_INCREF(dispatcher); /* XXX leak, but needed */ |
|---|
| 696 | n/a | return _res; |
|---|
| 697 | n/a | } |
|---|
| 698 | n/a | |
|---|
| 699 | n/a | static PyObject *AEDesc_AEGetTheCurrentEvent(AEDescObject *_self, PyObject *_args) |
|---|
| 700 | n/a | { |
|---|
| 701 | n/a | PyObject *_res = NULL; |
|---|
| 702 | n/a | OSErr _err; |
|---|
| 703 | n/a | #ifndef AEGetTheCurrentEvent |
|---|
| 704 | n/a | PyMac_PRECHECK(AEGetTheCurrentEvent); |
|---|
| 705 | n/a | #endif |
|---|
| 706 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 707 | n/a | return NULL; |
|---|
| 708 | n/a | _err = AEGetTheCurrentEvent(&_self->ob_itself); |
|---|
| 709 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 710 | n/a | Py_INCREF(Py_None); |
|---|
| 711 | n/a | _res = Py_None; |
|---|
| 712 | n/a | return _res; |
|---|
| 713 | n/a | } |
|---|
| 714 | n/a | |
|---|
| 715 | n/a | static PyObject *AEDesc_AESetTheCurrentEvent(AEDescObject *_self, PyObject *_args) |
|---|
| 716 | n/a | { |
|---|
| 717 | n/a | PyObject *_res = NULL; |
|---|
| 718 | n/a | OSErr _err; |
|---|
| 719 | n/a | #ifndef AESetTheCurrentEvent |
|---|
| 720 | n/a | PyMac_PRECHECK(AESetTheCurrentEvent); |
|---|
| 721 | n/a | #endif |
|---|
| 722 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 723 | n/a | return NULL; |
|---|
| 724 | n/a | _err = AESetTheCurrentEvent(&_self->ob_itself); |
|---|
| 725 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 726 | n/a | Py_INCREF(Py_None); |
|---|
| 727 | n/a | _res = Py_None; |
|---|
| 728 | n/a | return _res; |
|---|
| 729 | n/a | } |
|---|
| 730 | n/a | |
|---|
| 731 | n/a | static PyObject *AEDesc_AEResolve(AEDescObject *_self, PyObject *_args) |
|---|
| 732 | n/a | { |
|---|
| 733 | n/a | PyObject *_res = NULL; |
|---|
| 734 | n/a | OSErr _err; |
|---|
| 735 | n/a | short callbackFlags; |
|---|
| 736 | n/a | AEDesc theToken; |
|---|
| 737 | n/a | #ifndef AEResolve |
|---|
| 738 | n/a | PyMac_PRECHECK(AEResolve); |
|---|
| 739 | n/a | #endif |
|---|
| 740 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 741 | n/a | &callbackFlags)) |
|---|
| 742 | n/a | return NULL; |
|---|
| 743 | n/a | _err = AEResolve(&_self->ob_itself, |
|---|
| 744 | n/a | callbackFlags, |
|---|
| 745 | n/a | &theToken); |
|---|
| 746 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 747 | n/a | _res = Py_BuildValue("O&", |
|---|
| 748 | n/a | AEDesc_New, &theToken); |
|---|
| 749 | n/a | return _res; |
|---|
| 750 | n/a | } |
|---|
| 751 | n/a | |
|---|
| 752 | n/a | static PyObject *AEDesc_AutoDispose(AEDescObject *_self, PyObject *_args) |
|---|
| 753 | n/a | { |
|---|
| 754 | n/a | PyObject *_res = NULL; |
|---|
| 755 | n/a | |
|---|
| 756 | n/a | int onoff, old; |
|---|
| 757 | n/a | if (!PyArg_ParseTuple(_args, "i", &onoff)) |
|---|
| 758 | n/a | return NULL; |
|---|
| 759 | n/a | old = _self->ob_owned; |
|---|
| 760 | n/a | _self->ob_owned = onoff; |
|---|
| 761 | n/a | _res = Py_BuildValue("i", old); |
|---|
| 762 | n/a | return _res; |
|---|
| 763 | n/a | |
|---|
| 764 | n/a | } |
|---|
| 765 | n/a | |
|---|
| 766 | n/a | static PyMethodDef AEDesc_methods[] = { |
|---|
| 767 | n/a | {"AECoerceDesc", (PyCFunction)AEDesc_AECoerceDesc, 1, |
|---|
| 768 | n/a | PyDoc_STR("(DescType toType) -> (AEDesc result)")}, |
|---|
| 769 | n/a | {"AEDuplicateDesc", (PyCFunction)AEDesc_AEDuplicateDesc, 1, |
|---|
| 770 | n/a | PyDoc_STR("() -> (AEDesc result)")}, |
|---|
| 771 | n/a | {"AECountItems", (PyCFunction)AEDesc_AECountItems, 1, |
|---|
| 772 | n/a | PyDoc_STR("() -> (long theCount)")}, |
|---|
| 773 | n/a | {"AEPutPtr", (PyCFunction)AEDesc_AEPutPtr, 1, |
|---|
| 774 | n/a | PyDoc_STR("(long index, DescType typeCode, Buffer dataPtr) -> None")}, |
|---|
| 775 | n/a | {"AEPutDesc", (PyCFunction)AEDesc_AEPutDesc, 1, |
|---|
| 776 | n/a | PyDoc_STR("(long index, AEDesc theAEDesc) -> None")}, |
|---|
| 777 | n/a | {"AEGetNthPtr", (PyCFunction)AEDesc_AEGetNthPtr, 1, |
|---|
| 778 | n/a | PyDoc_STR("(long index, DescType desiredType, Buffer dataPtr) -> (AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr)")}, |
|---|
| 779 | n/a | {"AEGetNthDesc", (PyCFunction)AEDesc_AEGetNthDesc, 1, |
|---|
| 780 | n/a | PyDoc_STR("(long index, DescType desiredType) -> (AEKeyword theAEKeyword, AEDesc result)")}, |
|---|
| 781 | n/a | {"AESizeOfNthItem", (PyCFunction)AEDesc_AESizeOfNthItem, 1, |
|---|
| 782 | n/a | PyDoc_STR("(long index) -> (DescType typeCode, Size dataSize)")}, |
|---|
| 783 | n/a | {"AEDeleteItem", (PyCFunction)AEDesc_AEDeleteItem, 1, |
|---|
| 784 | n/a | PyDoc_STR("(long index) -> None")}, |
|---|
| 785 | n/a | {"AEPutParamPtr", (PyCFunction)AEDesc_AEPutParamPtr, 1, |
|---|
| 786 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None")}, |
|---|
| 787 | n/a | {"AEPutParamDesc", (PyCFunction)AEDesc_AEPutParamDesc, 1, |
|---|
| 788 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None")}, |
|---|
| 789 | n/a | {"AEGetParamPtr", (PyCFunction)AEDesc_AEGetParamPtr, 1, |
|---|
| 790 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)")}, |
|---|
| 791 | n/a | {"AEGetParamDesc", (PyCFunction)AEDesc_AEGetParamDesc, 1, |
|---|
| 792 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)")}, |
|---|
| 793 | n/a | {"AESizeOfParam", (PyCFunction)AEDesc_AESizeOfParam, 1, |
|---|
| 794 | n/a | PyDoc_STR("(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)")}, |
|---|
| 795 | n/a | {"AEDeleteParam", (PyCFunction)AEDesc_AEDeleteParam, 1, |
|---|
| 796 | n/a | PyDoc_STR("(AEKeyword theAEKeyword) -> None")}, |
|---|
| 797 | n/a | {"AEGetAttributePtr", (PyCFunction)AEDesc_AEGetAttributePtr, 1, |
|---|
| 798 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType, Buffer dataPtr) -> (DescType typeCode, Buffer dataPtr)")}, |
|---|
| 799 | n/a | {"AEGetAttributeDesc", (PyCFunction)AEDesc_AEGetAttributeDesc, 1, |
|---|
| 800 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType desiredType) -> (AEDesc result)")}, |
|---|
| 801 | n/a | {"AESizeOfAttribute", (PyCFunction)AEDesc_AESizeOfAttribute, 1, |
|---|
| 802 | n/a | PyDoc_STR("(AEKeyword theAEKeyword) -> (DescType typeCode, Size dataSize)")}, |
|---|
| 803 | n/a | {"AEPutAttributePtr", (PyCFunction)AEDesc_AEPutAttributePtr, 1, |
|---|
| 804 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None")}, |
|---|
| 805 | n/a | {"AEPutAttributeDesc", (PyCFunction)AEDesc_AEPutAttributeDesc, 1, |
|---|
| 806 | n/a | PyDoc_STR("(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None")}, |
|---|
| 807 | n/a | {"AEGetDescDataSize", (PyCFunction)AEDesc_AEGetDescDataSize, 1, |
|---|
| 808 | n/a | PyDoc_STR("() -> (Size _rv)")}, |
|---|
| 809 | n/a | {"AESend", (PyCFunction)AEDesc_AESend, 1, |
|---|
| 810 | n/a | PyDoc_STR("(AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks) -> (AppleEvent reply)")}, |
|---|
| 811 | n/a | {"AEResetTimer", (PyCFunction)AEDesc_AEResetTimer, 1, |
|---|
| 812 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 813 | n/a | {"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1, |
|---|
| 814 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 815 | n/a | {"AEResumeTheCurrentEvent", (PyCFunction)AEDesc_AEResumeTheCurrentEvent, 1, |
|---|
| 816 | n/a | PyDoc_STR("(AppleEvent reply, EventHandler dispatcher) -> None")}, |
|---|
| 817 | n/a | {"AEGetTheCurrentEvent", (PyCFunction)AEDesc_AEGetTheCurrentEvent, 1, |
|---|
| 818 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 819 | n/a | {"AESetTheCurrentEvent", (PyCFunction)AEDesc_AESetTheCurrentEvent, 1, |
|---|
| 820 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 821 | n/a | {"AEResolve", (PyCFunction)AEDesc_AEResolve, 1, |
|---|
| 822 | n/a | PyDoc_STR("(short callbackFlags) -> (AEDesc theToken)")}, |
|---|
| 823 | n/a | {"AutoDispose", (PyCFunction)AEDesc_AutoDispose, 1, |
|---|
| 824 | n/a | PyDoc_STR("(int)->int. Automatically AEDisposeDesc the object on Python object cleanup")}, |
|---|
| 825 | n/a | {NULL, NULL, 0} |
|---|
| 826 | n/a | }; |
|---|
| 827 | n/a | |
|---|
| 828 | n/a | static PyObject *AEDesc_get_type(AEDescObject *self, void *closure) |
|---|
| 829 | n/a | { |
|---|
| 830 | n/a | return PyMac_BuildOSType(self->ob_itself.descriptorType); |
|---|
| 831 | n/a | } |
|---|
| 832 | n/a | |
|---|
| 833 | n/a | #define AEDesc_set_type NULL |
|---|
| 834 | n/a | |
|---|
| 835 | n/a | static PyObject *AEDesc_get_data(AEDescObject *self, void *closure) |
|---|
| 836 | n/a | { |
|---|
| 837 | n/a | PyObject *res; |
|---|
| 838 | n/a | Size size; |
|---|
| 839 | n/a | char *ptr; |
|---|
| 840 | n/a | OSErr err; |
|---|
| 841 | n/a | |
|---|
| 842 | n/a | size = AEGetDescDataSize(&self->ob_itself); |
|---|
| 843 | n/a | if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL ) |
|---|
| 844 | n/a | return NULL; |
|---|
| 845 | n/a | if ( (ptr = PyString_AsString(res)) == NULL ) |
|---|
| 846 | n/a | return NULL; |
|---|
| 847 | n/a | if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 ) |
|---|
| 848 | n/a | return PyMac_Error(err); |
|---|
| 849 | n/a | return res; |
|---|
| 850 | n/a | } |
|---|
| 851 | n/a | |
|---|
| 852 | n/a | #define AEDesc_set_data NULL |
|---|
| 853 | n/a | |
|---|
| 854 | n/a | static PyGetSetDef AEDesc_getsetlist[] = { |
|---|
| 855 | n/a | {"type", (getter)AEDesc_get_type, (setter)AEDesc_set_type, "Type of this AEDesc"}, |
|---|
| 856 | n/a | {"data", (getter)AEDesc_get_data, (setter)AEDesc_set_data, "The raw data in this AEDesc"}, |
|---|
| 857 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 858 | n/a | }; |
|---|
| 859 | n/a | |
|---|
| 860 | n/a | |
|---|
| 861 | n/a | #define AEDesc_compare NULL |
|---|
| 862 | n/a | |
|---|
| 863 | n/a | #define AEDesc_repr NULL |
|---|
| 864 | n/a | |
|---|
| 865 | n/a | #define AEDesc_hash NULL |
|---|
| 866 | n/a | #define AEDesc_tp_init 0 |
|---|
| 867 | n/a | |
|---|
| 868 | n/a | #define AEDesc_tp_alloc PyType_GenericAlloc |
|---|
| 869 | n/a | |
|---|
| 870 | n/a | static PyObject *AEDesc_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 871 | n/a | { |
|---|
| 872 | n/a | PyObject *_self; |
|---|
| 873 | n/a | AEDesc itself; |
|---|
| 874 | n/a | char *kw[] = {"itself", 0}; |
|---|
| 875 | n/a | |
|---|
| 876 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, AEDesc_Convert, &itself)) return NULL; |
|---|
| 877 | n/a | if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 878 | n/a | ((AEDescObject *)_self)->ob_itself = itself; |
|---|
| 879 | n/a | return _self; |
|---|
| 880 | n/a | } |
|---|
| 881 | n/a | |
|---|
| 882 | n/a | #define AEDesc_tp_free PyObject_Del |
|---|
| 883 | n/a | |
|---|
| 884 | n/a | |
|---|
| 885 | n/a | PyTypeObject AEDesc_Type = { |
|---|
| 886 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 887 | n/a | 0, /*ob_size*/ |
|---|
| 888 | n/a | "_AE.AEDesc", /*tp_name*/ |
|---|
| 889 | n/a | sizeof(AEDescObject), /*tp_basicsize*/ |
|---|
| 890 | n/a | 0, /*tp_itemsize*/ |
|---|
| 891 | n/a | /* methods */ |
|---|
| 892 | n/a | (destructor) AEDesc_dealloc, /*tp_dealloc*/ |
|---|
| 893 | n/a | 0, /*tp_print*/ |
|---|
| 894 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 895 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 896 | n/a | (cmpfunc) AEDesc_compare, /*tp_compare*/ |
|---|
| 897 | n/a | (reprfunc) AEDesc_repr, /*tp_repr*/ |
|---|
| 898 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 899 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 900 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 901 | n/a | (hashfunc) AEDesc_hash, /*tp_hash*/ |
|---|
| 902 | n/a | 0, /*tp_call*/ |
|---|
| 903 | n/a | 0, /*tp_str*/ |
|---|
| 904 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 905 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 906 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 907 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 908 | n/a | 0, /*tp_doc*/ |
|---|
| 909 | n/a | 0, /*tp_traverse*/ |
|---|
| 910 | n/a | 0, /*tp_clear*/ |
|---|
| 911 | n/a | 0, /*tp_richcompare*/ |
|---|
| 912 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 913 | n/a | 0, /*tp_iter*/ |
|---|
| 914 | n/a | 0, /*tp_iternext*/ |
|---|
| 915 | n/a | AEDesc_methods, /* tp_methods */ |
|---|
| 916 | n/a | 0, /*tp_members*/ |
|---|
| 917 | n/a | AEDesc_getsetlist, /*tp_getset*/ |
|---|
| 918 | n/a | 0, /*tp_base*/ |
|---|
| 919 | n/a | 0, /*tp_dict*/ |
|---|
| 920 | n/a | 0, /*tp_descr_get*/ |
|---|
| 921 | n/a | 0, /*tp_descr_set*/ |
|---|
| 922 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 923 | n/a | AEDesc_tp_init, /* tp_init */ |
|---|
| 924 | n/a | AEDesc_tp_alloc, /* tp_alloc */ |
|---|
| 925 | n/a | AEDesc_tp_new, /* tp_new */ |
|---|
| 926 | n/a | AEDesc_tp_free, /* tp_free */ |
|---|
| 927 | n/a | }; |
|---|
| 928 | n/a | |
|---|
| 929 | n/a | /* --------------------- End object type AEDesc --------------------- */ |
|---|
| 930 | n/a | |
|---|
| 931 | n/a | |
|---|
| 932 | n/a | static PyObject *AE_AECoercePtr(PyObject *_self, PyObject *_args) |
|---|
| 933 | n/a | { |
|---|
| 934 | n/a | PyObject *_res = NULL; |
|---|
| 935 | n/a | OSErr _err; |
|---|
| 936 | n/a | DescType typeCode; |
|---|
| 937 | n/a | char *dataPtr__in__; |
|---|
| 938 | n/a | long dataPtr__len__; |
|---|
| 939 | n/a | int dataPtr__in_len__; |
|---|
| 940 | n/a | DescType toType; |
|---|
| 941 | n/a | AEDesc result; |
|---|
| 942 | n/a | #ifndef AECoercePtr |
|---|
| 943 | n/a | PyMac_PRECHECK(AECoercePtr); |
|---|
| 944 | n/a | #endif |
|---|
| 945 | n/a | if (!PyArg_ParseTuple(_args, "O&s#O&", |
|---|
| 946 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 947 | n/a | &dataPtr__in__, &dataPtr__in_len__, |
|---|
| 948 | n/a | PyMac_GetOSType, &toType)) |
|---|
| 949 | n/a | return NULL; |
|---|
| 950 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 951 | n/a | _err = AECoercePtr(typeCode, |
|---|
| 952 | n/a | dataPtr__in__, dataPtr__len__, |
|---|
| 953 | n/a | toType, |
|---|
| 954 | n/a | &result); |
|---|
| 955 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 956 | n/a | _res = Py_BuildValue("O&", |
|---|
| 957 | n/a | AEDesc_New, &result); |
|---|
| 958 | n/a | return _res; |
|---|
| 959 | n/a | } |
|---|
| 960 | n/a | |
|---|
| 961 | n/a | static PyObject *AE_AECreateDesc(PyObject *_self, PyObject *_args) |
|---|
| 962 | n/a | { |
|---|
| 963 | n/a | PyObject *_res = NULL; |
|---|
| 964 | n/a | OSErr _err; |
|---|
| 965 | n/a | DescType typeCode; |
|---|
| 966 | n/a | char *dataPtr__in__; |
|---|
| 967 | n/a | long dataPtr__len__; |
|---|
| 968 | n/a | int dataPtr__in_len__; |
|---|
| 969 | n/a | AEDesc result; |
|---|
| 970 | n/a | #ifndef AECreateDesc |
|---|
| 971 | n/a | PyMac_PRECHECK(AECreateDesc); |
|---|
| 972 | n/a | #endif |
|---|
| 973 | n/a | if (!PyArg_ParseTuple(_args, "O&s#", |
|---|
| 974 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 975 | n/a | &dataPtr__in__, &dataPtr__in_len__)) |
|---|
| 976 | n/a | return NULL; |
|---|
| 977 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 978 | n/a | _err = AECreateDesc(typeCode, |
|---|
| 979 | n/a | dataPtr__in__, dataPtr__len__, |
|---|
| 980 | n/a | &result); |
|---|
| 981 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 982 | n/a | _res = Py_BuildValue("O&", |
|---|
| 983 | n/a | AEDesc_New, &result); |
|---|
| 984 | n/a | return _res; |
|---|
| 985 | n/a | } |
|---|
| 986 | n/a | |
|---|
| 987 | n/a | static PyObject *AE_AECreateList(PyObject *_self, PyObject *_args) |
|---|
| 988 | n/a | { |
|---|
| 989 | n/a | PyObject *_res = NULL; |
|---|
| 990 | n/a | OSErr _err; |
|---|
| 991 | n/a | char *factoringPtr__in__; |
|---|
| 992 | n/a | long factoringPtr__len__; |
|---|
| 993 | n/a | int factoringPtr__in_len__; |
|---|
| 994 | n/a | Boolean isRecord; |
|---|
| 995 | n/a | AEDescList resultList; |
|---|
| 996 | n/a | #ifndef AECreateList |
|---|
| 997 | n/a | PyMac_PRECHECK(AECreateList); |
|---|
| 998 | n/a | #endif |
|---|
| 999 | n/a | if (!PyArg_ParseTuple(_args, "s#b", |
|---|
| 1000 | n/a | &factoringPtr__in__, &factoringPtr__in_len__, |
|---|
| 1001 | n/a | &isRecord)) |
|---|
| 1002 | n/a | return NULL; |
|---|
| 1003 | n/a | factoringPtr__len__ = factoringPtr__in_len__; |
|---|
| 1004 | n/a | _err = AECreateList(factoringPtr__in__, factoringPtr__len__, |
|---|
| 1005 | n/a | isRecord, |
|---|
| 1006 | n/a | &resultList); |
|---|
| 1007 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1008 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1009 | n/a | AEDesc_New, &resultList); |
|---|
| 1010 | n/a | return _res; |
|---|
| 1011 | n/a | } |
|---|
| 1012 | n/a | |
|---|
| 1013 | n/a | static PyObject *AE_AECreateAppleEvent(PyObject *_self, PyObject *_args) |
|---|
| 1014 | n/a | { |
|---|
| 1015 | n/a | PyObject *_res = NULL; |
|---|
| 1016 | n/a | OSErr _err; |
|---|
| 1017 | n/a | AEEventClass theAEEventClass; |
|---|
| 1018 | n/a | AEEventID theAEEventID; |
|---|
| 1019 | n/a | AEAddressDesc target; |
|---|
| 1020 | n/a | AEReturnID returnID; |
|---|
| 1021 | n/a | AETransactionID transactionID; |
|---|
| 1022 | n/a | AppleEvent result; |
|---|
| 1023 | n/a | #ifndef AECreateAppleEvent |
|---|
| 1024 | n/a | PyMac_PRECHECK(AECreateAppleEvent); |
|---|
| 1025 | n/a | #endif |
|---|
| 1026 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O&hl", |
|---|
| 1027 | n/a | PyMac_GetOSType, &theAEEventClass, |
|---|
| 1028 | n/a | PyMac_GetOSType, &theAEEventID, |
|---|
| 1029 | n/a | AEDesc_Convert, &target, |
|---|
| 1030 | n/a | &returnID, |
|---|
| 1031 | n/a | &transactionID)) |
|---|
| 1032 | n/a | return NULL; |
|---|
| 1033 | n/a | _err = AECreateAppleEvent(theAEEventClass, |
|---|
| 1034 | n/a | theAEEventID, |
|---|
| 1035 | n/a | &target, |
|---|
| 1036 | n/a | returnID, |
|---|
| 1037 | n/a | transactionID, |
|---|
| 1038 | n/a | &result); |
|---|
| 1039 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1040 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1041 | n/a | AEDesc_New, &result); |
|---|
| 1042 | n/a | return _res; |
|---|
| 1043 | n/a | } |
|---|
| 1044 | n/a | |
|---|
| 1045 | n/a | static PyObject *AE_AEReplaceDescData(PyObject *_self, PyObject *_args) |
|---|
| 1046 | n/a | { |
|---|
| 1047 | n/a | PyObject *_res = NULL; |
|---|
| 1048 | n/a | OSErr _err; |
|---|
| 1049 | n/a | DescType typeCode; |
|---|
| 1050 | n/a | char *dataPtr__in__; |
|---|
| 1051 | n/a | long dataPtr__len__; |
|---|
| 1052 | n/a | int dataPtr__in_len__; |
|---|
| 1053 | n/a | AEDesc theAEDesc; |
|---|
| 1054 | n/a | #ifndef AEReplaceDescData |
|---|
| 1055 | n/a | PyMac_PRECHECK(AEReplaceDescData); |
|---|
| 1056 | n/a | #endif |
|---|
| 1057 | n/a | if (!PyArg_ParseTuple(_args, "O&s#", |
|---|
| 1058 | n/a | PyMac_GetOSType, &typeCode, |
|---|
| 1059 | n/a | &dataPtr__in__, &dataPtr__in_len__)) |
|---|
| 1060 | n/a | return NULL; |
|---|
| 1061 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 1062 | n/a | _err = AEReplaceDescData(typeCode, |
|---|
| 1063 | n/a | dataPtr__in__, dataPtr__len__, |
|---|
| 1064 | n/a | &theAEDesc); |
|---|
| 1065 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1066 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1067 | n/a | AEDesc_New, &theAEDesc); |
|---|
| 1068 | n/a | return _res; |
|---|
| 1069 | n/a | } |
|---|
| 1070 | n/a | |
|---|
| 1071 | n/a | static PyObject *AE_AEProcessAppleEvent(PyObject *_self, PyObject *_args) |
|---|
| 1072 | n/a | { |
|---|
| 1073 | n/a | PyObject *_res = NULL; |
|---|
| 1074 | n/a | OSErr _err; |
|---|
| 1075 | n/a | EventRecord theEventRecord; |
|---|
| 1076 | n/a | #ifndef AEProcessAppleEvent |
|---|
| 1077 | n/a | PyMac_PRECHECK(AEProcessAppleEvent); |
|---|
| 1078 | n/a | #endif |
|---|
| 1079 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1080 | n/a | PyMac_GetEventRecord, &theEventRecord)) |
|---|
| 1081 | n/a | return NULL; |
|---|
| 1082 | n/a | _err = AEProcessAppleEvent(&theEventRecord); |
|---|
| 1083 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1084 | n/a | Py_INCREF(Py_None); |
|---|
| 1085 | n/a | _res = Py_None; |
|---|
| 1086 | n/a | return _res; |
|---|
| 1087 | n/a | } |
|---|
| 1088 | n/a | |
|---|
| 1089 | n/a | static PyObject *AE_AEGetInteractionAllowed(PyObject *_self, PyObject *_args) |
|---|
| 1090 | n/a | { |
|---|
| 1091 | n/a | PyObject *_res = NULL; |
|---|
| 1092 | n/a | OSErr _err; |
|---|
| 1093 | n/a | AEInteractAllowed level; |
|---|
| 1094 | n/a | #ifndef AEGetInteractionAllowed |
|---|
| 1095 | n/a | PyMac_PRECHECK(AEGetInteractionAllowed); |
|---|
| 1096 | n/a | #endif |
|---|
| 1097 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1098 | n/a | return NULL; |
|---|
| 1099 | n/a | _err = AEGetInteractionAllowed(&level); |
|---|
| 1100 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1101 | n/a | _res = Py_BuildValue("b", |
|---|
| 1102 | n/a | level); |
|---|
| 1103 | n/a | return _res; |
|---|
| 1104 | n/a | } |
|---|
| 1105 | n/a | |
|---|
| 1106 | n/a | static PyObject *AE_AESetInteractionAllowed(PyObject *_self, PyObject *_args) |
|---|
| 1107 | n/a | { |
|---|
| 1108 | n/a | PyObject *_res = NULL; |
|---|
| 1109 | n/a | OSErr _err; |
|---|
| 1110 | n/a | AEInteractAllowed level; |
|---|
| 1111 | n/a | #ifndef AESetInteractionAllowed |
|---|
| 1112 | n/a | PyMac_PRECHECK(AESetInteractionAllowed); |
|---|
| 1113 | n/a | #endif |
|---|
| 1114 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 1115 | n/a | &level)) |
|---|
| 1116 | n/a | return NULL; |
|---|
| 1117 | n/a | _err = AESetInteractionAllowed(level); |
|---|
| 1118 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1119 | n/a | Py_INCREF(Py_None); |
|---|
| 1120 | n/a | _res = Py_None; |
|---|
| 1121 | n/a | return _res; |
|---|
| 1122 | n/a | } |
|---|
| 1123 | n/a | |
|---|
| 1124 | n/a | static PyObject *AE_AEInteractWithUser(PyObject *_self, PyObject *_args) |
|---|
| 1125 | n/a | { |
|---|
| 1126 | n/a | PyObject *_res = NULL; |
|---|
| 1127 | n/a | OSErr _err; |
|---|
| 1128 | n/a | long timeOutInTicks; |
|---|
| 1129 | n/a | #ifndef AEInteractWithUser |
|---|
| 1130 | n/a | PyMac_PRECHECK(AEInteractWithUser); |
|---|
| 1131 | n/a | #endif |
|---|
| 1132 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 1133 | n/a | &timeOutInTicks)) |
|---|
| 1134 | n/a | return NULL; |
|---|
| 1135 | n/a | _err = AEInteractWithUser(timeOutInTicks, |
|---|
| 1136 | n/a | (NMRecPtr)0, |
|---|
| 1137 | n/a | upp_AEIdleProc); |
|---|
| 1138 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1139 | n/a | Py_INCREF(Py_None); |
|---|
| 1140 | n/a | _res = Py_None; |
|---|
| 1141 | n/a | return _res; |
|---|
| 1142 | n/a | } |
|---|
| 1143 | n/a | |
|---|
| 1144 | n/a | static PyObject *AE_AEInstallEventHandler(PyObject *_self, PyObject *_args) |
|---|
| 1145 | n/a | { |
|---|
| 1146 | n/a | PyObject *_res = NULL; |
|---|
| 1147 | n/a | OSErr _err; |
|---|
| 1148 | n/a | AEEventClass theAEEventClass; |
|---|
| 1149 | n/a | AEEventID theAEEventID; |
|---|
| 1150 | n/a | AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; |
|---|
| 1151 | n/a | PyObject *handler; |
|---|
| 1152 | n/a | #ifndef AEInstallEventHandler |
|---|
| 1153 | n/a | PyMac_PRECHECK(AEInstallEventHandler); |
|---|
| 1154 | n/a | #endif |
|---|
| 1155 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O", |
|---|
| 1156 | n/a | PyMac_GetOSType, &theAEEventClass, |
|---|
| 1157 | n/a | PyMac_GetOSType, &theAEEventID, |
|---|
| 1158 | n/a | &handler)) |
|---|
| 1159 | n/a | return NULL; |
|---|
| 1160 | n/a | _err = AEInstallEventHandler(theAEEventClass, |
|---|
| 1161 | n/a | theAEEventID, |
|---|
| 1162 | n/a | handler__proc__, (SRefCon)handler, |
|---|
| 1163 | n/a | 0); |
|---|
| 1164 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1165 | n/a | Py_INCREF(Py_None); |
|---|
| 1166 | n/a | _res = Py_None; |
|---|
| 1167 | n/a | Py_INCREF(handler); /* XXX leak, but needed */ |
|---|
| 1168 | n/a | return _res; |
|---|
| 1169 | n/a | } |
|---|
| 1170 | n/a | |
|---|
| 1171 | n/a | static PyObject *AE_AERemoveEventHandler(PyObject *_self, PyObject *_args) |
|---|
| 1172 | n/a | { |
|---|
| 1173 | n/a | PyObject *_res = NULL; |
|---|
| 1174 | n/a | OSErr _err; |
|---|
| 1175 | n/a | AEEventClass theAEEventClass; |
|---|
| 1176 | n/a | AEEventID theAEEventID; |
|---|
| 1177 | n/a | #ifndef AERemoveEventHandler |
|---|
| 1178 | n/a | PyMac_PRECHECK(AERemoveEventHandler); |
|---|
| 1179 | n/a | #endif |
|---|
| 1180 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 1181 | n/a | PyMac_GetOSType, &theAEEventClass, |
|---|
| 1182 | n/a | PyMac_GetOSType, &theAEEventID)) |
|---|
| 1183 | n/a | return NULL; |
|---|
| 1184 | n/a | _err = AERemoveEventHandler(theAEEventClass, |
|---|
| 1185 | n/a | theAEEventID, |
|---|
| 1186 | n/a | upp_GenericEventHandler, |
|---|
| 1187 | n/a | 0); |
|---|
| 1188 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1189 | n/a | Py_INCREF(Py_None); |
|---|
| 1190 | n/a | _res = Py_None; |
|---|
| 1191 | n/a | return _res; |
|---|
| 1192 | n/a | } |
|---|
| 1193 | n/a | |
|---|
| 1194 | n/a | static PyObject *AE_AEGetEventHandler(PyObject *_self, PyObject *_args) |
|---|
| 1195 | n/a | { |
|---|
| 1196 | n/a | PyObject *_res = NULL; |
|---|
| 1197 | n/a | OSErr _err; |
|---|
| 1198 | n/a | AEEventClass theAEEventClass; |
|---|
| 1199 | n/a | AEEventID theAEEventID; |
|---|
| 1200 | n/a | AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; |
|---|
| 1201 | n/a | PyObject *handler; |
|---|
| 1202 | n/a | #ifndef AEGetEventHandler |
|---|
| 1203 | n/a | PyMac_PRECHECK(AEGetEventHandler); |
|---|
| 1204 | n/a | #endif |
|---|
| 1205 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 1206 | n/a | PyMac_GetOSType, &theAEEventClass, |
|---|
| 1207 | n/a | PyMac_GetOSType, &theAEEventID)) |
|---|
| 1208 | n/a | return NULL; |
|---|
| 1209 | n/a | _err = AEGetEventHandler(theAEEventClass, |
|---|
| 1210 | n/a | theAEEventID, |
|---|
| 1211 | n/a | &handler__proc__, (SRefCon *)&handler, |
|---|
| 1212 | n/a | 0); |
|---|
| 1213 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1214 | n/a | _res = Py_BuildValue("O", |
|---|
| 1215 | n/a | handler); |
|---|
| 1216 | n/a | Py_INCREF(handler); /* XXX leak, but needed */ |
|---|
| 1217 | n/a | return _res; |
|---|
| 1218 | n/a | } |
|---|
| 1219 | n/a | |
|---|
| 1220 | n/a | static PyObject *AE_AEInstallSpecialHandler(PyObject *_self, PyObject *_args) |
|---|
| 1221 | n/a | { |
|---|
| 1222 | n/a | PyObject *_res = NULL; |
|---|
| 1223 | n/a | OSErr _err; |
|---|
| 1224 | n/a | AEKeyword functionClass; |
|---|
| 1225 | n/a | #ifndef AEInstallSpecialHandler |
|---|
| 1226 | n/a | PyMac_PRECHECK(AEInstallSpecialHandler); |
|---|
| 1227 | n/a | #endif |
|---|
| 1228 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1229 | n/a | PyMac_GetOSType, &functionClass)) |
|---|
| 1230 | n/a | return NULL; |
|---|
| 1231 | n/a | _err = AEInstallSpecialHandler(functionClass, |
|---|
| 1232 | n/a | upp_GenericEventHandler, |
|---|
| 1233 | n/a | 0); |
|---|
| 1234 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1235 | n/a | Py_INCREF(Py_None); |
|---|
| 1236 | n/a | _res = Py_None; |
|---|
| 1237 | n/a | return _res; |
|---|
| 1238 | n/a | } |
|---|
| 1239 | n/a | |
|---|
| 1240 | n/a | static PyObject *AE_AERemoveSpecialHandler(PyObject *_self, PyObject *_args) |
|---|
| 1241 | n/a | { |
|---|
| 1242 | n/a | PyObject *_res = NULL; |
|---|
| 1243 | n/a | OSErr _err; |
|---|
| 1244 | n/a | AEKeyword functionClass; |
|---|
| 1245 | n/a | #ifndef AERemoveSpecialHandler |
|---|
| 1246 | n/a | PyMac_PRECHECK(AERemoveSpecialHandler); |
|---|
| 1247 | n/a | #endif |
|---|
| 1248 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1249 | n/a | PyMac_GetOSType, &functionClass)) |
|---|
| 1250 | n/a | return NULL; |
|---|
| 1251 | n/a | _err = AERemoveSpecialHandler(functionClass, |
|---|
| 1252 | n/a | upp_GenericEventHandler, |
|---|
| 1253 | n/a | 0); |
|---|
| 1254 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1255 | n/a | Py_INCREF(Py_None); |
|---|
| 1256 | n/a | _res = Py_None; |
|---|
| 1257 | n/a | return _res; |
|---|
| 1258 | n/a | } |
|---|
| 1259 | n/a | |
|---|
| 1260 | n/a | static PyObject *AE_AEManagerInfo(PyObject *_self, PyObject *_args) |
|---|
| 1261 | n/a | { |
|---|
| 1262 | n/a | PyObject *_res = NULL; |
|---|
| 1263 | n/a | OSErr _err; |
|---|
| 1264 | n/a | AEKeyword keyWord; |
|---|
| 1265 | n/a | long result; |
|---|
| 1266 | n/a | #ifndef AEManagerInfo |
|---|
| 1267 | n/a | PyMac_PRECHECK(AEManagerInfo); |
|---|
| 1268 | n/a | #endif |
|---|
| 1269 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1270 | n/a | PyMac_GetOSType, &keyWord)) |
|---|
| 1271 | n/a | return NULL; |
|---|
| 1272 | n/a | _err = AEManagerInfo(keyWord, |
|---|
| 1273 | n/a | &result); |
|---|
| 1274 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1275 | n/a | _res = Py_BuildValue("l", |
|---|
| 1276 | n/a | result); |
|---|
| 1277 | n/a | return _res; |
|---|
| 1278 | n/a | } |
|---|
| 1279 | n/a | |
|---|
| 1280 | n/a | static PyObject *AE_AEObjectInit(PyObject *_self, PyObject *_args) |
|---|
| 1281 | n/a | { |
|---|
| 1282 | n/a | PyObject *_res = NULL; |
|---|
| 1283 | n/a | OSErr _err; |
|---|
| 1284 | n/a | #ifndef AEObjectInit |
|---|
| 1285 | n/a | PyMac_PRECHECK(AEObjectInit); |
|---|
| 1286 | n/a | #endif |
|---|
| 1287 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1288 | n/a | return NULL; |
|---|
| 1289 | n/a | _err = AEObjectInit(); |
|---|
| 1290 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1291 | n/a | Py_INCREF(Py_None); |
|---|
| 1292 | n/a | _res = Py_None; |
|---|
| 1293 | n/a | return _res; |
|---|
| 1294 | n/a | } |
|---|
| 1295 | n/a | |
|---|
| 1296 | n/a | static PyObject *AE_AEDisposeToken(PyObject *_self, PyObject *_args) |
|---|
| 1297 | n/a | { |
|---|
| 1298 | n/a | PyObject *_res = NULL; |
|---|
| 1299 | n/a | OSErr _err; |
|---|
| 1300 | n/a | AEDesc theToken; |
|---|
| 1301 | n/a | #ifndef AEDisposeToken |
|---|
| 1302 | n/a | PyMac_PRECHECK(AEDisposeToken); |
|---|
| 1303 | n/a | #endif |
|---|
| 1304 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1305 | n/a | return NULL; |
|---|
| 1306 | n/a | _err = AEDisposeToken(&theToken); |
|---|
| 1307 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1308 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1309 | n/a | AEDesc_New, &theToken); |
|---|
| 1310 | n/a | return _res; |
|---|
| 1311 | n/a | } |
|---|
| 1312 | n/a | |
|---|
| 1313 | n/a | static PyObject *AE_AECallObjectAccessor(PyObject *_self, PyObject *_args) |
|---|
| 1314 | n/a | { |
|---|
| 1315 | n/a | PyObject *_res = NULL; |
|---|
| 1316 | n/a | OSErr _err; |
|---|
| 1317 | n/a | DescType desiredClass; |
|---|
| 1318 | n/a | AEDesc containerToken; |
|---|
| 1319 | n/a | DescType containerClass; |
|---|
| 1320 | n/a | DescType keyForm; |
|---|
| 1321 | n/a | AEDesc keyData; |
|---|
| 1322 | n/a | AEDesc token; |
|---|
| 1323 | n/a | #ifndef AECallObjectAccessor |
|---|
| 1324 | n/a | PyMac_PRECHECK(AECallObjectAccessor); |
|---|
| 1325 | n/a | #endif |
|---|
| 1326 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", |
|---|
| 1327 | n/a | PyMac_GetOSType, &desiredClass, |
|---|
| 1328 | n/a | AEDesc_Convert, &containerToken, |
|---|
| 1329 | n/a | PyMac_GetOSType, &containerClass, |
|---|
| 1330 | n/a | PyMac_GetOSType, &keyForm, |
|---|
| 1331 | n/a | AEDesc_Convert, &keyData)) |
|---|
| 1332 | n/a | return NULL; |
|---|
| 1333 | n/a | _err = AECallObjectAccessor(desiredClass, |
|---|
| 1334 | n/a | &containerToken, |
|---|
| 1335 | n/a | containerClass, |
|---|
| 1336 | n/a | keyForm, |
|---|
| 1337 | n/a | &keyData, |
|---|
| 1338 | n/a | &token); |
|---|
| 1339 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1340 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1341 | n/a | AEDesc_New, &token); |
|---|
| 1342 | n/a | return _res; |
|---|
| 1343 | n/a | } |
|---|
| 1344 | n/a | |
|---|
| 1345 | n/a | static PyMethodDef AE_methods[] = { |
|---|
| 1346 | n/a | {"AECoercePtr", (PyCFunction)AE_AECoercePtr, 1, |
|---|
| 1347 | n/a | PyDoc_STR("(DescType typeCode, Buffer dataPtr, DescType toType) -> (AEDesc result)")}, |
|---|
| 1348 | n/a | {"AECreateDesc", (PyCFunction)AE_AECreateDesc, 1, |
|---|
| 1349 | n/a | PyDoc_STR("(DescType typeCode, Buffer dataPtr) -> (AEDesc result)")}, |
|---|
| 1350 | n/a | {"AECreateList", (PyCFunction)AE_AECreateList, 1, |
|---|
| 1351 | n/a | PyDoc_STR("(Buffer factoringPtr, Boolean isRecord) -> (AEDescList resultList)")}, |
|---|
| 1352 | n/a | {"AECreateAppleEvent", (PyCFunction)AE_AECreateAppleEvent, 1, |
|---|
| 1353 | n/a | PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID, AEAddressDesc target, AEReturnID returnID, AETransactionID transactionID) -> (AppleEvent result)")}, |
|---|
| 1354 | n/a | {"AEReplaceDescData", (PyCFunction)AE_AEReplaceDescData, 1, |
|---|
| 1355 | n/a | PyDoc_STR("(DescType typeCode, Buffer dataPtr) -> (AEDesc theAEDesc)")}, |
|---|
| 1356 | n/a | {"AEProcessAppleEvent", (PyCFunction)AE_AEProcessAppleEvent, 1, |
|---|
| 1357 | n/a | PyDoc_STR("(EventRecord theEventRecord) -> None")}, |
|---|
| 1358 | n/a | {"AEGetInteractionAllowed", (PyCFunction)AE_AEGetInteractionAllowed, 1, |
|---|
| 1359 | n/a | PyDoc_STR("() -> (AEInteractAllowed level)")}, |
|---|
| 1360 | n/a | {"AESetInteractionAllowed", (PyCFunction)AE_AESetInteractionAllowed, 1, |
|---|
| 1361 | n/a | PyDoc_STR("(AEInteractAllowed level) -> None")}, |
|---|
| 1362 | n/a | {"AEInteractWithUser", (PyCFunction)AE_AEInteractWithUser, 1, |
|---|
| 1363 | n/a | PyDoc_STR("(long timeOutInTicks) -> None")}, |
|---|
| 1364 | n/a | {"AEInstallEventHandler", (PyCFunction)AE_AEInstallEventHandler, 1, |
|---|
| 1365 | n/a | PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID, EventHandler handler) -> None")}, |
|---|
| 1366 | n/a | {"AERemoveEventHandler", (PyCFunction)AE_AERemoveEventHandler, 1, |
|---|
| 1367 | n/a | PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None")}, |
|---|
| 1368 | n/a | {"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1, |
|---|
| 1369 | n/a | PyDoc_STR("(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)")}, |
|---|
| 1370 | n/a | {"AEInstallSpecialHandler", (PyCFunction)AE_AEInstallSpecialHandler, 1, |
|---|
| 1371 | n/a | PyDoc_STR("(AEKeyword functionClass) -> None")}, |
|---|
| 1372 | n/a | {"AERemoveSpecialHandler", (PyCFunction)AE_AERemoveSpecialHandler, 1, |
|---|
| 1373 | n/a | PyDoc_STR("(AEKeyword functionClass) -> None")}, |
|---|
| 1374 | n/a | {"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1, |
|---|
| 1375 | n/a | PyDoc_STR("(AEKeyword keyWord) -> (long result)")}, |
|---|
| 1376 | n/a | {"AEObjectInit", (PyCFunction)AE_AEObjectInit, 1, |
|---|
| 1377 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 1378 | n/a | {"AEDisposeToken", (PyCFunction)AE_AEDisposeToken, 1, |
|---|
| 1379 | n/a | PyDoc_STR("() -> (AEDesc theToken)")}, |
|---|
| 1380 | n/a | {"AECallObjectAccessor", (PyCFunction)AE_AECallObjectAccessor, 1, |
|---|
| 1381 | n/a | PyDoc_STR("(DescType desiredClass, AEDesc containerToken, DescType containerClass, DescType keyForm, AEDesc keyData) -> (AEDesc token)")}, |
|---|
| 1382 | n/a | {NULL, NULL, 0} |
|---|
| 1383 | n/a | }; |
|---|
| 1384 | n/a | |
|---|
| 1385 | n/a | |
|---|
| 1386 | n/a | |
|---|
| 1387 | n/a | static pascal OSErr |
|---|
| 1388 | n/a | GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) |
|---|
| 1389 | n/a | { |
|---|
| 1390 | n/a | PyObject *handler = (PyObject *)refcon; |
|---|
| 1391 | n/a | AEDescObject *requestObject, *replyObject; |
|---|
| 1392 | n/a | PyObject *args, *res; |
|---|
| 1393 | n/a | if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) { |
|---|
| 1394 | n/a | return -1; |
|---|
| 1395 | n/a | } |
|---|
| 1396 | n/a | if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { |
|---|
| 1397 | n/a | Py_DECREF(requestObject); |
|---|
| 1398 | n/a | return -1; |
|---|
| 1399 | n/a | } |
|---|
| 1400 | n/a | if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { |
|---|
| 1401 | n/a | Py_DECREF(requestObject); |
|---|
| 1402 | n/a | Py_DECREF(replyObject); |
|---|
| 1403 | n/a | return -1; |
|---|
| 1404 | n/a | } |
|---|
| 1405 | n/a | res = PyEval_CallObject(handler, args); |
|---|
| 1406 | n/a | requestObject->ob_itself.descriptorType = 'null'; |
|---|
| 1407 | n/a | requestObject->ob_itself.dataHandle = NULL; |
|---|
| 1408 | n/a | replyObject->ob_itself.descriptorType = 'null'; |
|---|
| 1409 | n/a | replyObject->ob_itself.dataHandle = NULL; |
|---|
| 1410 | n/a | Py_DECREF(args); |
|---|
| 1411 | n/a | if (res == NULL) { |
|---|
| 1412 | n/a | PySys_WriteStderr("Exception in AE event handler function\n"); |
|---|
| 1413 | n/a | PyErr_Print(); |
|---|
| 1414 | n/a | return -1; |
|---|
| 1415 | n/a | } |
|---|
| 1416 | n/a | Py_DECREF(res); |
|---|
| 1417 | n/a | return noErr; |
|---|
| 1418 | n/a | } |
|---|
| 1419 | n/a | |
|---|
| 1420 | n/a | PyObject *AEDesc_NewBorrowed(AEDesc *itself) |
|---|
| 1421 | n/a | { |
|---|
| 1422 | n/a | PyObject *it; |
|---|
| 1423 | n/a | |
|---|
| 1424 | n/a | it = AEDesc_New(itself); |
|---|
| 1425 | n/a | if (it) |
|---|
| 1426 | n/a | ((AEDescObject *)it)->ob_owned = 0; |
|---|
| 1427 | n/a | return (PyObject *)it; |
|---|
| 1428 | n/a | } |
|---|
| 1429 | n/a | |
|---|
| 1430 | n/a | |
|---|
| 1431 | n/a | |
|---|
| 1432 | n/a | void init_AE(void) |
|---|
| 1433 | n/a | { |
|---|
| 1434 | n/a | PyObject *m; |
|---|
| 1435 | n/a | PyObject *d; |
|---|
| 1436 | n/a | |
|---|
| 1437 | n/a | upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); |
|---|
| 1438 | n/a | upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); |
|---|
| 1439 | n/a | PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); |
|---|
| 1440 | n/a | PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); |
|---|
| 1441 | n/a | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); |
|---|
| 1442 | n/a | |
|---|
| 1443 | n/a | m = Py_InitModule("_AE", AE_methods); |
|---|
| 1444 | n/a | d = PyModule_GetDict(m); |
|---|
| 1445 | n/a | AE_Error = PyMac_GetOSErrException(); |
|---|
| 1446 | n/a | if (AE_Error == NULL || |
|---|
| 1447 | n/a | PyDict_SetItemString(d, "Error", AE_Error) != 0) |
|---|
| 1448 | n/a | return; |
|---|
| 1449 | n/a | AEDesc_Type.ob_type = &PyType_Type; |
|---|
| 1450 | n/a | if (PyType_Ready(&AEDesc_Type) < 0) return; |
|---|
| 1451 | n/a | Py_INCREF(&AEDesc_Type); |
|---|
| 1452 | n/a | PyModule_AddObject(m, "AEDesc", (PyObject *)&AEDesc_Type); |
|---|
| 1453 | n/a | /* Backward-compatible name */ |
|---|
| 1454 | n/a | Py_INCREF(&AEDesc_Type); |
|---|
| 1455 | n/a | PyModule_AddObject(m, "AEDescType", (PyObject *)&AEDesc_Type); |
|---|
| 1456 | n/a | } |
|---|
| 1457 | n/a | |
|---|
| 1458 | n/a | /* ========================= End module _AE ========================= */ |
|---|
| 1459 | n/a | |
|---|