Changeset 391 for python/trunk/Mac/Modules/carbonevt
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Mac/Modules/carbonevt/_CarbonEvtmodule.c
r2 r391 10 10 /* Macro to test whether a weak-loaded CFM function exists */ 11 11 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ 12 13 14 12 PyErr_SetString(PyExc_NotImplementedError, \ 13 "Not available in this shared library/OS version"); \ 14 return NULL; \ 15 15 }} while(0) 16 16 … … 28 28 29 29 /********** EventTypeSpec *******/ 30 static PyObject*31 EventTypeSpec_New(EventTypeSpec *in)32 {33 return Py_BuildValue("ll", in->eventClass, in->eventKind);34 }35 36 30 static int 37 31 EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) 38 32 { 39 40 41 42 43 33 if (PyArg_Parse(v, "(O&l)", 34 PyMac_GetOSType, &(out->eventClass), 35 &(out->eventKind))) 36 return 1; 37 return 0; 44 38 } 45 39 … … 52 46 HIPoint_New(HIPoint *in) 53 47 { 54 48 return Py_BuildValue("ff", in->x, in->y); 55 49 } 56 50 … … 58 52 HIPoint_Convert(PyObject *v, HIPoint *out) 59 53 { 60 61 62 54 if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) 55 return 1; 56 return NULL; 63 57 } 64 58 #endif … … 67 61 68 62 /********** EventHotKeyID *******/ 69 70 static PyObject*71 EventHotKeyID_New(EventHotKeyID *in)72 {73 return Py_BuildValue("ll", in->signature, in->id);74 }75 63 76 64 static int 77 65 EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out) 78 66 { 79 80 81 67 if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) 68 return 1; 69 return 0; 82 70 } 83 71 … … 90 78 static pascal OSStatus 91 79 myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) { 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 80 PyObject *retValue; 81 int status; 82 83 retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", 84 EventHandlerCallRef_New, handlerRef, 85 EventRef_New, event); 86 if (retValue == NULL) { 87 PySys_WriteStderr("Error in event handler callback:\n"); 88 PyErr_Print(); /* this also clears the error */ 89 status = noErr; /* complain? how? */ 90 } else { 91 if (retValue == Py_None) 92 status = noErr; 93 else if (PyInt_Check(retValue)) { 94 status = PyInt_AsLong(retValue); 95 } else 96 status = noErr; /* wrong object type, complain? */ 97 Py_DECREF(retValue); 98 } 99 100 return status; 113 101 } 114 102 … … 125 113 126 114 typedef struct EventRefObject { 127 128 115 PyObject_HEAD 116 EventRef ob_itself; 129 117 } EventRefObject; 130 118 131 119 PyObject *EventRef_New(EventRef itself) 132 120 { 133 134 135 136 137 121 EventRefObject *it; 122 it = PyObject_NEW(EventRefObject, &EventRef_Type); 123 if (it == NULL) return NULL; 124 it->ob_itself = itself; 125 return (PyObject *)it; 138 126 } 139 127 140 128 int EventRef_Convert(PyObject *v, EventRef *p_itself) 141 129 { 142 143 144 145 146 147 148 130 if (!EventRef_Check(v)) 131 { 132 PyErr_SetString(PyExc_TypeError, "EventRef required"); 133 return 0; 134 } 135 *p_itself = ((EventRefObject *)v)->ob_itself; 136 return 1; 149 137 } 150 138 151 139 static void EventRef_dealloc(EventRefObject *self) 152 140 { 153 154 141 /* Cleanup of self->ob_itself goes here */ 142 self->ob_type->tp_free((PyObject *)self); 155 143 } 156 144 157 145 static PyObject *EventRef_RetainEvent(EventRefObject *_self, PyObject *_args) 158 146 { 159 160 161 162 163 164 165 166 147 PyObject *_res = NULL; 148 EventRef _rv; 149 if (!PyArg_ParseTuple(_args, "")) 150 return NULL; 151 _rv = RetainEvent(_self->ob_itself); 152 _res = Py_BuildValue("O&", 153 EventRef_New, _rv); 154 return _res; 167 155 } 168 156 169 157 static PyObject *EventRef_GetEventRetainCount(EventRefObject *_self, PyObject *_args) 170 158 { 171 172 173 174 175 176 177 178 159 PyObject *_res = NULL; 160 UInt32 _rv; 161 if (!PyArg_ParseTuple(_args, "")) 162 return NULL; 163 _rv = GetEventRetainCount(_self->ob_itself); 164 _res = Py_BuildValue("l", 165 _rv); 166 return _res; 179 167 } 180 168 181 169 static PyObject *EventRef_ReleaseEvent(EventRefObject *_self, PyObject *_args) 182 170 { 183 184 185 186 187 188 189 171 PyObject *_res = NULL; 172 if (!PyArg_ParseTuple(_args, "")) 173 return NULL; 174 ReleaseEvent(_self->ob_itself); 175 Py_INCREF(Py_None); 176 _res = Py_None; 177 return _res; 190 178 } 191 179 192 180 static PyObject *EventRef_SetEventParameter(EventRefObject *_self, PyObject *_args) 193 181 { 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 182 PyObject *_res = NULL; 183 OSStatus _err; 184 OSType inName; 185 OSType inType; 186 char *inDataPtr__in__; 187 long inDataPtr__len__; 188 int inDataPtr__in_len__; 189 if (!PyArg_ParseTuple(_args, "O&O&s#", 190 PyMac_GetOSType, &inName, 191 PyMac_GetOSType, &inType, 192 &inDataPtr__in__, &inDataPtr__in_len__)) 193 return NULL; 194 inDataPtr__len__ = inDataPtr__in_len__; 195 _err = SetEventParameter(_self->ob_itself, 196 inName, 197 inType, 198 inDataPtr__len__, inDataPtr__in__); 199 if (_err != noErr) return PyMac_Error(_err); 200 Py_INCREF(Py_None); 201 _res = Py_None; 202 return _res; 215 203 } 216 204 217 205 static PyObject *EventRef_GetEventClass(EventRefObject *_self, PyObject *_args) 218 206 { 219 220 221 222 223 224 225 226 207 PyObject *_res = NULL; 208 UInt32 _rv; 209 if (!PyArg_ParseTuple(_args, "")) 210 return NULL; 211 _rv = GetEventClass(_self->ob_itself); 212 _res = Py_BuildValue("l", 213 _rv); 214 return _res; 227 215 } 228 216 229 217 static PyObject *EventRef_GetEventKind(EventRefObject *_self, PyObject *_args) 230 218 { 231 232 233 234 235 236 237 238 219 PyObject *_res = NULL; 220 UInt32 _rv; 221 if (!PyArg_ParseTuple(_args, "")) 222 return NULL; 223 _rv = GetEventKind(_self->ob_itself); 224 _res = Py_BuildValue("l", 225 _rv); 226 return _res; 239 227 } 240 228 241 229 static PyObject *EventRef_GetEventTime(EventRefObject *_self, PyObject *_args) 242 230 { 243 244 245 246 247 248 249 250 231 PyObject *_res = NULL; 232 double _rv; 233 if (!PyArg_ParseTuple(_args, "")) 234 return NULL; 235 _rv = GetEventTime(_self->ob_itself); 236 _res = Py_BuildValue("d", 237 _rv); 238 return _res; 251 239 } 252 240 253 241 static PyObject *EventRef_SetEventTime(EventRefObject *_self, PyObject *_args) 254 242 { 255 256 257 258 259 260 261 262 263 264 265 266 243 PyObject *_res = NULL; 244 OSStatus _err; 245 double inTime; 246 if (!PyArg_ParseTuple(_args, "d", 247 &inTime)) 248 return NULL; 249 _err = SetEventTime(_self->ob_itself, 250 inTime); 251 if (_err != noErr) return PyMac_Error(_err); 252 Py_INCREF(Py_None); 253 _res = Py_None; 254 return _res; 267 255 } 268 256 269 257 static PyObject *EventRef_IsUserCancelEventRef(EventRefObject *_self, PyObject *_args) 270 258 { 271 272 273 274 275 276 277 278 259 PyObject *_res = NULL; 260 Boolean _rv; 261 if (!PyArg_ParseTuple(_args, "")) 262 return NULL; 263 _rv = IsUserCancelEventRef(_self->ob_itself); 264 _res = Py_BuildValue("b", 265 _rv); 266 return _res; 279 267 } 280 268 281 269 static PyObject *EventRef_ConvertEventRefToEventRecord(EventRefObject *_self, PyObject *_args) 282 270 { 283 284 285 286 287 288 289 290 291 292 293 271 PyObject *_res = NULL; 272 Boolean _rv; 273 EventRecord outEvent; 274 if (!PyArg_ParseTuple(_args, "")) 275 return NULL; 276 _rv = ConvertEventRefToEventRecord(_self->ob_itself, 277 &outEvent); 278 _res = Py_BuildValue("bO&", 279 _rv, 280 PyMac_BuildEventRecord, &outEvent); 281 return _res; 294 282 } 295 283 296 284 static PyObject *EventRef_IsEventInMask(EventRefObject *_self, PyObject *_args) 297 285 { 298 299 300 301 302 303 304 305 306 307 308 286 PyObject *_res = NULL; 287 Boolean _rv; 288 UInt16 inMask; 289 if (!PyArg_ParseTuple(_args, "H", 290 &inMask)) 291 return NULL; 292 _rv = IsEventInMask(_self->ob_itself, 293 inMask); 294 _res = Py_BuildValue("b", 295 _rv); 296 return _res; 309 297 } 310 298 311 299 static PyObject *EventRef_SendEventToEventTarget(EventRefObject *_self, PyObject *_args) 312 300 { 313 314 315 316 317 318 319 320 321 322 323 324 301 PyObject *_res = NULL; 302 OSStatus _err; 303 EventTargetRef inTarget; 304 if (!PyArg_ParseTuple(_args, "O&", 305 EventTargetRef_Convert, &inTarget)) 306 return NULL; 307 _err = SendEventToEventTarget(_self->ob_itself, 308 inTarget); 309 if (_err != noErr) return PyMac_Error(_err); 310 Py_INCREF(Py_None); 311 _res = Py_None; 312 return _res; 325 313 } 326 314 327 315 static PyObject *EventRef_GetEventParameter(EventRefObject *_self, PyObject *_args) 328 316 { 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 317 PyObject *_res = NULL; 318 319 UInt32 bufferSize; 320 EventParamName inName; 321 EventParamType inType; 322 OSErr _err; 323 void * buffer; 324 325 if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &inName, PyMac_GetOSType, &inType)) 326 return NULL; 327 328 /* Figure out the size by passing a null buffer to GetEventParameter */ 329 _err = GetEventParameter(_self->ob_itself, inName, inType, NULL, 0, &bufferSize, NULL); 330 331 if (_err != noErr) 332 return PyMac_Error(_err); 333 buffer = PyMem_NEW(char, bufferSize); 334 if (buffer == NULL) 335 return PyErr_NoMemory(); 336 337 _err = GetEventParameter(_self->ob_itself, inName, inType, NULL, bufferSize, NULL, buffer); 338 339 if (_err != noErr) { 340 PyMem_DEL(buffer); 341 return PyMac_Error(_err); 342 } 343 _res = Py_BuildValue("s#", buffer, bufferSize); 344 PyMem_DEL(buffer); 345 return _res; 358 346 359 347 } 360 348 361 349 static PyMethodDef EventRef_methods[] = { 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 350 {"RetainEvent", (PyCFunction)EventRef_RetainEvent, 1, 351 PyDoc_STR("() -> (EventRef _rv)")}, 352 {"GetEventRetainCount", (PyCFunction)EventRef_GetEventRetainCount, 1, 353 PyDoc_STR("() -> (UInt32 _rv)")}, 354 {"ReleaseEvent", (PyCFunction)EventRef_ReleaseEvent, 1, 355 PyDoc_STR("() -> None")}, 356 {"SetEventParameter", (PyCFunction)EventRef_SetEventParameter, 1, 357 PyDoc_STR("(OSType inName, OSType inType, Buffer inDataPtr) -> None")}, 358 {"GetEventClass", (PyCFunction)EventRef_GetEventClass, 1, 359 PyDoc_STR("() -> (UInt32 _rv)")}, 360 {"GetEventKind", (PyCFunction)EventRef_GetEventKind, 1, 361 PyDoc_STR("() -> (UInt32 _rv)")}, 362 {"GetEventTime", (PyCFunction)EventRef_GetEventTime, 1, 363 PyDoc_STR("() -> (double _rv)")}, 364 {"SetEventTime", (PyCFunction)EventRef_SetEventTime, 1, 365 PyDoc_STR("(double inTime) -> None")}, 366 {"IsUserCancelEventRef", (PyCFunction)EventRef_IsUserCancelEventRef, 1, 367 PyDoc_STR("() -> (Boolean _rv)")}, 368 {"ConvertEventRefToEventRecord", (PyCFunction)EventRef_ConvertEventRefToEventRecord, 1, 369 PyDoc_STR("() -> (Boolean _rv, EventRecord outEvent)")}, 370 {"IsEventInMask", (PyCFunction)EventRef_IsEventInMask, 1, 371 PyDoc_STR("(UInt16 inMask) -> (Boolean _rv)")}, 372 {"SendEventToEventTarget", (PyCFunction)EventRef_SendEventToEventTarget, 1, 373 PyDoc_STR("(EventTargetRef inTarget) -> None")}, 374 {"GetEventParameter", (PyCFunction)EventRef_GetEventParameter, 1, 375 PyDoc_STR("(EventParamName eventName, EventParamType eventType) -> (String eventParamData)")}, 376 {NULL, NULL, 0} 389 377 }; 390 378 … … 403 391 static PyObject *EventRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 404 392 { 405 406 407 408 409 410 411 412 393 PyObject *_self; 394 EventRef itself; 395 char *kw[] = {"itself", 0}; 396 397 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventRef_Convert, &itself)) return NULL; 398 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 399 ((EventRefObject *)_self)->ob_itself = itself; 400 return _self; 413 401 } 414 402 … … 417 405 418 406 PyTypeObject EventRef_Type = { 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 407 PyObject_HEAD_INIT(NULL) 408 0, /*ob_size*/ 409 "_CarbonEvt.EventRef", /*tp_name*/ 410 sizeof(EventRefObject), /*tp_basicsize*/ 411 0, /*tp_itemsize*/ 412 /* methods */ 413 (destructor) EventRef_dealloc, /*tp_dealloc*/ 414 0, /*tp_print*/ 415 (getattrfunc)0, /*tp_getattr*/ 416 (setattrfunc)0, /*tp_setattr*/ 417 (cmpfunc) EventRef_compare, /*tp_compare*/ 418 (reprfunc) EventRef_repr, /*tp_repr*/ 419 (PyNumberMethods *)0, /* tp_as_number */ 420 (PySequenceMethods *)0, /* tp_as_sequence */ 421 (PyMappingMethods *)0, /* tp_as_mapping */ 422 (hashfunc) EventRef_hash, /*tp_hash*/ 423 0, /*tp_call*/ 424 0, /*tp_str*/ 425 PyObject_GenericGetAttr, /*tp_getattro*/ 426 PyObject_GenericSetAttr, /*tp_setattro */ 427 0, /*tp_as_buffer*/ 428 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 429 0, /*tp_doc*/ 430 0, /*tp_traverse*/ 431 0, /*tp_clear*/ 432 0, /*tp_richcompare*/ 433 0, /*tp_weaklistoffset*/ 434 0, /*tp_iter*/ 435 0, /*tp_iternext*/ 436 EventRef_methods, /* tp_methods */ 437 0, /*tp_members*/ 438 EventRef_getsetlist, /*tp_getset*/ 439 0, /*tp_base*/ 440 0, /*tp_dict*/ 441 0, /*tp_descr_get*/ 442 0, /*tp_descr_set*/ 443 0, /*tp_dictoffset*/ 444 EventRef_tp_init, /* tp_init */ 445 EventRef_tp_alloc, /* tp_alloc */ 446 EventRef_tp_new, /* tp_new */ 447 EventRef_tp_free, /* tp_free */ 460 448 }; 461 449 … … 470 458 471 459 typedef struct EventQueueRefObject { 472 473 460 PyObject_HEAD 461 EventQueueRef ob_itself; 474 462 } EventQueueRefObject; 475 463 476 464 PyObject *EventQueueRef_New(EventQueueRef itself) 477 465 { 478 479 480 481 482 466 EventQueueRefObject *it; 467 it = PyObject_NEW(EventQueueRefObject, &EventQueueRef_Type); 468 if (it == NULL) return NULL; 469 it->ob_itself = itself; 470 return (PyObject *)it; 483 471 } 484 472 485 473 int EventQueueRef_Convert(PyObject *v, EventQueueRef *p_itself) 486 474 { 487 488 489 490 491 492 493 475 if (!EventQueueRef_Check(v)) 476 { 477 PyErr_SetString(PyExc_TypeError, "EventQueueRef required"); 478 return 0; 479 } 480 *p_itself = ((EventQueueRefObject *)v)->ob_itself; 481 return 1; 494 482 } 495 483 496 484 static void EventQueueRef_dealloc(EventQueueRefObject *self) 497 485 { 498 499 486 /* Cleanup of self->ob_itself goes here */ 487 self->ob_type->tp_free((PyObject *)self); 500 488 } 501 489 502 490 static PyObject *EventQueueRef_PostEventToQueue(EventQueueRefObject *_self, PyObject *_args) 503 491 { 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 492 PyObject *_res = NULL; 493 OSStatus _err; 494 EventRef inEvent; 495 SInt16 inPriority; 496 if (!PyArg_ParseTuple(_args, "O&h", 497 EventRef_Convert, &inEvent, 498 &inPriority)) 499 return NULL; 500 _err = PostEventToQueue(_self->ob_itself, 501 inEvent, 502 inPriority); 503 if (_err != noErr) return PyMac_Error(_err); 504 Py_INCREF(Py_None); 505 _res = Py_None; 506 return _res; 519 507 } 520 508 521 509 static PyObject *EventQueueRef_FlushEventsMatchingListFromQueue(EventQueueRefObject *_self, PyObject *_args) 522 510 { 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 511 PyObject *_res = NULL; 512 OSStatus _err; 513 UInt32 inNumTypes; 514 EventTypeSpec inList; 515 if (!PyArg_ParseTuple(_args, "lO&", 516 &inNumTypes, 517 EventTypeSpec_Convert, &inList)) 518 return NULL; 519 _err = FlushEventsMatchingListFromQueue(_self->ob_itself, 520 inNumTypes, 521 &inList); 522 if (_err != noErr) return PyMac_Error(_err); 523 Py_INCREF(Py_None); 524 _res = Py_None; 525 return _res; 538 526 } 539 527 540 528 static PyObject *EventQueueRef_FlushEventQueue(EventQueueRefObject *_self, PyObject *_args) 541 529 { 542 543 544 545 546 547 548 549 550 530 PyObject *_res = NULL; 531 OSStatus _err; 532 if (!PyArg_ParseTuple(_args, "")) 533 return NULL; 534 _err = FlushEventQueue(_self->ob_itself); 535 if (_err != noErr) return PyMac_Error(_err); 536 Py_INCREF(Py_None); 537 _res = Py_None; 538 return _res; 551 539 } 552 540 553 541 static PyObject *EventQueueRef_GetNumEventsInQueue(EventQueueRefObject *_self, PyObject *_args) 554 542 { 555 556 557 558 559 560 561 562 543 PyObject *_res = NULL; 544 UInt32 _rv; 545 if (!PyArg_ParseTuple(_args, "")) 546 return NULL; 547 _rv = GetNumEventsInQueue(_self->ob_itself); 548 _res = Py_BuildValue("l", 549 _rv); 550 return _res; 563 551 } 564 552 565 553 static PyObject *EventQueueRef_RemoveEventFromQueue(EventQueueRefObject *_self, PyObject *_args) 566 554 { 567 568 569 570 571 572 573 574 575 576 577 578 555 PyObject *_res = NULL; 556 OSStatus _err; 557 EventRef inEvent; 558 if (!PyArg_ParseTuple(_args, "O&", 559 EventRef_Convert, &inEvent)) 560 return NULL; 561 _err = RemoveEventFromQueue(_self->ob_itself, 562 inEvent); 563 if (_err != noErr) return PyMac_Error(_err); 564 Py_INCREF(Py_None); 565 _res = Py_None; 566 return _res; 579 567 } 580 568 581 569 static PyObject *EventQueueRef_IsEventInQueue(EventQueueRefObject *_self, PyObject *_args) 582 570 { 583 584 585 586 587 588 589 590 591 592 593 571 PyObject *_res = NULL; 572 Boolean _rv; 573 EventRef inEvent; 574 if (!PyArg_ParseTuple(_args, "O&", 575 EventRef_Convert, &inEvent)) 576 return NULL; 577 _rv = IsEventInQueue(_self->ob_itself, 578 inEvent); 579 _res = Py_BuildValue("b", 580 _rv); 581 return _res; 594 582 } 595 583 596 584 static PyMethodDef EventQueueRef_methods[] = { 597 598 599 600 601 602 603 604 605 606 607 608 609 585 {"PostEventToQueue", (PyCFunction)EventQueueRef_PostEventToQueue, 1, 586 PyDoc_STR("(EventRef inEvent, SInt16 inPriority) -> None")}, 587 {"FlushEventsMatchingListFromQueue", (PyCFunction)EventQueueRef_FlushEventsMatchingListFromQueue, 1, 588 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, 589 {"FlushEventQueue", (PyCFunction)EventQueueRef_FlushEventQueue, 1, 590 PyDoc_STR("() -> None")}, 591 {"GetNumEventsInQueue", (PyCFunction)EventQueueRef_GetNumEventsInQueue, 1, 592 PyDoc_STR("() -> (UInt32 _rv)")}, 593 {"RemoveEventFromQueue", (PyCFunction)EventQueueRef_RemoveEventFromQueue, 1, 594 PyDoc_STR("(EventRef inEvent) -> None")}, 595 {"IsEventInQueue", (PyCFunction)EventQueueRef_IsEventInQueue, 1, 596 PyDoc_STR("(EventRef inEvent) -> (Boolean _rv)")}, 597 {NULL, NULL, 0} 610 598 }; 611 599 … … 624 612 static PyObject *EventQueueRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 625 613 { 626 627 628 629 630 631 632 633 614 PyObject *_self; 615 EventQueueRef itself; 616 char *kw[] = {"itself", 0}; 617 618 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventQueueRef_Convert, &itself)) return NULL; 619 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 620 ((EventQueueRefObject *)_self)->ob_itself = itself; 621 return _self; 634 622 } 635 623 … … 638 626 639 627 PyTypeObject EventQueueRef_Type = { 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 628 PyObject_HEAD_INIT(NULL) 629 0, /*ob_size*/ 630 "_CarbonEvt.EventQueueRef", /*tp_name*/ 631 sizeof(EventQueueRefObject), /*tp_basicsize*/ 632 0, /*tp_itemsize*/ 633 /* methods */ 634 (destructor) EventQueueRef_dealloc, /*tp_dealloc*/ 635 0, /*tp_print*/ 636 (getattrfunc)0, /*tp_getattr*/ 637 (setattrfunc)0, /*tp_setattr*/ 638 (cmpfunc) EventQueueRef_compare, /*tp_compare*/ 639 (reprfunc) EventQueueRef_repr, /*tp_repr*/ 640 (PyNumberMethods *)0, /* tp_as_number */ 641 (PySequenceMethods *)0, /* tp_as_sequence */ 642 (PyMappingMethods *)0, /* tp_as_mapping */ 643 (hashfunc) EventQueueRef_hash, /*tp_hash*/ 644 0, /*tp_call*/ 645 0, /*tp_str*/ 646 PyObject_GenericGetAttr, /*tp_getattro*/ 647 PyObject_GenericSetAttr, /*tp_setattro */ 648 0, /*tp_as_buffer*/ 649 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 650 0, /*tp_doc*/ 651 0, /*tp_traverse*/ 652 0, /*tp_clear*/ 653 0, /*tp_richcompare*/ 654 0, /*tp_weaklistoffset*/ 655 0, /*tp_iter*/ 656 0, /*tp_iternext*/ 657 EventQueueRef_methods, /* tp_methods */ 658 0, /*tp_members*/ 659 EventQueueRef_getsetlist, /*tp_getset*/ 660 0, /*tp_base*/ 661 0, /*tp_dict*/ 662 0, /*tp_descr_get*/ 663 0, /*tp_descr_set*/ 664 0, /*tp_dictoffset*/ 665 EventQueueRef_tp_init, /* tp_init */ 666 EventQueueRef_tp_alloc, /* tp_alloc */ 667 EventQueueRef_tp_new, /* tp_new */ 668 EventQueueRef_tp_free, /* tp_free */ 681 669 }; 682 670 … … 691 679 692 680 typedef struct EventLoopRefObject { 693 694 681 PyObject_HEAD 682 EventLoopRef ob_itself; 695 683 } EventLoopRefObject; 696 684 697 685 PyObject *EventLoopRef_New(EventLoopRef itself) 698 686 { 699 700 701 702 703 687 EventLoopRefObject *it; 688 it = PyObject_NEW(EventLoopRefObject, &EventLoopRef_Type); 689 if (it == NULL) return NULL; 690 it->ob_itself = itself; 691 return (PyObject *)it; 704 692 } 705 693 706 694 int EventLoopRef_Convert(PyObject *v, EventLoopRef *p_itself) 707 695 { 708 709 710 711 712 713 714 696 if (!EventLoopRef_Check(v)) 697 { 698 PyErr_SetString(PyExc_TypeError, "EventLoopRef required"); 699 return 0; 700 } 701 *p_itself = ((EventLoopRefObject *)v)->ob_itself; 702 return 1; 715 703 } 716 704 717 705 static void EventLoopRef_dealloc(EventLoopRefObject *self) 718 706 { 719 720 707 /* Cleanup of self->ob_itself goes here */ 708 self->ob_type->tp_free((PyObject *)self); 721 709 } 722 710 723 711 static PyObject *EventLoopRef_QuitEventLoop(EventLoopRefObject *_self, PyObject *_args) 724 712 { 725 726 727 728 729 730 731 732 733 713 PyObject *_res = NULL; 714 OSStatus _err; 715 if (!PyArg_ParseTuple(_args, "")) 716 return NULL; 717 _err = QuitEventLoop(_self->ob_itself); 718 if (_err != noErr) return PyMac_Error(_err); 719 Py_INCREF(Py_None); 720 _res = Py_None; 721 return _res; 734 722 } 735 723 736 724 static PyMethodDef EventLoopRef_methods[] = { 737 738 739 725 {"QuitEventLoop", (PyCFunction)EventLoopRef_QuitEventLoop, 1, 726 PyDoc_STR("() -> None")}, 727 {NULL, NULL, 0} 740 728 }; 741 729 … … 754 742 static PyObject *EventLoopRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 755 743 { 756 757 758 759 760 761 762 763 744 PyObject *_self; 745 EventLoopRef itself; 746 char *kw[] = {"itself", 0}; 747 748 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopRef_Convert, &itself)) return NULL; 749 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 750 ((EventLoopRefObject *)_self)->ob_itself = itself; 751 return _self; 764 752 } 765 753 … … 768 756 769 757 PyTypeObject EventLoopRef_Type = { 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 758 PyObject_HEAD_INIT(NULL) 759 0, /*ob_size*/ 760 "_CarbonEvt.EventLoopRef", /*tp_name*/ 761 sizeof(EventLoopRefObject), /*tp_basicsize*/ 762 0, /*tp_itemsize*/ 763 /* methods */ 764 (destructor) EventLoopRef_dealloc, /*tp_dealloc*/ 765 0, /*tp_print*/ 766 (getattrfunc)0, /*tp_getattr*/ 767 (setattrfunc)0, /*tp_setattr*/ 768 (cmpfunc) EventLoopRef_compare, /*tp_compare*/ 769 (reprfunc) EventLoopRef_repr, /*tp_repr*/ 770 (PyNumberMethods *)0, /* tp_as_number */ 771 (PySequenceMethods *)0, /* tp_as_sequence */ 772 (PyMappingMethods *)0, /* tp_as_mapping */ 773 (hashfunc) EventLoopRef_hash, /*tp_hash*/ 774 0, /*tp_call*/ 775 0, /*tp_str*/ 776 PyObject_GenericGetAttr, /*tp_getattro*/ 777 PyObject_GenericSetAttr, /*tp_setattro */ 778 0, /*tp_as_buffer*/ 779 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 780 0, /*tp_doc*/ 781 0, /*tp_traverse*/ 782 0, /*tp_clear*/ 783 0, /*tp_richcompare*/ 784 0, /*tp_weaklistoffset*/ 785 0, /*tp_iter*/ 786 0, /*tp_iternext*/ 787 EventLoopRef_methods, /* tp_methods */ 788 0, /*tp_members*/ 789 EventLoopRef_getsetlist, /*tp_getset*/ 790 0, /*tp_base*/ 791 0, /*tp_dict*/ 792 0, /*tp_descr_get*/ 793 0, /*tp_descr_set*/ 794 0, /*tp_dictoffset*/ 795 EventLoopRef_tp_init, /* tp_init */ 796 EventLoopRef_tp_alloc, /* tp_alloc */ 797 EventLoopRef_tp_new, /* tp_new */ 798 EventLoopRef_tp_free, /* tp_free */ 811 799 }; 812 800 … … 821 809 822 810 typedef struct EventLoopTimerRefObject { 823 824 811 PyObject_HEAD 812 EventLoopTimerRef ob_itself; 825 813 } EventLoopTimerRefObject; 826 814 827 815 PyObject *EventLoopTimerRef_New(EventLoopTimerRef itself) 828 816 { 829 830 831 832 833 817 EventLoopTimerRefObject *it; 818 it = PyObject_NEW(EventLoopTimerRefObject, &EventLoopTimerRef_Type); 819 if (it == NULL) return NULL; 820 it->ob_itself = itself; 821 return (PyObject *)it; 834 822 } 835 823 836 824 int EventLoopTimerRef_Convert(PyObject *v, EventLoopTimerRef *p_itself) 837 825 { 838 839 840 841 842 843 844 826 if (!EventLoopTimerRef_Check(v)) 827 { 828 PyErr_SetString(PyExc_TypeError, "EventLoopTimerRef required"); 829 return 0; 830 } 831 *p_itself = ((EventLoopTimerRefObject *)v)->ob_itself; 832 return 1; 845 833 } 846 834 847 835 static void EventLoopTimerRef_dealloc(EventLoopTimerRefObject *self) 848 836 { 849 850 837 /* Cleanup of self->ob_itself goes here */ 838 self->ob_type->tp_free((PyObject *)self); 851 839 } 852 840 853 841 static PyObject *EventLoopTimerRef_RemoveEventLoopTimer(EventLoopTimerRefObject *_self, PyObject *_args) 854 842 { 855 856 857 858 859 860 861 862 863 843 PyObject *_res = NULL; 844 OSStatus _err; 845 if (!PyArg_ParseTuple(_args, "")) 846 return NULL; 847 _err = RemoveEventLoopTimer(_self->ob_itself); 848 if (_err != noErr) return PyMac_Error(_err); 849 Py_INCREF(Py_None); 850 _res = Py_None; 851 return _res; 864 852 } 865 853 866 854 static PyObject *EventLoopTimerRef_SetEventLoopTimerNextFireTime(EventLoopTimerRefObject *_self, PyObject *_args) 867 855 { 868 869 870 871 872 873 874 875 876 877 878 879 856 PyObject *_res = NULL; 857 OSStatus _err; 858 double inNextFire; 859 if (!PyArg_ParseTuple(_args, "d", 860 &inNextFire)) 861 return NULL; 862 _err = SetEventLoopTimerNextFireTime(_self->ob_itself, 863 inNextFire); 864 if (_err != noErr) return PyMac_Error(_err); 865 Py_INCREF(Py_None); 866 _res = Py_None; 867 return _res; 880 868 } 881 869 882 870 static PyMethodDef EventLoopTimerRef_methods[] = { 883 884 885 886 887 871 {"RemoveEventLoopTimer", (PyCFunction)EventLoopTimerRef_RemoveEventLoopTimer, 1, 872 PyDoc_STR("() -> None")}, 873 {"SetEventLoopTimerNextFireTime", (PyCFunction)EventLoopTimerRef_SetEventLoopTimerNextFireTime, 1, 874 PyDoc_STR("(double inNextFire) -> None")}, 875 {NULL, NULL, 0} 888 876 }; 889 877 … … 902 890 static PyObject *EventLoopTimerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 903 891 { 904 905 906 907 908 909 910 911 892 PyObject *_self; 893 EventLoopTimerRef itself; 894 char *kw[] = {"itself", 0}; 895 896 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopTimerRef_Convert, &itself)) return NULL; 897 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 898 ((EventLoopTimerRefObject *)_self)->ob_itself = itself; 899 return _self; 912 900 } 913 901 … … 916 904 917 905 PyTypeObject EventLoopTimerRef_Type = { 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 906 PyObject_HEAD_INIT(NULL) 907 0, /*ob_size*/ 908 "_CarbonEvt.EventLoopTimerRef", /*tp_name*/ 909 sizeof(EventLoopTimerRefObject), /*tp_basicsize*/ 910 0, /*tp_itemsize*/ 911 /* methods */ 912 (destructor) EventLoopTimerRef_dealloc, /*tp_dealloc*/ 913 0, /*tp_print*/ 914 (getattrfunc)0, /*tp_getattr*/ 915 (setattrfunc)0, /*tp_setattr*/ 916 (cmpfunc) EventLoopTimerRef_compare, /*tp_compare*/ 917 (reprfunc) EventLoopTimerRef_repr, /*tp_repr*/ 918 (PyNumberMethods *)0, /* tp_as_number */ 919 (PySequenceMethods *)0, /* tp_as_sequence */ 920 (PyMappingMethods *)0, /* tp_as_mapping */ 921 (hashfunc) EventLoopTimerRef_hash, /*tp_hash*/ 922 0, /*tp_call*/ 923 0, /*tp_str*/ 924 PyObject_GenericGetAttr, /*tp_getattro*/ 925 PyObject_GenericSetAttr, /*tp_setattro */ 926 0, /*tp_as_buffer*/ 927 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 928 0, /*tp_doc*/ 929 0, /*tp_traverse*/ 930 0, /*tp_clear*/ 931 0, /*tp_richcompare*/ 932 0, /*tp_weaklistoffset*/ 933 0, /*tp_iter*/ 934 0, /*tp_iternext*/ 935 EventLoopTimerRef_methods, /* tp_methods */ 936 0, /*tp_members*/ 937 EventLoopTimerRef_getsetlist, /*tp_getset*/ 938 0, /*tp_base*/ 939 0, /*tp_dict*/ 940 0, /*tp_descr_get*/ 941 0, /*tp_descr_set*/ 942 0, /*tp_dictoffset*/ 943 EventLoopTimerRef_tp_init, /* tp_init */ 944 EventLoopTimerRef_tp_alloc, /* tp_alloc */ 945 EventLoopTimerRef_tp_new, /* tp_new */ 946 EventLoopTimerRef_tp_free, /* tp_free */ 959 947 }; 960 948 … … 969 957 970 958 typedef struct EventHandlerRefObject { 971 972 973 959 PyObject_HEAD 960 EventHandlerRef ob_itself; 961 PyObject *ob_callback; 974 962 } EventHandlerRefObject; 975 963 976 964 PyObject *EventHandlerRef_New(EventHandlerRef itself) 977 965 { 978 979 980 981 982 983 966 EventHandlerRefObject *it; 967 it = PyObject_NEW(EventHandlerRefObject, &EventHandlerRef_Type); 968 if (it == NULL) return NULL; 969 it->ob_itself = itself; 970 it->ob_callback = NULL; 971 return (PyObject *)it; 984 972 } 985 973 986 974 int EventHandlerRef_Convert(PyObject *v, EventHandlerRef *p_itself) 987 975 { 988 989 990 991 992 993 994 976 if (!EventHandlerRef_Check(v)) 977 { 978 PyErr_SetString(PyExc_TypeError, "EventHandlerRef required"); 979 return 0; 980 } 981 *p_itself = ((EventHandlerRefObject *)v)->ob_itself; 982 return 1; 995 983 } 996 984 997 985 static void EventHandlerRef_dealloc(EventHandlerRefObject *self) 998 986 { 999 1000 1001 1002 1003 987 if (self->ob_itself != NULL) { 988 RemoveEventHandler(self->ob_itself); 989 Py_DECREF(self->ob_callback); 990 } 991 self->ob_type->tp_free((PyObject *)self); 1004 992 } 1005 993 1006 994 static PyObject *EventHandlerRef_AddEventTypesToHandler(EventHandlerRefObject *_self, PyObject *_args) 1007 995 { 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 996 PyObject *_res = NULL; 997 OSStatus _err; 998 UInt32 inNumTypes; 999 EventTypeSpec inList; 1000 if (_self->ob_itself == NULL) { 1001 PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); 1002 return NULL; 1003 } 1004 if (!PyArg_ParseTuple(_args, "lO&", 1005 &inNumTypes, 1006 EventTypeSpec_Convert, &inList)) 1007 return NULL; 1008 _err = AddEventTypesToHandler(_self->ob_itself, 1009 inNumTypes, 1010 &inList); 1011 if (_err != noErr) return PyMac_Error(_err); 1012 Py_INCREF(Py_None); 1013 _res = Py_None; 1014 return _res; 1027 1015 } 1028 1016 1029 1017 static PyObject *EventHandlerRef_RemoveEventTypesFromHandler(EventHandlerRefObject *_self, PyObject *_args) 1030 1018 { 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1019 PyObject *_res = NULL; 1020 OSStatus _err; 1021 UInt32 inNumTypes; 1022 EventTypeSpec inList; 1023 if (_self->ob_itself == NULL) { 1024 PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); 1025 return NULL; 1026 } 1027 if (!PyArg_ParseTuple(_args, "lO&", 1028 &inNumTypes, 1029 EventTypeSpec_Convert, &inList)) 1030 return NULL; 1031 _err = RemoveEventTypesFromHandler(_self->ob_itself, 1032 inNumTypes, 1033 &inList); 1034 if (_err != noErr) return PyMac_Error(_err); 1035 Py_INCREF(Py_None); 1036 _res = Py_None; 1037 return _res; 1050 1038 } 1051 1039 1052 1040 static PyObject *EventHandlerRef_RemoveEventHandler(EventHandlerRefObject *_self, PyObject *_args) 1053 1041 { 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1042 PyObject *_res = NULL; 1043 1044 OSStatus _err; 1045 if (_self->ob_itself == NULL) { 1046 PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); 1047 return NULL; 1048 } 1049 if (!PyArg_ParseTuple(_args, "")) 1050 return NULL; 1051 _err = RemoveEventHandler(_self->ob_itself); 1052 if (_err != noErr) return PyMac_Error(_err); 1053 _self->ob_itself = NULL; 1054 Py_DECREF(_self->ob_callback); 1055 _self->ob_callback = NULL; 1056 Py_INCREF(Py_None); 1057 _res = Py_None; 1058 return _res; 1071 1059 } 1072 1060 1073 1061 static PyMethodDef EventHandlerRef_methods[] = { 1074 1075 1076 1077 1078 1079 1080 1062 {"AddEventTypesToHandler", (PyCFunction)EventHandlerRef_AddEventTypesToHandler, 1, 1063 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, 1064 {"RemoveEventTypesFromHandler", (PyCFunction)EventHandlerRef_RemoveEventTypesFromHandler, 1, 1065 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, 1066 {"RemoveEventHandler", (PyCFunction)EventHandlerRef_RemoveEventHandler, 1, 1067 PyDoc_STR("() -> None")}, 1068 {NULL, NULL, 0} 1081 1069 }; 1082 1070 … … 1095 1083 static PyObject *EventHandlerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 1096 1084 { 1097 1098 1099 1100 1101 1102 1103 1104 1085 PyObject *_self; 1086 EventHandlerRef itself; 1087 char *kw[] = {"itself", 0}; 1088 1089 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerRef_Convert, &itself)) return NULL; 1090 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 1091 ((EventHandlerRefObject *)_self)->ob_itself = itself; 1092 return _self; 1105 1093 } 1106 1094 … … 1109 1097 1110 1098 PyTypeObject EventHandlerRef_Type = { 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1099 PyObject_HEAD_INIT(NULL) 1100 0, /*ob_size*/ 1101 "_CarbonEvt.EventHandlerRef", /*tp_name*/ 1102 sizeof(EventHandlerRefObject), /*tp_basicsize*/ 1103 0, /*tp_itemsize*/ 1104 /* methods */ 1105 (destructor) EventHandlerRef_dealloc, /*tp_dealloc*/ 1106 0, /*tp_print*/ 1107 (getattrfunc)0, /*tp_getattr*/ 1108 (setattrfunc)0, /*tp_setattr*/ 1109 (cmpfunc) EventHandlerRef_compare, /*tp_compare*/ 1110 (reprfunc) EventHandlerRef_repr, /*tp_repr*/ 1111 (PyNumberMethods *)0, /* tp_as_number */ 1112 (PySequenceMethods *)0, /* tp_as_sequence */ 1113 (PyMappingMethods *)0, /* tp_as_mapping */ 1114 (hashfunc) EventHandlerRef_hash, /*tp_hash*/ 1115 0, /*tp_call*/ 1116 0, /*tp_str*/ 1117 PyObject_GenericGetAttr, /*tp_getattro*/ 1118 PyObject_GenericSetAttr, /*tp_setattro */ 1119 0, /*tp_as_buffer*/ 1120 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 1121 0, /*tp_doc*/ 1122 0, /*tp_traverse*/ 1123 0, /*tp_clear*/ 1124 0, /*tp_richcompare*/ 1125 0, /*tp_weaklistoffset*/ 1126 0, /*tp_iter*/ 1127 0, /*tp_iternext*/ 1128 EventHandlerRef_methods, /* tp_methods */ 1129 0, /*tp_members*/ 1130 EventHandlerRef_getsetlist, /*tp_getset*/ 1131 0, /*tp_base*/ 1132 0, /*tp_dict*/ 1133 0, /*tp_descr_get*/ 1134 0, /*tp_descr_set*/ 1135 0, /*tp_dictoffset*/ 1136 EventHandlerRef_tp_init, /* tp_init */ 1137 EventHandlerRef_tp_alloc, /* tp_alloc */ 1138 EventHandlerRef_tp_new, /* tp_new */ 1139 EventHandlerRef_tp_free, /* tp_free */ 1152 1140 }; 1153 1141 … … 1162 1150 1163 1151 typedef struct EventHandlerCallRefObject { 1164 1165 1152 PyObject_HEAD 1153 EventHandlerCallRef ob_itself; 1166 1154 } EventHandlerCallRefObject; 1167 1155 1168 1156 PyObject *EventHandlerCallRef_New(EventHandlerCallRef itself) 1169 1157 { 1170 1171 1172 1173 1174 1158 EventHandlerCallRefObject *it; 1159 it = PyObject_NEW(EventHandlerCallRefObject, &EventHandlerCallRef_Type); 1160 if (it == NULL) return NULL; 1161 it->ob_itself = itself; 1162 return (PyObject *)it; 1175 1163 } 1176 1164 1177 1165 int EventHandlerCallRef_Convert(PyObject *v, EventHandlerCallRef *p_itself) 1178 1166 { 1179 1180 1181 1182 1183 1184 1185 1167 if (!EventHandlerCallRef_Check(v)) 1168 { 1169 PyErr_SetString(PyExc_TypeError, "EventHandlerCallRef required"); 1170 return 0; 1171 } 1172 *p_itself = ((EventHandlerCallRefObject *)v)->ob_itself; 1173 return 1; 1186 1174 } 1187 1175 1188 1176 static void EventHandlerCallRef_dealloc(EventHandlerCallRefObject *self) 1189 1177 { 1190 1191 1178 /* Cleanup of self->ob_itself goes here */ 1179 self->ob_type->tp_free((PyObject *)self); 1192 1180 } 1193 1181 1194 1182 static PyObject *EventHandlerCallRef_CallNextEventHandler(EventHandlerCallRefObject *_self, PyObject *_args) 1195 1183 { 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1184 PyObject *_res = NULL; 1185 OSStatus _err; 1186 EventRef inEvent; 1187 if (!PyArg_ParseTuple(_args, "O&", 1188 EventRef_Convert, &inEvent)) 1189 return NULL; 1190 _err = CallNextEventHandler(_self->ob_itself, 1191 inEvent); 1192 if (_err != noErr) return PyMac_Error(_err); 1193 Py_INCREF(Py_None); 1194 _res = Py_None; 1195 return _res; 1208 1196 } 1209 1197 1210 1198 static PyMethodDef EventHandlerCallRef_methods[] = { 1211 1212 1213 1199 {"CallNextEventHandler", (PyCFunction)EventHandlerCallRef_CallNextEventHandler, 1, 1200 PyDoc_STR("(EventRef inEvent) -> None")}, 1201 {NULL, NULL, 0} 1214 1202 }; 1215 1203 … … 1228 1216 static PyObject *EventHandlerCallRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 1229 1217 { 1230 1231 1232 1233 1234 1235 1236 1237 1218 PyObject *_self; 1219 EventHandlerCallRef itself; 1220 char *kw[] = {"itself", 0}; 1221 1222 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerCallRef_Convert, &itself)) return NULL; 1223 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 1224 ((EventHandlerCallRefObject *)_self)->ob_itself = itself; 1225 return _self; 1238 1226 } 1239 1227 … … 1242 1230 1243 1231 PyTypeObject EventHandlerCallRef_Type = { 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1232 PyObject_HEAD_INIT(NULL) 1233 0, /*ob_size*/ 1234 "_CarbonEvt.EventHandlerCallRef", /*tp_name*/ 1235 sizeof(EventHandlerCallRefObject), /*tp_basicsize*/ 1236 0, /*tp_itemsize*/ 1237 /* methods */ 1238 (destructor) EventHandlerCallRef_dealloc, /*tp_dealloc*/ 1239 0, /*tp_print*/ 1240 (getattrfunc)0, /*tp_getattr*/ 1241 (setattrfunc)0, /*tp_setattr*/ 1242 (cmpfunc) EventHandlerCallRef_compare, /*tp_compare*/ 1243 (reprfunc) EventHandlerCallRef_repr, /*tp_repr*/ 1244 (PyNumberMethods *)0, /* tp_as_number */ 1245 (PySequenceMethods *)0, /* tp_as_sequence */ 1246 (PyMappingMethods *)0, /* tp_as_mapping */ 1247 (hashfunc) EventHandlerCallRef_hash, /*tp_hash*/ 1248 0, /*tp_call*/ 1249 0, /*tp_str*/ 1250 PyObject_GenericGetAttr, /*tp_getattro*/ 1251 PyObject_GenericSetAttr, /*tp_setattro */ 1252 0, /*tp_as_buffer*/ 1253 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 1254 0, /*tp_doc*/ 1255 0, /*tp_traverse*/ 1256 0, /*tp_clear*/ 1257 0, /*tp_richcompare*/ 1258 0, /*tp_weaklistoffset*/ 1259 0, /*tp_iter*/ 1260 0, /*tp_iternext*/ 1261 EventHandlerCallRef_methods, /* tp_methods */ 1262 0, /*tp_members*/ 1263 EventHandlerCallRef_getsetlist, /*tp_getset*/ 1264 0, /*tp_base*/ 1265 0, /*tp_dict*/ 1266 0, /*tp_descr_get*/ 1267 0, /*tp_descr_set*/ 1268 0, /*tp_dictoffset*/ 1269 EventHandlerCallRef_tp_init, /* tp_init */ 1270 EventHandlerCallRef_tp_alloc, /* tp_alloc */ 1271 EventHandlerCallRef_tp_new, /* tp_new */ 1272 EventHandlerCallRef_tp_free, /* tp_free */ 1285 1273 }; 1286 1274 … … 1295 1283 1296 1284 typedef struct EventTargetRefObject { 1297 1298 1285 PyObject_HEAD 1286 EventTargetRef ob_itself; 1299 1287 } EventTargetRefObject; 1300 1288 1301 1289 PyObject *EventTargetRef_New(EventTargetRef itself) 1302 1290 { 1303 1304 1305 1306 1307 1291 EventTargetRefObject *it; 1292 it = PyObject_NEW(EventTargetRefObject, &EventTargetRef_Type); 1293 if (it == NULL) return NULL; 1294 it->ob_itself = itself; 1295 return (PyObject *)it; 1308 1296 } 1309 1297 1310 1298 int EventTargetRef_Convert(PyObject *v, EventTargetRef *p_itself) 1311 1299 { 1312 1313 1314 1315 1316 1317 1318 1300 if (!EventTargetRef_Check(v)) 1301 { 1302 PyErr_SetString(PyExc_TypeError, "EventTargetRef required"); 1303 return 0; 1304 } 1305 *p_itself = ((EventTargetRefObject *)v)->ob_itself; 1306 return 1; 1319 1307 } 1320 1308 1321 1309 static void EventTargetRef_dealloc(EventTargetRefObject *self) 1322 1310 { 1323 1324 1311 /* Cleanup of self->ob_itself goes here */ 1312 self->ob_type->tp_free((PyObject *)self); 1325 1313 } 1326 1314 1327 1315 static PyObject *EventTargetRef_InstallStandardEventHandler(EventTargetRefObject *_self, PyObject *_args) 1328 1316 { 1329 1330 1331 1332 1333 1334 1335 1336 1337 1317 PyObject *_res = NULL; 1318 OSStatus _err; 1319 if (!PyArg_ParseTuple(_args, "")) 1320 return NULL; 1321 _err = InstallStandardEventHandler(_self->ob_itself); 1322 if (_err != noErr) return PyMac_Error(_err); 1323 Py_INCREF(Py_None); 1324 _res = Py_None; 1325 return _res; 1338 1326 } 1339 1327 1340 1328 static PyObject *EventTargetRef_InstallEventHandler(EventTargetRefObject *_self, PyObject *_args) 1341 1329 { 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1330 PyObject *_res = NULL; 1331 1332 EventTypeSpec inSpec; 1333 PyObject *callback; 1334 EventHandlerRef outRef; 1335 OSStatus _err; 1336 1337 if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback)) 1338 return NULL; 1339 1340 _err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef); 1341 if (_err != noErr) return PyMac_Error(_err); 1342 1343 _res = EventHandlerRef_New(outRef); 1344 if (_res != NULL) { 1345 ((EventHandlerRefObject*)_res)->ob_callback = callback; 1346 Py_INCREF(callback); 1347 } 1348 return _res; 1361 1349 } 1362 1350 1363 1351 static PyMethodDef EventTargetRef_methods[] = { 1364 1365 1366 1367 1368 1352 {"InstallStandardEventHandler", (PyCFunction)EventTargetRef_InstallStandardEventHandler, 1, 1353 PyDoc_STR("() -> None")}, 1354 {"InstallEventHandler", (PyCFunction)EventTargetRef_InstallEventHandler, 1, 1355 PyDoc_STR("(EventTypeSpec inSpec, Method callback) -> (EventHandlerRef outRef)")}, 1356 {NULL, NULL, 0} 1369 1357 }; 1370 1358 … … 1383 1371 static PyObject *EventTargetRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 1384 1372 { 1385 1386 1387 1388 1389 1390 1391 1392 1373 PyObject *_self; 1374 EventTargetRef itself; 1375 char *kw[] = {"itself", 0}; 1376 1377 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventTargetRef_Convert, &itself)) return NULL; 1378 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 1379 ((EventTargetRefObject *)_self)->ob_itself = itself; 1380 return _self; 1393 1381 } 1394 1382 … … 1397 1385 1398 1386 PyTypeObject EventTargetRef_Type = { 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1387 PyObject_HEAD_INIT(NULL) 1388 0, /*ob_size*/ 1389 "_CarbonEvt.EventTargetRef", /*tp_name*/ 1390 sizeof(EventTargetRefObject), /*tp_basicsize*/ 1391 0, /*tp_itemsize*/ 1392 /* methods */ 1393 (destructor) EventTargetRef_dealloc, /*tp_dealloc*/ 1394 0, /*tp_print*/ 1395 (getattrfunc)0, /*tp_getattr*/ 1396 (setattrfunc)0, /*tp_setattr*/ 1397 (cmpfunc) EventTargetRef_compare, /*tp_compare*/ 1398 (reprfunc) EventTargetRef_repr, /*tp_repr*/ 1399 (PyNumberMethods *)0, /* tp_as_number */ 1400 (PySequenceMethods *)0, /* tp_as_sequence */ 1401 (PyMappingMethods *)0, /* tp_as_mapping */ 1402 (hashfunc) EventTargetRef_hash, /*tp_hash*/ 1403 0, /*tp_call*/ 1404 0, /*tp_str*/ 1405 PyObject_GenericGetAttr, /*tp_getattro*/ 1406 PyObject_GenericSetAttr, /*tp_setattro */ 1407 0, /*tp_as_buffer*/ 1408 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 1409 0, /*tp_doc*/ 1410 0, /*tp_traverse*/ 1411 0, /*tp_clear*/ 1412 0, /*tp_richcompare*/ 1413 0, /*tp_weaklistoffset*/ 1414 0, /*tp_iter*/ 1415 0, /*tp_iternext*/ 1416 EventTargetRef_methods, /* tp_methods */ 1417 0, /*tp_members*/ 1418 EventTargetRef_getsetlist, /*tp_getset*/ 1419 0, /*tp_base*/ 1420 0, /*tp_dict*/ 1421 0, /*tp_descr_get*/ 1422 0, /*tp_descr_set*/ 1423 0, /*tp_dictoffset*/ 1424 EventTargetRef_tp_init, /* tp_init */ 1425 EventTargetRef_tp_alloc, /* tp_alloc */ 1426 EventTargetRef_tp_new, /* tp_new */ 1427 EventTargetRef_tp_free, /* tp_free */ 1440 1428 }; 1441 1429 … … 1450 1438 1451 1439 typedef struct EventHotKeyRefObject { 1452 1453 1440 PyObject_HEAD 1441 EventHotKeyRef ob_itself; 1454 1442 } EventHotKeyRefObject; 1455 1443 1456 1444 PyObject *EventHotKeyRef_New(EventHotKeyRef itself) 1457 1445 { 1458 1459 1460 1461 1462 1446 EventHotKeyRefObject *it; 1447 it = PyObject_NEW(EventHotKeyRefObject, &EventHotKeyRef_Type); 1448 if (it == NULL) return NULL; 1449 it->ob_itself = itself; 1450 return (PyObject *)it; 1463 1451 } 1464 1452 1465 1453 int EventHotKeyRef_Convert(PyObject *v, EventHotKeyRef *p_itself) 1466 1454 { 1467 1468 1469 1470 1471 1472 1473 1455 if (!EventHotKeyRef_Check(v)) 1456 { 1457 PyErr_SetString(PyExc_TypeError, "EventHotKeyRef required"); 1458 return 0; 1459 } 1460 *p_itself = ((EventHotKeyRefObject *)v)->ob_itself; 1461 return 1; 1474 1462 } 1475 1463 1476 1464 static void EventHotKeyRef_dealloc(EventHotKeyRefObject *self) 1477 1465 { 1478 1479 1466 /* Cleanup of self->ob_itself goes here */ 1467 self->ob_type->tp_free((PyObject *)self); 1480 1468 } 1481 1469 1482 1470 static PyObject *EventHotKeyRef_UnregisterEventHotKey(EventHotKeyRefObject *_self, PyObject *_args) 1483 1471 { 1484 1485 1486 1487 1488 1489 1490 1491 1492 1472 PyObject *_res = NULL; 1473 OSStatus _err; 1474 if (!PyArg_ParseTuple(_args, "")) 1475 return NULL; 1476 _err = UnregisterEventHotKey(_self->ob_itself); 1477 if (_err != noErr) return PyMac_Error(_err); 1478 Py_INCREF(Py_None); 1479 _res = Py_None; 1480 return _res; 1493 1481 } 1494 1482 1495 1483 static PyMethodDef EventHotKeyRef_methods[] = { 1496 1497 1498 1484 {"UnregisterEventHotKey", (PyCFunction)EventHotKeyRef_UnregisterEventHotKey, 1, 1485 PyDoc_STR("() -> None")}, 1486 {NULL, NULL, 0} 1499 1487 }; 1500 1488 … … 1513 1501 static PyObject *EventHotKeyRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 1514 1502 { 1515 1516 1517 1518 1519 1520 1521 1522 1503 PyObject *_self; 1504 EventHotKeyRef itself; 1505 char *kw[] = {"itself", 0}; 1506 1507 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHotKeyRef_Convert, &itself)) return NULL; 1508 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 1509 ((EventHotKeyRefObject *)_self)->ob_itself = itself; 1510 return _self; 1523 1511 } 1524 1512 … … 1527 1515 1528 1516 PyTypeObject EventHotKeyRef_Type = { 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1517 PyObject_HEAD_INIT(NULL) 1518 0, /*ob_size*/ 1519 "_CarbonEvt.EventHotKeyRef", /*tp_name*/ 1520 sizeof(EventHotKeyRefObject), /*tp_basicsize*/ 1521 0, /*tp_itemsize*/ 1522 /* methods */ 1523 (destructor) EventHotKeyRef_dealloc, /*tp_dealloc*/ 1524 0, /*tp_print*/ 1525 (getattrfunc)0, /*tp_getattr*/ 1526 (setattrfunc)0, /*tp_setattr*/ 1527 (cmpfunc) EventHotKeyRef_compare, /*tp_compare*/ 1528 (reprfunc) EventHotKeyRef_repr, /*tp_repr*/ 1529 (PyNumberMethods *)0, /* tp_as_number */ 1530 (PySequenceMethods *)0, /* tp_as_sequence */ 1531 (PyMappingMethods *)0, /* tp_as_mapping */ 1532 (hashfunc) EventHotKeyRef_hash, /*tp_hash*/ 1533 0, /*tp_call*/ 1534 0, /*tp_str*/ 1535 PyObject_GenericGetAttr, /*tp_getattro*/ 1536 PyObject_GenericSetAttr, /*tp_setattro */ 1537 0, /*tp_as_buffer*/ 1538 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 1539 0, /*tp_doc*/ 1540 0, /*tp_traverse*/ 1541 0, /*tp_clear*/ 1542 0, /*tp_richcompare*/ 1543 0, /*tp_weaklistoffset*/ 1544 0, /*tp_iter*/ 1545 0, /*tp_iternext*/ 1546 EventHotKeyRef_methods, /* tp_methods */ 1547 0, /*tp_members*/ 1548 EventHotKeyRef_getsetlist, /*tp_getset*/ 1549 0, /*tp_base*/ 1550 0, /*tp_dict*/ 1551 0, /*tp_descr_get*/ 1552 0, /*tp_descr_set*/ 1553 0, /*tp_dictoffset*/ 1554 EventHotKeyRef_tp_init, /* tp_init */ 1555 EventHotKeyRef_tp_alloc, /* tp_alloc */ 1556 EventHotKeyRef_tp_new, /* tp_new */ 1557 EventHotKeyRef_tp_free, /* tp_free */ 1570 1558 }; 1571 1559 … … 1575 1563 static PyObject *CarbonEvents_GetCurrentEventLoop(PyObject *_self, PyObject *_args) 1576 1564 { 1577 1578 1579 1580 1581 1582 1583 1584 1565 PyObject *_res = NULL; 1566 EventLoopRef _rv; 1567 if (!PyArg_ParseTuple(_args, "")) 1568 return NULL; 1569 _rv = GetCurrentEventLoop(); 1570 _res = Py_BuildValue("O&", 1571 EventLoopRef_New, _rv); 1572 return _res; 1585 1573 } 1586 1574 1587 1575 static PyObject *CarbonEvents_GetMainEventLoop(PyObject *_self, PyObject *_args) 1588 1576 { 1589 1590 1591 1592 1593 1594 1595 1596 1577 PyObject *_res = NULL; 1578 EventLoopRef _rv; 1579 if (!PyArg_ParseTuple(_args, "")) 1580 return NULL; 1581 _rv = GetMainEventLoop(); 1582 _res = Py_BuildValue("O&", 1583 EventLoopRef_New, _rv); 1584 return _res; 1597 1585 } 1598 1586 1599 1587 static PyObject *CarbonEvents_RunCurrentEventLoop(PyObject *_self, PyObject *_args) 1600 1588 { 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1589 PyObject *_res = NULL; 1590 OSStatus _err; 1591 double inTimeout; 1592 if (!PyArg_ParseTuple(_args, "d", 1593 &inTimeout)) 1594 return NULL; 1595 _err = RunCurrentEventLoop(inTimeout); 1596 if (_err != noErr) return PyMac_Error(_err); 1597 Py_INCREF(Py_None); 1598 _res = Py_None; 1599 return _res; 1612 1600 } 1613 1601 1614 1602 static PyObject *CarbonEvents_ReceiveNextEvent(PyObject *_self, PyObject *_args) 1615 1603 { 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1604 PyObject *_res = NULL; 1605 OSStatus _err; 1606 UInt32 inNumTypes; 1607 EventTypeSpec inList; 1608 double inTimeout; 1609 Boolean inPullEvent; 1610 EventRef outEvent; 1611 if (!PyArg_ParseTuple(_args, "lO&db", 1612 &inNumTypes, 1613 EventTypeSpec_Convert, &inList, 1614 &inTimeout, 1615 &inPullEvent)) 1616 return NULL; 1617 _err = ReceiveNextEvent(inNumTypes, 1618 &inList, 1619 inTimeout, 1620 inPullEvent, 1621 &outEvent); 1622 if (_err != noErr) return PyMac_Error(_err); 1623 _res = Py_BuildValue("O&", 1624 EventRef_New, outEvent); 1625 return _res; 1638 1626 } 1639 1627 1640 1628 static PyObject *CarbonEvents_GetCurrentEventQueue(PyObject *_self, PyObject *_args) 1641 1629 { 1642 1643 1644 1645 1646 1647 1648 1649 1630 PyObject *_res = NULL; 1631 EventQueueRef _rv; 1632 if (!PyArg_ParseTuple(_args, "")) 1633 return NULL; 1634 _rv = GetCurrentEventQueue(); 1635 _res = Py_BuildValue("O&", 1636 EventQueueRef_New, _rv); 1637 return _res; 1650 1638 } 1651 1639 1652 1640 static PyObject *CarbonEvents_GetMainEventQueue(PyObject *_self, PyObject *_args) 1653 1641 { 1654 1655 1656 1657 1658 1659 1660 1661 1642 PyObject *_res = NULL; 1643 EventQueueRef _rv; 1644 if (!PyArg_ParseTuple(_args, "")) 1645 return NULL; 1646 _rv = GetMainEventQueue(); 1647 _res = Py_BuildValue("O&", 1648 EventQueueRef_New, _rv); 1649 return _res; 1662 1650 } 1663 1651 1664 1652 static PyObject *CarbonEvents_GetCurrentEventTime(PyObject *_self, PyObject *_args) 1665 1653 { 1666 1667 1668 1669 1670 1671 1672 1673 1654 PyObject *_res = NULL; 1655 double _rv; 1656 if (!PyArg_ParseTuple(_args, "")) 1657 return NULL; 1658 _rv = GetCurrentEventTime(); 1659 _res = Py_BuildValue("d", 1660 _rv); 1661 return _res; 1674 1662 } 1675 1663 1676 1664 static PyObject *CarbonEvents_TrackMouseLocation(PyObject *_self, PyObject *_args) 1677 1665 { 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1666 PyObject *_res = NULL; 1667 OSStatus _err; 1668 GrafPtr inPort; 1669 Point outPt; 1670 UInt16 outResult; 1671 if (!PyArg_ParseTuple(_args, "O&", 1672 GrafObj_Convert, &inPort)) 1673 return NULL; 1674 _err = TrackMouseLocation(inPort, 1675 &outPt, 1676 &outResult); 1677 if (_err != noErr) return PyMac_Error(_err); 1678 _res = Py_BuildValue("O&H", 1679 PyMac_BuildPoint, outPt, 1680 outResult); 1681 return _res; 1694 1682 } 1695 1683 1696 1684 static PyObject *CarbonEvents_TrackMouseLocationWithOptions(PyObject *_self, PyObject *_args) 1697 1685 { 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1686 PyObject *_res = NULL; 1687 OSStatus _err; 1688 GrafPtr inPort; 1689 OptionBits inOptions; 1690 double inTimeout; 1691 Point outPt; 1692 UInt32 outModifiers; 1693 UInt16 outResult; 1694 if (!PyArg_ParseTuple(_args, "O&ld", 1695 GrafObj_Convert, &inPort, 1696 &inOptions, 1697 &inTimeout)) 1698 return NULL; 1699 _err = TrackMouseLocationWithOptions(inPort, 1700 inOptions, 1701 inTimeout, 1702 &outPt, 1703 &outModifiers, 1704 &outResult); 1705 if (_err != noErr) return PyMac_Error(_err); 1706 _res = Py_BuildValue("O&lH", 1707 PyMac_BuildPoint, outPt, 1708 outModifiers, 1709 outResult); 1710 return _res; 1723 1711 } 1724 1712 1725 1713 static PyObject *CarbonEvents_TrackMouseRegion(PyObject *_self, PyObject *_args) 1726 1714 { 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1715 PyObject *_res = NULL; 1716 OSStatus _err; 1717 GrafPtr inPort; 1718 RgnHandle inRegion; 1719 Boolean ioWasInRgn; 1720 UInt16 outResult; 1721 if (!PyArg_ParseTuple(_args, "O&O&b", 1722 GrafObj_Convert, &inPort, 1723 ResObj_Convert, &inRegion, 1724 &ioWasInRgn)) 1725 return NULL; 1726 _err = TrackMouseRegion(inPort, 1727 inRegion, 1728 &ioWasInRgn, 1729 &outResult); 1730 if (_err != noErr) return PyMac_Error(_err); 1731 _res = Py_BuildValue("bH", 1732 ioWasInRgn, 1733 outResult); 1734 return _res; 1747 1735 } 1748 1736 1749 1737 static PyObject *CarbonEvents_GetLastUserEventTime(PyObject *_self, PyObject *_args) 1750 1738 { 1751 1752 1753 1754 1755 1756 1757 1758 1739 PyObject *_res = NULL; 1740 double _rv; 1741 if (!PyArg_ParseTuple(_args, "")) 1742 return NULL; 1743 _rv = GetLastUserEventTime(); 1744 _res = Py_BuildValue("d", 1745 _rv); 1746 return _res; 1759 1747 } 1760 1748 1761 1749 static PyObject *CarbonEvents_IsMouseCoalescingEnabled(PyObject *_self, PyObject *_args) 1762 1750 { 1763 1764 1765 1766 1767 1768 1769 1770 1751 PyObject *_res = NULL; 1752 Boolean _rv; 1753 if (!PyArg_ParseTuple(_args, "")) 1754 return NULL; 1755 _rv = IsMouseCoalescingEnabled(); 1756 _res = Py_BuildValue("b", 1757 _rv); 1758 return _res; 1771 1759 } 1772 1760 1773 1761 static PyObject *CarbonEvents_SetMouseCoalescingEnabled(PyObject *_self, PyObject *_args) 1774 1762 { 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1763 PyObject *_res = NULL; 1764 OSStatus _err; 1765 Boolean inNewState; 1766 Boolean outOldState; 1767 if (!PyArg_ParseTuple(_args, "b", 1768 &inNewState)) 1769 return NULL; 1770 _err = SetMouseCoalescingEnabled(inNewState, 1771 &outOldState); 1772 if (_err != noErr) return PyMac_Error(_err); 1773 _res = Py_BuildValue("b", 1774 outOldState); 1775 return _res; 1788 1776 } 1789 1777 1790 1778 static PyObject *CarbonEvents_GetWindowEventTarget(PyObject *_self, PyObject *_args) 1791 1779 { 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1780 PyObject *_res = NULL; 1781 EventTargetRef _rv; 1782 WindowPtr inWindow; 1783 if (!PyArg_ParseTuple(_args, "O&", 1784 WinObj_Convert, &inWindow)) 1785 return NULL; 1786 _rv = GetWindowEventTarget(inWindow); 1787 _res = Py_BuildValue("O&", 1788 EventTargetRef_New, _rv); 1789 return _res; 1802 1790 } 1803 1791 1804 1792 static PyObject *CarbonEvents_GetControlEventTarget(PyObject *_self, PyObject *_args) 1805 1793 { 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1794 PyObject *_res = NULL; 1795 EventTargetRef _rv; 1796 ControlHandle inControl; 1797 if (!PyArg_ParseTuple(_args, "O&", 1798 CtlObj_Convert, &inControl)) 1799 return NULL; 1800 _rv = GetControlEventTarget(inControl); 1801 _res = Py_BuildValue("O&", 1802 EventTargetRef_New, _rv); 1803 return _res; 1816 1804 } 1817 1805 1818 1806 static PyObject *CarbonEvents_GetMenuEventTarget(PyObject *_self, PyObject *_args) 1819 1807 { 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1808 PyObject *_res = NULL; 1809 EventTargetRef _rv; 1810 MenuHandle inMenu; 1811 if (!PyArg_ParseTuple(_args, "O&", 1812 MenuObj_Convert, &inMenu)) 1813 return NULL; 1814 _rv = GetMenuEventTarget(inMenu); 1815 _res = Py_BuildValue("O&", 1816 EventTargetRef_New, _rv); 1817 return _res; 1830 1818 } 1831 1819 1832 1820 static PyObject *CarbonEvents_GetApplicationEventTarget(PyObject *_self, PyObject *_args) 1833 1821 { 1834 1835 1836 1837 1838 1839 1840 1841 1822 PyObject *_res = NULL; 1823 EventTargetRef _rv; 1824 if (!PyArg_ParseTuple(_args, "")) 1825 return NULL; 1826 _rv = GetApplicationEventTarget(); 1827 _res = Py_BuildValue("O&", 1828 EventTargetRef_New, _rv); 1829 return _res; 1842 1830 } 1843 1831 1844 1832 static PyObject *CarbonEvents_GetUserFocusEventTarget(PyObject *_self, PyObject *_args) 1845 1833 { 1846 1847 1848 1849 1850 1851 1852 1853 1834 PyObject *_res = NULL; 1835 EventTargetRef _rv; 1836 if (!PyArg_ParseTuple(_args, "")) 1837 return NULL; 1838 _rv = GetUserFocusEventTarget(); 1839 _res = Py_BuildValue("O&", 1840 EventTargetRef_New, _rv); 1841 return _res; 1854 1842 } 1855 1843 1856 1844 static PyObject *CarbonEvents_GetEventDispatcherTarget(PyObject *_self, PyObject *_args) 1857 1845 { 1858 1859 1860 1861 1862 1863 1864 1865 1846 PyObject *_res = NULL; 1847 EventTargetRef _rv; 1848 if (!PyArg_ParseTuple(_args, "")) 1849 return NULL; 1850 _rv = GetEventDispatcherTarget(); 1851 _res = Py_BuildValue("O&", 1852 EventTargetRef_New, _rv); 1853 return _res; 1866 1854 } 1867 1855 1868 1856 static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args) 1869 1857 { 1870 1871 1872 1873 1874 1875 1876 1858 PyObject *_res = NULL; 1859 if (!PyArg_ParseTuple(_args, "")) 1860 return NULL; 1861 RunApplicationEventLoop(); 1862 Py_INCREF(Py_None); 1863 _res = Py_None; 1864 return _res; 1877 1865 } 1878 1866 1879 1867 static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args) 1880 1868 { 1881 1882 1883 1884 1885 1886 1887 1869 PyObject *_res = NULL; 1870 if (!PyArg_ParseTuple(_args, "")) 1871 return NULL; 1872 QuitApplicationEventLoop(); 1873 Py_INCREF(Py_None); 1874 _res = Py_None; 1875 return _res; 1888 1876 } 1889 1877 1890 1878 static PyObject *CarbonEvents_RunAppModalLoopForWindow(PyObject *_self, PyObject *_args) 1891 1879 { 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1880 PyObject *_res = NULL; 1881 OSStatus _err; 1882 WindowPtr inWindow; 1883 if (!PyArg_ParseTuple(_args, "O&", 1884 WinObj_Convert, &inWindow)) 1885 return NULL; 1886 _err = RunAppModalLoopForWindow(inWindow); 1887 if (_err != noErr) return PyMac_Error(_err); 1888 Py_INCREF(Py_None); 1889 _res = Py_None; 1890 return _res; 1903 1891 } 1904 1892 1905 1893 static PyObject *CarbonEvents_QuitAppModalLoopForWindow(PyObject *_self, PyObject *_args) 1906 1894 { 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1895 PyObject *_res = NULL; 1896 OSStatus _err; 1897 WindowPtr inWindow; 1898 if (!PyArg_ParseTuple(_args, "O&", 1899 WinObj_Convert, &inWindow)) 1900 return NULL; 1901 _err = QuitAppModalLoopForWindow(inWindow); 1902 if (_err != noErr) return PyMac_Error(_err); 1903 Py_INCREF(Py_None); 1904 _res = Py_None; 1905 return _res; 1918 1906 } 1919 1907 1920 1908 static PyObject *CarbonEvents_BeginAppModalStateForWindow(PyObject *_self, PyObject *_args) 1921 1909 { 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1910 PyObject *_res = NULL; 1911 OSStatus _err; 1912 WindowPtr inWindow; 1913 if (!PyArg_ParseTuple(_args, "O&", 1914 WinObj_Convert, &inWindow)) 1915 return NULL; 1916 _err = BeginAppModalStateForWindow(inWindow); 1917 if (_err != noErr) return PyMac_Error(_err); 1918 Py_INCREF(Py_None); 1919 _res = Py_None; 1920 return _res; 1933 1921 } 1934 1922 1935 1923 static PyObject *CarbonEvents_EndAppModalStateForWindow(PyObject *_self, PyObject *_args) 1936 1924 { 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1925 PyObject *_res = NULL; 1926 OSStatus _err; 1927 WindowPtr inWindow; 1928 if (!PyArg_ParseTuple(_args, "O&", 1929 WinObj_Convert, &inWindow)) 1930 return NULL; 1931 _err = EndAppModalStateForWindow(inWindow); 1932 if (_err != noErr) return PyMac_Error(_err); 1933 Py_INCREF(Py_None); 1934 _res = Py_None; 1935 return _res; 1948 1936 } 1949 1937 1950 1938 static PyObject *CarbonEvents_SetUserFocusWindow(PyObject *_self, PyObject *_args) 1951 1939 { 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1940 PyObject *_res = NULL; 1941 OSStatus _err; 1942 WindowPtr inWindow; 1943 if (!PyArg_ParseTuple(_args, "O&", 1944 WinObj_Convert, &inWindow)) 1945 return NULL; 1946 _err = SetUserFocusWindow(inWindow); 1947 if (_err != noErr) return PyMac_Error(_err); 1948 Py_INCREF(Py_None); 1949 _res = Py_None; 1950 return _res; 1963 1951 } 1964 1952 1965 1953 static PyObject *CarbonEvents_GetUserFocusWindow(PyObject *_self, PyObject *_args) 1966 1954 { 1967 1968 1969 1970 1971 1972 1973 1974 1955 PyObject *_res = NULL; 1956 WindowPtr _rv; 1957 if (!PyArg_ParseTuple(_args, "")) 1958 return NULL; 1959 _rv = GetUserFocusWindow(); 1960 _res = Py_BuildValue("O&", 1961 WinObj_New, _rv); 1962 return _res; 1975 1963 } 1976 1964 1977 1965 static PyObject *CarbonEvents_SetWindowDefaultButton(PyObject *_self, PyObject *_args) 1978 1966 { 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1967 PyObject *_res = NULL; 1968 OSStatus _err; 1969 WindowPtr inWindow; 1970 ControlHandle inControl; 1971 if (!PyArg_ParseTuple(_args, "O&O&", 1972 WinObj_Convert, &inWindow, 1973 CtlObj_Convert, &inControl)) 1974 return NULL; 1975 _err = SetWindowDefaultButton(inWindow, 1976 inControl); 1977 if (_err != noErr) return PyMac_Error(_err); 1978 Py_INCREF(Py_None); 1979 _res = Py_None; 1980 return _res; 1993 1981 } 1994 1982 1995 1983 static PyObject *CarbonEvents_SetWindowCancelButton(PyObject *_self, PyObject *_args) 1996 1984 { 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 1985 PyObject *_res = NULL; 1986 OSStatus _err; 1987 WindowPtr inWindow; 1988 ControlHandle inControl; 1989 if (!PyArg_ParseTuple(_args, "O&O&", 1990 WinObj_Convert, &inWindow, 1991 CtlObj_Convert, &inControl)) 1992 return NULL; 1993 _err = SetWindowCancelButton(inWindow, 1994 inControl); 1995 if (_err != noErr) return PyMac_Error(_err); 1996 Py_INCREF(Py_None); 1997 _res = Py_None; 1998 return _res; 2011 1999 } 2012 2000 2013 2001 static PyObject *CarbonEvents_GetWindowDefaultButton(PyObject *_self, PyObject *_args) 2014 2002 { 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2003 PyObject *_res = NULL; 2004 OSStatus _err; 2005 WindowPtr inWindow; 2006 ControlHandle outControl; 2007 if (!PyArg_ParseTuple(_args, "O&", 2008 WinObj_Convert, &inWindow)) 2009 return NULL; 2010 _err = GetWindowDefaultButton(inWindow, 2011 &outControl); 2012 if (_err != noErr) return PyMac_Error(_err); 2013 _res = Py_BuildValue("O&", 2014 CtlObj_New, outControl); 2015 return _res; 2028 2016 } 2029 2017 2030 2018 static PyObject *CarbonEvents_GetWindowCancelButton(PyObject *_self, PyObject *_args) 2031 2019 { 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2020 PyObject *_res = NULL; 2021 OSStatus _err; 2022 WindowPtr inWindow; 2023 ControlHandle outControl; 2024 if (!PyArg_ParseTuple(_args, "O&", 2025 WinObj_Convert, &inWindow)) 2026 return NULL; 2027 _err = GetWindowCancelButton(inWindow, 2028 &outControl); 2029 if (_err != noErr) return PyMac_Error(_err); 2030 _res = Py_BuildValue("O&", 2031 CtlObj_New, outControl); 2032 return _res; 2045 2033 } 2046 2034 2047 2035 static PyObject *CarbonEvents_RegisterEventHotKey(PyObject *_self, PyObject *_args) 2048 2036 { 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2037 PyObject *_res = NULL; 2038 OSStatus _err; 2039 UInt32 inHotKeyCode; 2040 UInt32 inHotKeyModifiers; 2041 EventHotKeyID inHotKeyID; 2042 EventTargetRef inTarget; 2043 OptionBits inOptions; 2044 EventHotKeyRef outRef; 2045 if (!PyArg_ParseTuple(_args, "llO&O&l", 2046 &inHotKeyCode, 2047 &inHotKeyModifiers, 2048 EventHotKeyID_Convert, &inHotKeyID, 2049 EventTargetRef_Convert, &inTarget, 2050 &inOptions)) 2051 return NULL; 2052 _err = RegisterEventHotKey(inHotKeyCode, 2053 inHotKeyModifiers, 2054 inHotKeyID, 2055 inTarget, 2056 inOptions, 2057 &outRef); 2058 if (_err != noErr) return PyMac_Error(_err); 2059 _res = Py_BuildValue("O&", 2060 EventHotKeyRef_New, outRef); 2061 return _res; 2074 2062 } 2075 2063 2076 2064 static PyMethodDef CarbonEvents_methods[] = { 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2065 {"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1, 2066 PyDoc_STR("() -> (EventLoopRef _rv)")}, 2067 {"GetMainEventLoop", (PyCFunction)CarbonEvents_GetMainEventLoop, 1, 2068 PyDoc_STR("() -> (EventLoopRef _rv)")}, 2069 {"RunCurrentEventLoop", (PyCFunction)CarbonEvents_RunCurrentEventLoop, 1, 2070 PyDoc_STR("(double inTimeout) -> None")}, 2071 {"ReceiveNextEvent", (PyCFunction)CarbonEvents_ReceiveNextEvent, 1, 2072 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList, double inTimeout, Boolean inPullEvent) -> (EventRef outEvent)")}, 2073 {"GetCurrentEventQueue", (PyCFunction)CarbonEvents_GetCurrentEventQueue, 1, 2074 PyDoc_STR("() -> (EventQueueRef _rv)")}, 2075 {"GetMainEventQueue", (PyCFunction)CarbonEvents_GetMainEventQueue, 1, 2076 PyDoc_STR("() -> (EventQueueRef _rv)")}, 2077 {"GetCurrentEventTime", (PyCFunction)CarbonEvents_GetCurrentEventTime, 1, 2078 PyDoc_STR("() -> (double _rv)")}, 2079 {"TrackMouseLocation", (PyCFunction)CarbonEvents_TrackMouseLocation, 1, 2080 PyDoc_STR("(GrafPtr inPort) -> (Point outPt, UInt16 outResult)")}, 2081 {"TrackMouseLocationWithOptions", (PyCFunction)CarbonEvents_TrackMouseLocationWithOptions, 1, 2082 PyDoc_STR("(GrafPtr inPort, OptionBits inOptions, double inTimeout) -> (Point outPt, UInt32 outModifiers, UInt16 outResult)")}, 2083 {"TrackMouseRegion", (PyCFunction)CarbonEvents_TrackMouseRegion, 1, 2084 PyDoc_STR("(GrafPtr inPort, RgnHandle inRegion, Boolean ioWasInRgn) -> (Boolean ioWasInRgn, UInt16 outResult)")}, 2085 {"GetLastUserEventTime", (PyCFunction)CarbonEvents_GetLastUserEventTime, 1, 2086 PyDoc_STR("() -> (double _rv)")}, 2087 {"IsMouseCoalescingEnabled", (PyCFunction)CarbonEvents_IsMouseCoalescingEnabled, 1, 2088 PyDoc_STR("() -> (Boolean _rv)")}, 2089 {"SetMouseCoalescingEnabled", (PyCFunction)CarbonEvents_SetMouseCoalescingEnabled, 1, 2090 PyDoc_STR("(Boolean inNewState) -> (Boolean outOldState)")}, 2091 {"GetWindowEventTarget", (PyCFunction)CarbonEvents_GetWindowEventTarget, 1, 2092 PyDoc_STR("(WindowPtr inWindow) -> (EventTargetRef _rv)")}, 2093 {"GetControlEventTarget", (PyCFunction)CarbonEvents_GetControlEventTarget, 1, 2094 PyDoc_STR("(ControlHandle inControl) -> (EventTargetRef _rv)")}, 2095 {"GetMenuEventTarget", (PyCFunction)CarbonEvents_GetMenuEventTarget, 1, 2096 PyDoc_STR("(MenuHandle inMenu) -> (EventTargetRef _rv)")}, 2097 {"GetApplicationEventTarget", (PyCFunction)CarbonEvents_GetApplicationEventTarget, 1, 2098 PyDoc_STR("() -> (EventTargetRef _rv)")}, 2099 {"GetUserFocusEventTarget", (PyCFunction)CarbonEvents_GetUserFocusEventTarget, 1, 2100 PyDoc_STR("() -> (EventTargetRef _rv)")}, 2101 {"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1, 2102 PyDoc_STR("() -> (EventTargetRef _rv)")}, 2103 {"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1, 2104 PyDoc_STR("() -> None")}, 2105 {"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1, 2106 PyDoc_STR("() -> None")}, 2107 {"RunAppModalLoopForWindow", (PyCFunction)CarbonEvents_RunAppModalLoopForWindow, 1, 2108 PyDoc_STR("(WindowPtr inWindow) -> None")}, 2109 {"QuitAppModalLoopForWindow", (PyCFunction)CarbonEvents_QuitAppModalLoopForWindow, 1, 2110 PyDoc_STR("(WindowPtr inWindow) -> None")}, 2111 {"BeginAppModalStateForWindow", (PyCFunction)CarbonEvents_BeginAppModalStateForWindow, 1, 2112 PyDoc_STR("(WindowPtr inWindow) -> None")}, 2113 {"EndAppModalStateForWindow", (PyCFunction)CarbonEvents_EndAppModalStateForWindow, 1, 2114 PyDoc_STR("(WindowPtr inWindow) -> None")}, 2115 {"SetUserFocusWindow", (PyCFunction)CarbonEvents_SetUserFocusWindow, 1, 2116 PyDoc_STR("(WindowPtr inWindow) -> None")}, 2117 {"GetUserFocusWindow", (PyCFunction)CarbonEvents_GetUserFocusWindow, 1, 2118 PyDoc_STR("() -> (WindowPtr _rv)")}, 2119 {"SetWindowDefaultButton", (PyCFunction)CarbonEvents_SetWindowDefaultButton, 1, 2120 PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")}, 2121 {"SetWindowCancelButton", (PyCFunction)CarbonEvents_SetWindowCancelButton, 1, 2122 PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")}, 2123 {"GetWindowDefaultButton", (PyCFunction)CarbonEvents_GetWindowDefaultButton, 1, 2124 PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")}, 2125 {"GetWindowCancelButton", (PyCFunction)CarbonEvents_GetWindowCancelButton, 1, 2126 PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")}, 2127 {"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1, 2128 PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")}, 2129 {NULL, NULL, 0} 2142 2130 }; 2143 2131 … … 2145 2133 2146 2134 static PyMethodDef CarbonEvents_methods[] = { 2147 2135 {NULL, NULL, 0} 2148 2136 }; 2149 2137 … … 2154 2142 void init_CarbonEvt(void) 2155 2143 { 2156 2144 PyObject *m; 2157 2145 #ifndef __LP64__ 2158 2146 PyObject *d; 2159 2147 #endif /* !__LP64__ */ 2160 2148 2161 2149 2162 2150 m = Py_InitModule("_CarbonEvt", CarbonEvents_methods); 2163 2151 2164 2152 #ifndef __LP64__ 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2153 myEventHandlerUPP = NewEventHandlerUPP(myEventHandler); 2154 d = PyModule_GetDict(m); 2155 CarbonEvents_Error = PyMac_GetOSErrException(); 2156 if (CarbonEvents_Error == NULL || 2157 PyDict_SetItemString(d, "Error", CarbonEvents_Error) != 0) 2158 return; 2159 EventRef_Type.ob_type = &PyType_Type; 2160 if (PyType_Ready(&EventRef_Type) < 0) return; 2161 Py_INCREF(&EventRef_Type); 2162 PyModule_AddObject(m, "EventRef", (PyObject *)&EventRef_Type); 2163 /* Backward-compatible name */ 2164 Py_INCREF(&EventRef_Type); 2165 PyModule_AddObject(m, "EventRefType", (PyObject *)&EventRef_Type); 2166 EventQueueRef_Type.ob_type = &PyType_Type; 2167 if (PyType_Ready(&EventQueueRef_Type) < 0) return; 2168 Py_INCREF(&EventQueueRef_Type); 2169 PyModule_AddObject(m, "EventQueueRef", (PyObject *)&EventQueueRef_Type); 2170 /* Backward-compatible name */ 2171 Py_INCREF(&EventQueueRef_Type); 2172 PyModule_AddObject(m, "EventQueueRefType", (PyObject *)&EventQueueRef_Type); 2173 EventLoopRef_Type.ob_type = &PyType_Type; 2174 if (PyType_Ready(&EventLoopRef_Type) < 0) return; 2175 Py_INCREF(&EventLoopRef_Type); 2176 PyModule_AddObject(m, "EventLoopRef", (PyObject *)&EventLoopRef_Type); 2177 /* Backward-compatible name */ 2178 Py_INCREF(&EventLoopRef_Type); 2179 PyModule_AddObject(m, "EventLoopRefType", (PyObject *)&EventLoopRef_Type); 2180 EventLoopTimerRef_Type.ob_type = &PyType_Type; 2181 if (PyType_Ready(&EventLoopTimerRef_Type) < 0) return; 2182 Py_INCREF(&EventLoopTimerRef_Type); 2183 PyModule_AddObject(m, "EventLoopTimerRef", (PyObject *)&EventLoopTimerRef_Type); 2184 /* Backward-compatible name */ 2185 Py_INCREF(&EventLoopTimerRef_Type); 2186 PyModule_AddObject(m, "EventLoopTimerRefType", (PyObject *)&EventLoopTimerRef_Type); 2187 EventHandlerRef_Type.ob_type = &PyType_Type; 2188 if (PyType_Ready(&EventHandlerRef_Type) < 0) return; 2189 Py_INCREF(&EventHandlerRef_Type); 2190 PyModule_AddObject(m, "EventHandlerRef", (PyObject *)&EventHandlerRef_Type); 2191 /* Backward-compatible name */ 2192 Py_INCREF(&EventHandlerRef_Type); 2193 PyModule_AddObject(m, "EventHandlerRefType", (PyObject *)&EventHandlerRef_Type); 2194 EventHandlerCallRef_Type.ob_type = &PyType_Type; 2195 if (PyType_Ready(&EventHandlerCallRef_Type) < 0) return; 2196 Py_INCREF(&EventHandlerCallRef_Type); 2197 PyModule_AddObject(m, "EventHandlerCallRef", (PyObject *)&EventHandlerCallRef_Type); 2198 /* Backward-compatible name */ 2199 Py_INCREF(&EventHandlerCallRef_Type); 2200 PyModule_AddObject(m, "EventHandlerCallRefType", (PyObject *)&EventHandlerCallRef_Type); 2201 EventTargetRef_Type.ob_type = &PyType_Type; 2202 if (PyType_Ready(&EventTargetRef_Type) < 0) return; 2203 Py_INCREF(&EventTargetRef_Type); 2204 PyModule_AddObject(m, "EventTargetRef", (PyObject *)&EventTargetRef_Type); 2205 /* Backward-compatible name */ 2206 Py_INCREF(&EventTargetRef_Type); 2207 PyModule_AddObject(m, "EventTargetRefType", (PyObject *)&EventTargetRef_Type); 2208 EventHotKeyRef_Type.ob_type = &PyType_Type; 2209 if (PyType_Ready(&EventHotKeyRef_Type) < 0) return; 2210 Py_INCREF(&EventHotKeyRef_Type); 2211 PyModule_AddObject(m, "EventHotKeyRef", (PyObject *)&EventHotKeyRef_Type); 2212 /* Backward-compatible name */ 2213 Py_INCREF(&EventHotKeyRef_Type); 2214 PyModule_AddObject(m, "EventHotKeyRefType", (PyObject *)&EventHotKeyRef_Type); 2227 2215 #endif /* !__LP64__ */ 2228 2216 }
Note:
See TracChangeset
for help on using the changeset viewer.