2 /* ======================= Module _CarbonEvt ======================== */
8 #ifdef WITHOUT_FRAMEWORKS
9 #include <CarbonEvents.h>
11 #include <Carbon/Carbon.h>
16 /* Macro to test whether a weak-loaded CFM function exists */
17 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
18 PyErr_SetString(PyExc_NotImplementedError, \
19 "Not available in this shared library/OS version"); \
24 #define USE_MAC_MP_MULTITHREADING 0
26 #if USE_MAC_MP_MULTITHREADING
27 static PyThreadState
*_save
;
28 static MPCriticalRegionID reentrantLock
;
29 #endif /* USE_MAC_MP_MULTITHREADING */
31 extern int CFStringRef_New(CFStringRef
*);
33 extern int CFStringRef_Convert(PyObject
*, CFStringRef
*);
34 extern int CFBundleRef_Convert(PyObject
*, CFBundleRef
*);
36 int EventTargetRef_Convert(PyObject
*, EventTargetRef
*);
37 PyObject
*EventHandlerCallRef_New(EventHandlerCallRef itself
);
38 PyObject
*EventRef_New(EventRef itself
);
40 /********** EventTypeSpec *******/
42 EventTypeSpec_New(EventTypeSpec
*in
)
44 return Py_BuildValue("ll", in
->eventClass
, in
->eventKind
);
48 EventTypeSpec_Convert(PyObject
*v
, EventTypeSpec
*out
)
50 if (PyArg_Parse(v
, "(O&l)",
51 PyMac_GetOSType
, &(out
->eventClass
),
57 /********** end EventTypeSpec *******/
59 /********** HIPoint *******/
61 #if 0 /* XXX doesn't compile */
63 HIPoint_New(HIPoint
*in
)
65 return Py_BuildValue("ff", in
->x
, in
->y
);
69 HIPoint_Convert(PyObject
*v
, HIPoint
*out
)
71 if (PyArg_ParseTuple(v
, "ff", &(out
->x
), &(out
->y
)))
77 /********** end HIPoint *******/
79 /********** EventHotKeyID *******/
82 EventHotKeyID_New(EventHotKeyID
*in
)
84 return Py_BuildValue("ll", in
->signature
, in
->id
);
88 EventHotKeyID_Convert(PyObject
*v
, EventHotKeyID
*out
)
90 if (PyArg_ParseTuple(v
, "ll", &out
->signature
, &out
->id
))
95 /********** end EventHotKeyID *******/
97 /******** myEventHandler ***********/
99 static EventHandlerUPP myEventHandlerUPP
;
101 static pascal OSStatus
102 myEventHandler(EventHandlerCallRef handlerRef
, EventRef event
, void *outPyObject
) {
106 #if USE_MAC_MP_MULTITHREADING
107 MPEnterCriticalRegion(reentrantLock
, kDurationForever
);
108 PyEval_RestoreThread(_save
);
109 #endif /* USE_MAC_MP_MULTITHREADING */
111 retValue
= PyObject_CallFunction((PyObject
*)outPyObject
, "O&O&",
112 EventHandlerCallRef_New
, handlerRef
,
113 EventRef_New
, event
);
114 if (retValue
== NULL
) {
115 PySys_WriteStderr("Error in event handler callback:\n");
116 PyErr_Print(); /* this also clears the error */
117 status
= noErr
; /* complain? how? */
119 if (retValue
== Py_None
)
121 else if (PyInt_Check(retValue
)) {
122 status
= PyInt_AsLong(retValue
);
124 status
= noErr
; /* wrong object type, complain? */
128 #if USE_MAC_MP_MULTITHREADING
129 _save
= PyEval_SaveThread();
130 MPExitCriticalRegion(reentrantLock
);
131 #endif /* USE_MAC_MP_MULTITHREADING */
136 /******** end myEventHandler ***********/
139 static PyObject
*CarbonEvents_Error
;
141 /* ---------------------- Object type EventRef ---------------------- */
143 PyTypeObject EventRef_Type
;
145 #define EventRef_Check(x) ((x)->ob_type == &EventRef_Type || PyObject_TypeCheck((x), &EventRef_Type))
147 typedef struct EventRefObject
{
152 PyObject
*EventRef_New(EventRef itself
)
155 it
= PyObject_NEW(EventRefObject
, &EventRef_Type
);
156 if (it
== NULL
) return NULL
;
157 it
->ob_itself
= itself
;
158 return (PyObject
*)it
;
160 int EventRef_Convert(PyObject
*v
, EventRef
*p_itself
)
162 if (!EventRef_Check(v
))
164 PyErr_SetString(PyExc_TypeError
, "EventRef required");
167 *p_itself
= ((EventRefObject
*)v
)->ob_itself
;
171 static void EventRef_dealloc(EventRefObject
*self
)
173 /* Cleanup of self->ob_itself goes here */
174 self
->ob_type
->tp_free((PyObject
*)self
);
177 static PyObject
*EventRef_RetainEvent(EventRefObject
*_self
, PyObject
*_args
)
179 PyObject
*_res
= NULL
;
181 if (!PyArg_ParseTuple(_args
, ""))
183 _rv
= RetainEvent(_self
->ob_itself
);
184 _res
= Py_BuildValue("O&",
189 static PyObject
*EventRef_GetEventRetainCount(EventRefObject
*_self
, PyObject
*_args
)
191 PyObject
*_res
= NULL
;
193 if (!PyArg_ParseTuple(_args
, ""))
195 _rv
= GetEventRetainCount(_self
->ob_itself
);
196 _res
= Py_BuildValue("l",
201 static PyObject
*EventRef_ReleaseEvent(EventRefObject
*_self
, PyObject
*_args
)
203 PyObject
*_res
= NULL
;
204 if (!PyArg_ParseTuple(_args
, ""))
206 ReleaseEvent(_self
->ob_itself
);
212 static PyObject
*EventRef_SetEventParameter(EventRefObject
*_self
, PyObject
*_args
)
214 PyObject
*_res
= NULL
;
218 char *inDataPtr__in__
;
219 long inDataPtr__len__
;
220 int inDataPtr__in_len__
;
221 if (!PyArg_ParseTuple(_args
, "O&O&s#",
222 PyMac_GetOSType
, &inName
,
223 PyMac_GetOSType
, &inType
,
224 &inDataPtr__in__
, &inDataPtr__in_len__
))
226 inDataPtr__len__
= inDataPtr__in_len__
;
227 _err
= SetEventParameter(_self
->ob_itself
,
230 inDataPtr__len__
, inDataPtr__in__
);
231 if (_err
!= noErr
) return PyMac_Error(_err
);
237 static PyObject
*EventRef_GetEventClass(EventRefObject
*_self
, PyObject
*_args
)
239 PyObject
*_res
= NULL
;
241 if (!PyArg_ParseTuple(_args
, ""))
243 _rv
= GetEventClass(_self
->ob_itself
);
244 _res
= Py_BuildValue("l",
249 static PyObject
*EventRef_GetEventKind(EventRefObject
*_self
, PyObject
*_args
)
251 PyObject
*_res
= NULL
;
253 if (!PyArg_ParseTuple(_args
, ""))
255 _rv
= GetEventKind(_self
->ob_itself
);
256 _res
= Py_BuildValue("l",
261 static PyObject
*EventRef_GetEventTime(EventRefObject
*_self
, PyObject
*_args
)
263 PyObject
*_res
= NULL
;
265 if (!PyArg_ParseTuple(_args
, ""))
267 _rv
= GetEventTime(_self
->ob_itself
);
268 _res
= Py_BuildValue("d",
273 static PyObject
*EventRef_SetEventTime(EventRefObject
*_self
, PyObject
*_args
)
275 PyObject
*_res
= NULL
;
278 if (!PyArg_ParseTuple(_args
, "d",
281 _err
= SetEventTime(_self
->ob_itself
,
283 if (_err
!= noErr
) return PyMac_Error(_err
);
289 static PyObject
*EventRef_IsUserCancelEventRef(EventRefObject
*_self
, PyObject
*_args
)
291 PyObject
*_res
= NULL
;
293 if (!PyArg_ParseTuple(_args
, ""))
295 _rv
= IsUserCancelEventRef(_self
->ob_itself
);
296 _res
= Py_BuildValue("b",
301 static PyObject
*EventRef_ConvertEventRefToEventRecord(EventRefObject
*_self
, PyObject
*_args
)
303 PyObject
*_res
= NULL
;
305 EventRecord outEvent
;
306 if (!PyArg_ParseTuple(_args
, ""))
308 _rv
= ConvertEventRefToEventRecord(_self
->ob_itself
,
310 _res
= Py_BuildValue("bO&",
312 PyMac_BuildEventRecord
, &outEvent
);
316 static PyObject
*EventRef_IsEventInMask(EventRefObject
*_self
, PyObject
*_args
)
318 PyObject
*_res
= NULL
;
321 if (!PyArg_ParseTuple(_args
, "H",
324 _rv
= IsEventInMask(_self
->ob_itself
,
326 _res
= Py_BuildValue("b",
331 static PyObject
*EventRef_SendEventToEventTarget(EventRefObject
*_self
, PyObject
*_args
)
333 PyObject
*_res
= NULL
;
335 EventTargetRef inTarget
;
336 if (!PyArg_ParseTuple(_args
, "O&",
337 EventTargetRef_Convert
, &inTarget
))
339 _err
= SendEventToEventTarget(_self
->ob_itself
,
341 if (_err
!= noErr
) return PyMac_Error(_err
);
347 static PyObject
*EventRef_GetEventParameter(EventRefObject
*_self
, PyObject
*_args
)
349 PyObject
*_res
= NULL
;
352 EventParamName inName
;
353 EventParamType inType
;
357 if (!PyArg_ParseTuple(_args
, "O&O&", PyMac_GetOSType
, &inName
, PyMac_GetOSType
, &inType
))
360 /* Figure out the size by passing a null buffer to GetEventParameter */
361 _err
= GetEventParameter(_self
->ob_itself
, inName
, inType
, NULL
, 0, &bufferSize
, NULL
);
364 return PyMac_Error(_err
);
365 buffer
= PyMem_NEW(char, bufferSize
);
367 return PyErr_NoMemory();
369 _err
= GetEventParameter(_self
->ob_itself
, inName
, inType
, NULL
, bufferSize
, NULL
, buffer
);
373 return PyMac_Error(_err
);
375 _res
= Py_BuildValue("s#", buffer
, bufferSize
);
381 static PyMethodDef EventRef_methods
[] = {
382 {"RetainEvent", (PyCFunction
)EventRef_RetainEvent
, 1,
383 PyDoc_STR("() -> (EventRef _rv)")},
384 {"GetEventRetainCount", (PyCFunction
)EventRef_GetEventRetainCount
, 1,
385 PyDoc_STR("() -> (UInt32 _rv)")},
386 {"ReleaseEvent", (PyCFunction
)EventRef_ReleaseEvent
, 1,
387 PyDoc_STR("() -> None")},
388 {"SetEventParameter", (PyCFunction
)EventRef_SetEventParameter
, 1,
389 PyDoc_STR("(OSType inName, OSType inType, Buffer inDataPtr) -> None")},
390 {"GetEventClass", (PyCFunction
)EventRef_GetEventClass
, 1,
391 PyDoc_STR("() -> (UInt32 _rv)")},
392 {"GetEventKind", (PyCFunction
)EventRef_GetEventKind
, 1,
393 PyDoc_STR("() -> (UInt32 _rv)")},
394 {"GetEventTime", (PyCFunction
)EventRef_GetEventTime
, 1,
395 PyDoc_STR("() -> (double _rv)")},
396 {"SetEventTime", (PyCFunction
)EventRef_SetEventTime
, 1,
397 PyDoc_STR("(double inTime) -> None")},
398 {"IsUserCancelEventRef", (PyCFunction
)EventRef_IsUserCancelEventRef
, 1,
399 PyDoc_STR("() -> (Boolean _rv)")},
400 {"ConvertEventRefToEventRecord", (PyCFunction
)EventRef_ConvertEventRefToEventRecord
, 1,
401 PyDoc_STR("() -> (Boolean _rv, EventRecord outEvent)")},
402 {"IsEventInMask", (PyCFunction
)EventRef_IsEventInMask
, 1,
403 PyDoc_STR("(UInt16 inMask) -> (Boolean _rv)")},
404 {"SendEventToEventTarget", (PyCFunction
)EventRef_SendEventToEventTarget
, 1,
405 PyDoc_STR("(EventTargetRef inTarget) -> None")},
406 {"GetEventParameter", (PyCFunction
)EventRef_GetEventParameter
, 1,
407 PyDoc_STR("(EventParamName eventName, EventParamType eventType) -> (String eventParamData)")},
411 #define EventRef_getsetlist NULL
414 #define EventRef_compare NULL
416 #define EventRef_repr NULL
418 #define EventRef_hash NULL
419 #define EventRef_tp_init 0
421 #define EventRef_tp_alloc PyType_GenericAlloc
423 static PyObject
*EventRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
427 char *kw
[] = {"itself", 0};
429 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventRef_Convert
, &itself
)) return NULL
;
430 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
431 ((EventRefObject
*)self
)->ob_itself
= itself
;
435 #define EventRef_tp_free PyObject_Del
438 PyTypeObject EventRef_Type
= {
439 PyObject_HEAD_INIT(NULL
)
441 "_CarbonEvt.EventRef", /*tp_name*/
442 sizeof(EventRefObject
), /*tp_basicsize*/
445 (destructor
) EventRef_dealloc
, /*tp_dealloc*/
447 (getattrfunc
)0, /*tp_getattr*/
448 (setattrfunc
)0, /*tp_setattr*/
449 (cmpfunc
) EventRef_compare
, /*tp_compare*/
450 (reprfunc
) EventRef_repr
, /*tp_repr*/
451 (PyNumberMethods
*)0, /* tp_as_number */
452 (PySequenceMethods
*)0, /* tp_as_sequence */
453 (PyMappingMethods
*)0, /* tp_as_mapping */
454 (hashfunc
) EventRef_hash
, /*tp_hash*/
457 PyObject_GenericGetAttr
, /*tp_getattro*/
458 PyObject_GenericSetAttr
, /*tp_setattro */
460 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
464 0, /*tp_richcompare*/
465 0, /*tp_weaklistoffset*/
468 EventRef_methods
, /* tp_methods */
470 EventRef_getsetlist
, /*tp_getset*/
476 EventRef_tp_init
, /* tp_init */
477 EventRef_tp_alloc
, /* tp_alloc */
478 EventRef_tp_new
, /* tp_new */
479 EventRef_tp_free
, /* tp_free */
482 /* -------------------- End object type EventRef -------------------- */
485 /* ------------------- Object type EventQueueRef -------------------- */
487 PyTypeObject EventQueueRef_Type
;
489 #define EventQueueRef_Check(x) ((x)->ob_type == &EventQueueRef_Type || PyObject_TypeCheck((x), &EventQueueRef_Type))
491 typedef struct EventQueueRefObject
{
493 EventQueueRef ob_itself
;
494 } EventQueueRefObject
;
496 PyObject
*EventQueueRef_New(EventQueueRef itself
)
498 EventQueueRefObject
*it
;
499 it
= PyObject_NEW(EventQueueRefObject
, &EventQueueRef_Type
);
500 if (it
== NULL
) return NULL
;
501 it
->ob_itself
= itself
;
502 return (PyObject
*)it
;
504 int EventQueueRef_Convert(PyObject
*v
, EventQueueRef
*p_itself
)
506 if (!EventQueueRef_Check(v
))
508 PyErr_SetString(PyExc_TypeError
, "EventQueueRef required");
511 *p_itself
= ((EventQueueRefObject
*)v
)->ob_itself
;
515 static void EventQueueRef_dealloc(EventQueueRefObject
*self
)
517 /* Cleanup of self->ob_itself goes here */
518 self
->ob_type
->tp_free((PyObject
*)self
);
521 static PyObject
*EventQueueRef_PostEventToQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
523 PyObject
*_res
= NULL
;
527 if (!PyArg_ParseTuple(_args
, "O&h",
528 EventRef_Convert
, &inEvent
,
531 _err
= PostEventToQueue(_self
->ob_itself
,
534 if (_err
!= noErr
) return PyMac_Error(_err
);
540 static PyObject
*EventQueueRef_FlushEventsMatchingListFromQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
542 PyObject
*_res
= NULL
;
545 EventTypeSpec inList
;
546 if (!PyArg_ParseTuple(_args
, "lO&",
548 EventTypeSpec_Convert
, &inList
))
550 _err
= FlushEventsMatchingListFromQueue(_self
->ob_itself
,
553 if (_err
!= noErr
) return PyMac_Error(_err
);
559 static PyObject
*EventQueueRef_FlushEventQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
561 PyObject
*_res
= NULL
;
563 if (!PyArg_ParseTuple(_args
, ""))
565 _err
= FlushEventQueue(_self
->ob_itself
);
566 if (_err
!= noErr
) return PyMac_Error(_err
);
572 static PyObject
*EventQueueRef_GetNumEventsInQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
574 PyObject
*_res
= NULL
;
576 if (!PyArg_ParseTuple(_args
, ""))
578 _rv
= GetNumEventsInQueue(_self
->ob_itself
);
579 _res
= Py_BuildValue("l",
584 static PyObject
*EventQueueRef_RemoveEventFromQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
586 PyObject
*_res
= NULL
;
589 if (!PyArg_ParseTuple(_args
, "O&",
590 EventRef_Convert
, &inEvent
))
592 _err
= RemoveEventFromQueue(_self
->ob_itself
,
594 if (_err
!= noErr
) return PyMac_Error(_err
);
600 static PyObject
*EventQueueRef_IsEventInQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
602 PyObject
*_res
= NULL
;
605 if (!PyArg_ParseTuple(_args
, "O&",
606 EventRef_Convert
, &inEvent
))
608 _rv
= IsEventInQueue(_self
->ob_itself
,
610 _res
= Py_BuildValue("b",
615 static PyMethodDef EventQueueRef_methods
[] = {
616 {"PostEventToQueue", (PyCFunction
)EventQueueRef_PostEventToQueue
, 1,
617 PyDoc_STR("(EventRef inEvent, SInt16 inPriority) -> None")},
618 {"FlushEventsMatchingListFromQueue", (PyCFunction
)EventQueueRef_FlushEventsMatchingListFromQueue
, 1,
619 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")},
620 {"FlushEventQueue", (PyCFunction
)EventQueueRef_FlushEventQueue
, 1,
621 PyDoc_STR("() -> None")},
622 {"GetNumEventsInQueue", (PyCFunction
)EventQueueRef_GetNumEventsInQueue
, 1,
623 PyDoc_STR("() -> (UInt32 _rv)")},
624 {"RemoveEventFromQueue", (PyCFunction
)EventQueueRef_RemoveEventFromQueue
, 1,
625 PyDoc_STR("(EventRef inEvent) -> None")},
626 {"IsEventInQueue", (PyCFunction
)EventQueueRef_IsEventInQueue
, 1,
627 PyDoc_STR("(EventRef inEvent) -> (Boolean _rv)")},
631 #define EventQueueRef_getsetlist NULL
634 #define EventQueueRef_compare NULL
636 #define EventQueueRef_repr NULL
638 #define EventQueueRef_hash NULL
639 #define EventQueueRef_tp_init 0
641 #define EventQueueRef_tp_alloc PyType_GenericAlloc
643 static PyObject
*EventQueueRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
646 EventQueueRef itself
;
647 char *kw
[] = {"itself", 0};
649 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventQueueRef_Convert
, &itself
)) return NULL
;
650 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
651 ((EventQueueRefObject
*)self
)->ob_itself
= itself
;
655 #define EventQueueRef_tp_free PyObject_Del
658 PyTypeObject EventQueueRef_Type
= {
659 PyObject_HEAD_INIT(NULL
)
661 "_CarbonEvt.EventQueueRef", /*tp_name*/
662 sizeof(EventQueueRefObject
), /*tp_basicsize*/
665 (destructor
) EventQueueRef_dealloc
, /*tp_dealloc*/
667 (getattrfunc
)0, /*tp_getattr*/
668 (setattrfunc
)0, /*tp_setattr*/
669 (cmpfunc
) EventQueueRef_compare
, /*tp_compare*/
670 (reprfunc
) EventQueueRef_repr
, /*tp_repr*/
671 (PyNumberMethods
*)0, /* tp_as_number */
672 (PySequenceMethods
*)0, /* tp_as_sequence */
673 (PyMappingMethods
*)0, /* tp_as_mapping */
674 (hashfunc
) EventQueueRef_hash
, /*tp_hash*/
677 PyObject_GenericGetAttr
, /*tp_getattro*/
678 PyObject_GenericSetAttr
, /*tp_setattro */
680 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
684 0, /*tp_richcompare*/
685 0, /*tp_weaklistoffset*/
688 EventQueueRef_methods
, /* tp_methods */
690 EventQueueRef_getsetlist
, /*tp_getset*/
696 EventQueueRef_tp_init
, /* tp_init */
697 EventQueueRef_tp_alloc
, /* tp_alloc */
698 EventQueueRef_tp_new
, /* tp_new */
699 EventQueueRef_tp_free
, /* tp_free */
702 /* ----------------- End object type EventQueueRef ------------------ */
705 /* -------------------- Object type EventLoopRef -------------------- */
707 PyTypeObject EventLoopRef_Type
;
709 #define EventLoopRef_Check(x) ((x)->ob_type == &EventLoopRef_Type || PyObject_TypeCheck((x), &EventLoopRef_Type))
711 typedef struct EventLoopRefObject
{
713 EventLoopRef ob_itself
;
714 } EventLoopRefObject
;
716 PyObject
*EventLoopRef_New(EventLoopRef itself
)
718 EventLoopRefObject
*it
;
719 it
= PyObject_NEW(EventLoopRefObject
, &EventLoopRef_Type
);
720 if (it
== NULL
) return NULL
;
721 it
->ob_itself
= itself
;
722 return (PyObject
*)it
;
724 int EventLoopRef_Convert(PyObject
*v
, EventLoopRef
*p_itself
)
726 if (!EventLoopRef_Check(v
))
728 PyErr_SetString(PyExc_TypeError
, "EventLoopRef required");
731 *p_itself
= ((EventLoopRefObject
*)v
)->ob_itself
;
735 static void EventLoopRef_dealloc(EventLoopRefObject
*self
)
737 /* Cleanup of self->ob_itself goes here */
738 self
->ob_type
->tp_free((PyObject
*)self
);
741 static PyObject
*EventLoopRef_QuitEventLoop(EventLoopRefObject
*_self
, PyObject
*_args
)
743 PyObject
*_res
= NULL
;
745 if (!PyArg_ParseTuple(_args
, ""))
747 _err
= QuitEventLoop(_self
->ob_itself
);
748 if (_err
!= noErr
) return PyMac_Error(_err
);
754 static PyMethodDef EventLoopRef_methods
[] = {
755 {"QuitEventLoop", (PyCFunction
)EventLoopRef_QuitEventLoop
, 1,
756 PyDoc_STR("() -> None")},
760 #define EventLoopRef_getsetlist NULL
763 #define EventLoopRef_compare NULL
765 #define EventLoopRef_repr NULL
767 #define EventLoopRef_hash NULL
768 #define EventLoopRef_tp_init 0
770 #define EventLoopRef_tp_alloc PyType_GenericAlloc
772 static PyObject
*EventLoopRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
776 char *kw
[] = {"itself", 0};
778 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventLoopRef_Convert
, &itself
)) return NULL
;
779 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
780 ((EventLoopRefObject
*)self
)->ob_itself
= itself
;
784 #define EventLoopRef_tp_free PyObject_Del
787 PyTypeObject EventLoopRef_Type
= {
788 PyObject_HEAD_INIT(NULL
)
790 "_CarbonEvt.EventLoopRef", /*tp_name*/
791 sizeof(EventLoopRefObject
), /*tp_basicsize*/
794 (destructor
) EventLoopRef_dealloc
, /*tp_dealloc*/
796 (getattrfunc
)0, /*tp_getattr*/
797 (setattrfunc
)0, /*tp_setattr*/
798 (cmpfunc
) EventLoopRef_compare
, /*tp_compare*/
799 (reprfunc
) EventLoopRef_repr
, /*tp_repr*/
800 (PyNumberMethods
*)0, /* tp_as_number */
801 (PySequenceMethods
*)0, /* tp_as_sequence */
802 (PyMappingMethods
*)0, /* tp_as_mapping */
803 (hashfunc
) EventLoopRef_hash
, /*tp_hash*/
806 PyObject_GenericGetAttr
, /*tp_getattro*/
807 PyObject_GenericSetAttr
, /*tp_setattro */
809 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
813 0, /*tp_richcompare*/
814 0, /*tp_weaklistoffset*/
817 EventLoopRef_methods
, /* tp_methods */
819 EventLoopRef_getsetlist
, /*tp_getset*/
825 EventLoopRef_tp_init
, /* tp_init */
826 EventLoopRef_tp_alloc
, /* tp_alloc */
827 EventLoopRef_tp_new
, /* tp_new */
828 EventLoopRef_tp_free
, /* tp_free */
831 /* ------------------ End object type EventLoopRef ------------------ */
834 /* ----------------- Object type EventLoopTimerRef ------------------ */
836 PyTypeObject EventLoopTimerRef_Type
;
838 #define EventLoopTimerRef_Check(x) ((x)->ob_type == &EventLoopTimerRef_Type || PyObject_TypeCheck((x), &EventLoopTimerRef_Type))
840 typedef struct EventLoopTimerRefObject
{
842 EventLoopTimerRef ob_itself
;
843 } EventLoopTimerRefObject
;
845 PyObject
*EventLoopTimerRef_New(EventLoopTimerRef itself
)
847 EventLoopTimerRefObject
*it
;
848 it
= PyObject_NEW(EventLoopTimerRefObject
, &EventLoopTimerRef_Type
);
849 if (it
== NULL
) return NULL
;
850 it
->ob_itself
= itself
;
851 return (PyObject
*)it
;
853 int EventLoopTimerRef_Convert(PyObject
*v
, EventLoopTimerRef
*p_itself
)
855 if (!EventLoopTimerRef_Check(v
))
857 PyErr_SetString(PyExc_TypeError
, "EventLoopTimerRef required");
860 *p_itself
= ((EventLoopTimerRefObject
*)v
)->ob_itself
;
864 static void EventLoopTimerRef_dealloc(EventLoopTimerRefObject
*self
)
866 /* Cleanup of self->ob_itself goes here */
867 self
->ob_type
->tp_free((PyObject
*)self
);
870 static PyObject
*EventLoopTimerRef_RemoveEventLoopTimer(EventLoopTimerRefObject
*_self
, PyObject
*_args
)
872 PyObject
*_res
= NULL
;
874 if (!PyArg_ParseTuple(_args
, ""))
876 _err
= RemoveEventLoopTimer(_self
->ob_itself
);
877 if (_err
!= noErr
) return PyMac_Error(_err
);
883 static PyObject
*EventLoopTimerRef_SetEventLoopTimerNextFireTime(EventLoopTimerRefObject
*_self
, PyObject
*_args
)
885 PyObject
*_res
= NULL
;
888 if (!PyArg_ParseTuple(_args
, "d",
891 _err
= SetEventLoopTimerNextFireTime(_self
->ob_itself
,
893 if (_err
!= noErr
) return PyMac_Error(_err
);
899 static PyMethodDef EventLoopTimerRef_methods
[] = {
900 {"RemoveEventLoopTimer", (PyCFunction
)EventLoopTimerRef_RemoveEventLoopTimer
, 1,
901 PyDoc_STR("() -> None")},
902 {"SetEventLoopTimerNextFireTime", (PyCFunction
)EventLoopTimerRef_SetEventLoopTimerNextFireTime
, 1,
903 PyDoc_STR("(double inNextFire) -> None")},
907 #define EventLoopTimerRef_getsetlist NULL
910 #define EventLoopTimerRef_compare NULL
912 #define EventLoopTimerRef_repr NULL
914 #define EventLoopTimerRef_hash NULL
915 #define EventLoopTimerRef_tp_init 0
917 #define EventLoopTimerRef_tp_alloc PyType_GenericAlloc
919 static PyObject
*EventLoopTimerRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
922 EventLoopTimerRef itself
;
923 char *kw
[] = {"itself", 0};
925 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventLoopTimerRef_Convert
, &itself
)) return NULL
;
926 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
927 ((EventLoopTimerRefObject
*)self
)->ob_itself
= itself
;
931 #define EventLoopTimerRef_tp_free PyObject_Del
934 PyTypeObject EventLoopTimerRef_Type
= {
935 PyObject_HEAD_INIT(NULL
)
937 "_CarbonEvt.EventLoopTimerRef", /*tp_name*/
938 sizeof(EventLoopTimerRefObject
), /*tp_basicsize*/
941 (destructor
) EventLoopTimerRef_dealloc
, /*tp_dealloc*/
943 (getattrfunc
)0, /*tp_getattr*/
944 (setattrfunc
)0, /*tp_setattr*/
945 (cmpfunc
) EventLoopTimerRef_compare
, /*tp_compare*/
946 (reprfunc
) EventLoopTimerRef_repr
, /*tp_repr*/
947 (PyNumberMethods
*)0, /* tp_as_number */
948 (PySequenceMethods
*)0, /* tp_as_sequence */
949 (PyMappingMethods
*)0, /* tp_as_mapping */
950 (hashfunc
) EventLoopTimerRef_hash
, /*tp_hash*/
953 PyObject_GenericGetAttr
, /*tp_getattro*/
954 PyObject_GenericSetAttr
, /*tp_setattro */
956 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
960 0, /*tp_richcompare*/
961 0, /*tp_weaklistoffset*/
964 EventLoopTimerRef_methods
, /* tp_methods */
966 EventLoopTimerRef_getsetlist
, /*tp_getset*/
972 EventLoopTimerRef_tp_init
, /* tp_init */
973 EventLoopTimerRef_tp_alloc
, /* tp_alloc */
974 EventLoopTimerRef_tp_new
, /* tp_new */
975 EventLoopTimerRef_tp_free
, /* tp_free */
978 /* --------------- End object type EventLoopTimerRef ---------------- */
981 /* ------------------ Object type EventHandlerRef ------------------- */
983 PyTypeObject EventHandlerRef_Type
;
985 #define EventHandlerRef_Check(x) ((x)->ob_type == &EventHandlerRef_Type || PyObject_TypeCheck((x), &EventHandlerRef_Type))
987 typedef struct EventHandlerRefObject
{
989 EventHandlerRef ob_itself
;
990 PyObject
*ob_callback
;
991 } EventHandlerRefObject
;
993 PyObject
*EventHandlerRef_New(EventHandlerRef itself
)
995 EventHandlerRefObject
*it
;
996 it
= PyObject_NEW(EventHandlerRefObject
, &EventHandlerRef_Type
);
997 if (it
== NULL
) return NULL
;
998 it
->ob_itself
= itself
;
999 it
->ob_callback
= NULL
;
1000 return (PyObject
*)it
;
1002 int EventHandlerRef_Convert(PyObject
*v
, EventHandlerRef
*p_itself
)
1004 if (!EventHandlerRef_Check(v
))
1006 PyErr_SetString(PyExc_TypeError
, "EventHandlerRef required");
1009 *p_itself
= ((EventHandlerRefObject
*)v
)->ob_itself
;
1013 static void EventHandlerRef_dealloc(EventHandlerRefObject
*self
)
1015 if (self
->ob_itself
!= NULL
) {
1016 RemoveEventHandler(self
->ob_itself
);
1017 Py_DECREF(self
->ob_callback
);
1019 self
->ob_type
->tp_free((PyObject
*)self
);
1022 static PyObject
*EventHandlerRef_AddEventTypesToHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
1024 PyObject
*_res
= NULL
;
1027 EventTypeSpec inList
;
1028 if (_self
->ob_itself
== NULL
) {
1029 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1032 if (!PyArg_ParseTuple(_args
, "lO&",
1034 EventTypeSpec_Convert
, &inList
))
1036 _err
= AddEventTypesToHandler(_self
->ob_itself
,
1039 if (_err
!= noErr
) return PyMac_Error(_err
);
1045 static PyObject
*EventHandlerRef_RemoveEventTypesFromHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
1047 PyObject
*_res
= NULL
;
1050 EventTypeSpec inList
;
1051 if (_self
->ob_itself
== NULL
) {
1052 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1055 if (!PyArg_ParseTuple(_args
, "lO&",
1057 EventTypeSpec_Convert
, &inList
))
1059 _err
= RemoveEventTypesFromHandler(_self
->ob_itself
,
1062 if (_err
!= noErr
) return PyMac_Error(_err
);
1068 static PyObject
*EventHandlerRef_RemoveEventHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
1070 PyObject
*_res
= NULL
;
1073 if (_self
->ob_itself
== NULL
) {
1074 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1077 if (!PyArg_ParseTuple(_args
, ""))
1079 _err
= RemoveEventHandler(_self
->ob_itself
);
1080 if (_err
!= noErr
) return PyMac_Error(_err
);
1081 _self
->ob_itself
= NULL
;
1082 Py_DECREF(_self
->ob_callback
);
1083 _self
->ob_callback
= NULL
;
1089 static PyMethodDef EventHandlerRef_methods
[] = {
1090 {"AddEventTypesToHandler", (PyCFunction
)EventHandlerRef_AddEventTypesToHandler
, 1,
1091 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")},
1092 {"RemoveEventTypesFromHandler", (PyCFunction
)EventHandlerRef_RemoveEventTypesFromHandler
, 1,
1093 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")},
1094 {"RemoveEventHandler", (PyCFunction
)EventHandlerRef_RemoveEventHandler
, 1,
1095 PyDoc_STR("() -> None")},
1099 #define EventHandlerRef_getsetlist NULL
1102 #define EventHandlerRef_compare NULL
1104 #define EventHandlerRef_repr NULL
1106 #define EventHandlerRef_hash NULL
1107 #define EventHandlerRef_tp_init 0
1109 #define EventHandlerRef_tp_alloc PyType_GenericAlloc
1111 static PyObject
*EventHandlerRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
1114 EventHandlerRef itself
;
1115 char *kw
[] = {"itself", 0};
1117 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventHandlerRef_Convert
, &itself
)) return NULL
;
1118 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1119 ((EventHandlerRefObject
*)self
)->ob_itself
= itself
;
1123 #define EventHandlerRef_tp_free PyObject_Del
1126 PyTypeObject EventHandlerRef_Type
= {
1127 PyObject_HEAD_INIT(NULL
)
1129 "_CarbonEvt.EventHandlerRef", /*tp_name*/
1130 sizeof(EventHandlerRefObject
), /*tp_basicsize*/
1133 (destructor
) EventHandlerRef_dealloc
, /*tp_dealloc*/
1135 (getattrfunc
)0, /*tp_getattr*/
1136 (setattrfunc
)0, /*tp_setattr*/
1137 (cmpfunc
) EventHandlerRef_compare
, /*tp_compare*/
1138 (reprfunc
) EventHandlerRef_repr
, /*tp_repr*/
1139 (PyNumberMethods
*)0, /* tp_as_number */
1140 (PySequenceMethods
*)0, /* tp_as_sequence */
1141 (PyMappingMethods
*)0, /* tp_as_mapping */
1142 (hashfunc
) EventHandlerRef_hash
, /*tp_hash*/
1145 PyObject_GenericGetAttr
, /*tp_getattro*/
1146 PyObject_GenericSetAttr
, /*tp_setattro */
1148 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1152 0, /*tp_richcompare*/
1153 0, /*tp_weaklistoffset*/
1156 EventHandlerRef_methods
, /* tp_methods */
1158 EventHandlerRef_getsetlist
, /*tp_getset*/
1163 0, /*tp_dictoffset*/
1164 EventHandlerRef_tp_init
, /* tp_init */
1165 EventHandlerRef_tp_alloc
, /* tp_alloc */
1166 EventHandlerRef_tp_new
, /* tp_new */
1167 EventHandlerRef_tp_free
, /* tp_free */
1170 /* ---------------- End object type EventHandlerRef ----------------- */
1173 /* ---------------- Object type EventHandlerCallRef ----------------- */
1175 PyTypeObject EventHandlerCallRef_Type
;
1177 #define EventHandlerCallRef_Check(x) ((x)->ob_type == &EventHandlerCallRef_Type || PyObject_TypeCheck((x), &EventHandlerCallRef_Type))
1179 typedef struct EventHandlerCallRefObject
{
1181 EventHandlerCallRef ob_itself
;
1182 } EventHandlerCallRefObject
;
1184 PyObject
*EventHandlerCallRef_New(EventHandlerCallRef itself
)
1186 EventHandlerCallRefObject
*it
;
1187 it
= PyObject_NEW(EventHandlerCallRefObject
, &EventHandlerCallRef_Type
);
1188 if (it
== NULL
) return NULL
;
1189 it
->ob_itself
= itself
;
1190 return (PyObject
*)it
;
1192 int EventHandlerCallRef_Convert(PyObject
*v
, EventHandlerCallRef
*p_itself
)
1194 if (!EventHandlerCallRef_Check(v
))
1196 PyErr_SetString(PyExc_TypeError
, "EventHandlerCallRef required");
1199 *p_itself
= ((EventHandlerCallRefObject
*)v
)->ob_itself
;
1203 static void EventHandlerCallRef_dealloc(EventHandlerCallRefObject
*self
)
1205 /* Cleanup of self->ob_itself goes here */
1206 self
->ob_type
->tp_free((PyObject
*)self
);
1209 static PyObject
*EventHandlerCallRef_CallNextEventHandler(EventHandlerCallRefObject
*_self
, PyObject
*_args
)
1211 PyObject
*_res
= NULL
;
1214 if (!PyArg_ParseTuple(_args
, "O&",
1215 EventRef_Convert
, &inEvent
))
1217 _err
= CallNextEventHandler(_self
->ob_itself
,
1219 if (_err
!= noErr
) return PyMac_Error(_err
);
1225 static PyMethodDef EventHandlerCallRef_methods
[] = {
1226 {"CallNextEventHandler", (PyCFunction
)EventHandlerCallRef_CallNextEventHandler
, 1,
1227 PyDoc_STR("(EventRef inEvent) -> None")},
1231 #define EventHandlerCallRef_getsetlist NULL
1234 #define EventHandlerCallRef_compare NULL
1236 #define EventHandlerCallRef_repr NULL
1238 #define EventHandlerCallRef_hash NULL
1239 #define EventHandlerCallRef_tp_init 0
1241 #define EventHandlerCallRef_tp_alloc PyType_GenericAlloc
1243 static PyObject
*EventHandlerCallRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
1246 EventHandlerCallRef itself
;
1247 char *kw
[] = {"itself", 0};
1249 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventHandlerCallRef_Convert
, &itself
)) return NULL
;
1250 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1251 ((EventHandlerCallRefObject
*)self
)->ob_itself
= itself
;
1255 #define EventHandlerCallRef_tp_free PyObject_Del
1258 PyTypeObject EventHandlerCallRef_Type
= {
1259 PyObject_HEAD_INIT(NULL
)
1261 "_CarbonEvt.EventHandlerCallRef", /*tp_name*/
1262 sizeof(EventHandlerCallRefObject
), /*tp_basicsize*/
1265 (destructor
) EventHandlerCallRef_dealloc
, /*tp_dealloc*/
1267 (getattrfunc
)0, /*tp_getattr*/
1268 (setattrfunc
)0, /*tp_setattr*/
1269 (cmpfunc
) EventHandlerCallRef_compare
, /*tp_compare*/
1270 (reprfunc
) EventHandlerCallRef_repr
, /*tp_repr*/
1271 (PyNumberMethods
*)0, /* tp_as_number */
1272 (PySequenceMethods
*)0, /* tp_as_sequence */
1273 (PyMappingMethods
*)0, /* tp_as_mapping */
1274 (hashfunc
) EventHandlerCallRef_hash
, /*tp_hash*/
1277 PyObject_GenericGetAttr
, /*tp_getattro*/
1278 PyObject_GenericSetAttr
, /*tp_setattro */
1280 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1284 0, /*tp_richcompare*/
1285 0, /*tp_weaklistoffset*/
1288 EventHandlerCallRef_methods
, /* tp_methods */
1290 EventHandlerCallRef_getsetlist
, /*tp_getset*/
1295 0, /*tp_dictoffset*/
1296 EventHandlerCallRef_tp_init
, /* tp_init */
1297 EventHandlerCallRef_tp_alloc
, /* tp_alloc */
1298 EventHandlerCallRef_tp_new
, /* tp_new */
1299 EventHandlerCallRef_tp_free
, /* tp_free */
1302 /* -------------- End object type EventHandlerCallRef --------------- */
1305 /* ------------------- Object type EventTargetRef ------------------- */
1307 PyTypeObject EventTargetRef_Type
;
1309 #define EventTargetRef_Check(x) ((x)->ob_type == &EventTargetRef_Type || PyObject_TypeCheck((x), &EventTargetRef_Type))
1311 typedef struct EventTargetRefObject
{
1313 EventTargetRef ob_itself
;
1314 } EventTargetRefObject
;
1316 PyObject
*EventTargetRef_New(EventTargetRef itself
)
1318 EventTargetRefObject
*it
;
1319 it
= PyObject_NEW(EventTargetRefObject
, &EventTargetRef_Type
);
1320 if (it
== NULL
) return NULL
;
1321 it
->ob_itself
= itself
;
1322 return (PyObject
*)it
;
1324 int EventTargetRef_Convert(PyObject
*v
, EventTargetRef
*p_itself
)
1326 if (!EventTargetRef_Check(v
))
1328 PyErr_SetString(PyExc_TypeError
, "EventTargetRef required");
1331 *p_itself
= ((EventTargetRefObject
*)v
)->ob_itself
;
1335 static void EventTargetRef_dealloc(EventTargetRefObject
*self
)
1337 /* Cleanup of self->ob_itself goes here */
1338 self
->ob_type
->tp_free((PyObject
*)self
);
1341 static PyObject
*EventTargetRef_InstallStandardEventHandler(EventTargetRefObject
*_self
, PyObject
*_args
)
1343 PyObject
*_res
= NULL
;
1345 if (!PyArg_ParseTuple(_args
, ""))
1347 _err
= InstallStandardEventHandler(_self
->ob_itself
);
1348 if (_err
!= noErr
) return PyMac_Error(_err
);
1354 static PyObject
*EventTargetRef_InstallEventHandler(EventTargetRefObject
*_self
, PyObject
*_args
)
1356 PyObject
*_res
= NULL
;
1358 EventTypeSpec inSpec
;
1360 EventHandlerRef outRef
;
1363 if (!PyArg_ParseTuple(_args
, "O&O", EventTypeSpec_Convert
, &inSpec
, &callback
))
1366 _err
= InstallEventHandler(_self
->ob_itself
, myEventHandlerUPP
, 1, &inSpec
, (void *)callback
, &outRef
);
1367 if (_err
!= noErr
) return PyMac_Error(_err
);
1369 _res
= EventHandlerRef_New(outRef
);
1371 ((EventHandlerRefObject
*)_res
)->ob_callback
= callback
;
1372 Py_INCREF(callback
);
1377 static PyMethodDef EventTargetRef_methods
[] = {
1378 {"InstallStandardEventHandler", (PyCFunction
)EventTargetRef_InstallStandardEventHandler
, 1,
1379 PyDoc_STR("() -> None")},
1380 {"InstallEventHandler", (PyCFunction
)EventTargetRef_InstallEventHandler
, 1,
1381 PyDoc_STR("(EventTypeSpec inSpec, Method callback) -> (EventHandlerRef outRef)")},
1385 #define EventTargetRef_getsetlist NULL
1388 #define EventTargetRef_compare NULL
1390 #define EventTargetRef_repr NULL
1392 #define EventTargetRef_hash NULL
1393 #define EventTargetRef_tp_init 0
1395 #define EventTargetRef_tp_alloc PyType_GenericAlloc
1397 static PyObject
*EventTargetRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
1400 EventTargetRef itself
;
1401 char *kw
[] = {"itself", 0};
1403 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventTargetRef_Convert
, &itself
)) return NULL
;
1404 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1405 ((EventTargetRefObject
*)self
)->ob_itself
= itself
;
1409 #define EventTargetRef_tp_free PyObject_Del
1412 PyTypeObject EventTargetRef_Type
= {
1413 PyObject_HEAD_INIT(NULL
)
1415 "_CarbonEvt.EventTargetRef", /*tp_name*/
1416 sizeof(EventTargetRefObject
), /*tp_basicsize*/
1419 (destructor
) EventTargetRef_dealloc
, /*tp_dealloc*/
1421 (getattrfunc
)0, /*tp_getattr*/
1422 (setattrfunc
)0, /*tp_setattr*/
1423 (cmpfunc
) EventTargetRef_compare
, /*tp_compare*/
1424 (reprfunc
) EventTargetRef_repr
, /*tp_repr*/
1425 (PyNumberMethods
*)0, /* tp_as_number */
1426 (PySequenceMethods
*)0, /* tp_as_sequence */
1427 (PyMappingMethods
*)0, /* tp_as_mapping */
1428 (hashfunc
) EventTargetRef_hash
, /*tp_hash*/
1431 PyObject_GenericGetAttr
, /*tp_getattro*/
1432 PyObject_GenericSetAttr
, /*tp_setattro */
1434 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1438 0, /*tp_richcompare*/
1439 0, /*tp_weaklistoffset*/
1442 EventTargetRef_methods
, /* tp_methods */
1444 EventTargetRef_getsetlist
, /*tp_getset*/
1449 0, /*tp_dictoffset*/
1450 EventTargetRef_tp_init
, /* tp_init */
1451 EventTargetRef_tp_alloc
, /* tp_alloc */
1452 EventTargetRef_tp_new
, /* tp_new */
1453 EventTargetRef_tp_free
, /* tp_free */
1456 /* ----------------- End object type EventTargetRef ----------------- */
1459 /* ------------------- Object type EventHotKeyRef ------------------- */
1461 PyTypeObject EventHotKeyRef_Type
;
1463 #define EventHotKeyRef_Check(x) ((x)->ob_type == &EventHotKeyRef_Type || PyObject_TypeCheck((x), &EventHotKeyRef_Type))
1465 typedef struct EventHotKeyRefObject
{
1467 EventHotKeyRef ob_itself
;
1468 } EventHotKeyRefObject
;
1470 PyObject
*EventHotKeyRef_New(EventHotKeyRef itself
)
1472 EventHotKeyRefObject
*it
;
1473 it
= PyObject_NEW(EventHotKeyRefObject
, &EventHotKeyRef_Type
);
1474 if (it
== NULL
) return NULL
;
1475 it
->ob_itself
= itself
;
1476 return (PyObject
*)it
;
1478 int EventHotKeyRef_Convert(PyObject
*v
, EventHotKeyRef
*p_itself
)
1480 if (!EventHotKeyRef_Check(v
))
1482 PyErr_SetString(PyExc_TypeError
, "EventHotKeyRef required");
1485 *p_itself
= ((EventHotKeyRefObject
*)v
)->ob_itself
;
1489 static void EventHotKeyRef_dealloc(EventHotKeyRefObject
*self
)
1491 /* Cleanup of self->ob_itself goes here */
1492 self
->ob_type
->tp_free((PyObject
*)self
);
1495 static PyObject
*EventHotKeyRef_UnregisterEventHotKey(EventHotKeyRefObject
*_self
, PyObject
*_args
)
1497 PyObject
*_res
= NULL
;
1499 if (!PyArg_ParseTuple(_args
, ""))
1501 _err
= UnregisterEventHotKey(_self
->ob_itself
);
1502 if (_err
!= noErr
) return PyMac_Error(_err
);
1508 static PyMethodDef EventHotKeyRef_methods
[] = {
1509 {"UnregisterEventHotKey", (PyCFunction
)EventHotKeyRef_UnregisterEventHotKey
, 1,
1510 PyDoc_STR("() -> None")},
1514 #define EventHotKeyRef_getsetlist NULL
1517 #define EventHotKeyRef_compare NULL
1519 #define EventHotKeyRef_repr NULL
1521 #define EventHotKeyRef_hash NULL
1522 #define EventHotKeyRef_tp_init 0
1524 #define EventHotKeyRef_tp_alloc PyType_GenericAlloc
1526 static PyObject
*EventHotKeyRef_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
1529 EventHotKeyRef itself
;
1530 char *kw
[] = {"itself", 0};
1532 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, EventHotKeyRef_Convert
, &itself
)) return NULL
;
1533 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1534 ((EventHotKeyRefObject
*)self
)->ob_itself
= itself
;
1538 #define EventHotKeyRef_tp_free PyObject_Del
1541 PyTypeObject EventHotKeyRef_Type
= {
1542 PyObject_HEAD_INIT(NULL
)
1544 "_CarbonEvt.EventHotKeyRef", /*tp_name*/
1545 sizeof(EventHotKeyRefObject
), /*tp_basicsize*/
1548 (destructor
) EventHotKeyRef_dealloc
, /*tp_dealloc*/
1550 (getattrfunc
)0, /*tp_getattr*/
1551 (setattrfunc
)0, /*tp_setattr*/
1552 (cmpfunc
) EventHotKeyRef_compare
, /*tp_compare*/
1553 (reprfunc
) EventHotKeyRef_repr
, /*tp_repr*/
1554 (PyNumberMethods
*)0, /* tp_as_number */
1555 (PySequenceMethods
*)0, /* tp_as_sequence */
1556 (PyMappingMethods
*)0, /* tp_as_mapping */
1557 (hashfunc
) EventHotKeyRef_hash
, /*tp_hash*/
1560 PyObject_GenericGetAttr
, /*tp_getattro*/
1561 PyObject_GenericSetAttr
, /*tp_setattro */
1563 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1567 0, /*tp_richcompare*/
1568 0, /*tp_weaklistoffset*/
1571 EventHotKeyRef_methods
, /* tp_methods */
1573 EventHotKeyRef_getsetlist
, /*tp_getset*/
1578 0, /*tp_dictoffset*/
1579 EventHotKeyRef_tp_init
, /* tp_init */
1580 EventHotKeyRef_tp_alloc
, /* tp_alloc */
1581 EventHotKeyRef_tp_new
, /* tp_new */
1582 EventHotKeyRef_tp_free
, /* tp_free */
1585 /* ----------------- End object type EventHotKeyRef ----------------- */
1588 static PyObject
*CarbonEvents_GetCurrentEventLoop(PyObject
*_self
, PyObject
*_args
)
1590 PyObject
*_res
= NULL
;
1592 if (!PyArg_ParseTuple(_args
, ""))
1594 _rv
= GetCurrentEventLoop();
1595 _res
= Py_BuildValue("O&",
1596 EventLoopRef_New
, _rv
);
1600 static PyObject
*CarbonEvents_GetMainEventLoop(PyObject
*_self
, PyObject
*_args
)
1602 PyObject
*_res
= NULL
;
1604 if (!PyArg_ParseTuple(_args
, ""))
1606 _rv
= GetMainEventLoop();
1607 _res
= Py_BuildValue("O&",
1608 EventLoopRef_New
, _rv
);
1612 static PyObject
*CarbonEvents_RunCurrentEventLoop(PyObject
*_self
, PyObject
*_args
)
1614 PyObject
*_res
= NULL
;
1617 if (!PyArg_ParseTuple(_args
, "d",
1620 _err
= RunCurrentEventLoop(inTimeout
);
1621 if (_err
!= noErr
) return PyMac_Error(_err
);
1627 static PyObject
*CarbonEvents_ReceiveNextEvent(PyObject
*_self
, PyObject
*_args
)
1629 PyObject
*_res
= NULL
;
1632 EventTypeSpec inList
;
1634 Boolean inPullEvent
;
1636 if (!PyArg_ParseTuple(_args
, "lO&db",
1638 EventTypeSpec_Convert
, &inList
,
1642 _err
= ReceiveNextEvent(inNumTypes
,
1647 if (_err
!= noErr
) return PyMac_Error(_err
);
1648 _res
= Py_BuildValue("O&",
1649 EventRef_New
, outEvent
);
1653 static PyObject
*CarbonEvents_GetCurrentEventQueue(PyObject
*_self
, PyObject
*_args
)
1655 PyObject
*_res
= NULL
;
1657 if (!PyArg_ParseTuple(_args
, ""))
1659 _rv
= GetCurrentEventQueue();
1660 _res
= Py_BuildValue("O&",
1661 EventQueueRef_New
, _rv
);
1665 static PyObject
*CarbonEvents_GetMainEventQueue(PyObject
*_self
, PyObject
*_args
)
1667 PyObject
*_res
= NULL
;
1669 if (!PyArg_ParseTuple(_args
, ""))
1671 _rv
= GetMainEventQueue();
1672 _res
= Py_BuildValue("O&",
1673 EventQueueRef_New
, _rv
);
1677 static PyObject
*CarbonEvents_GetCurrentEventTime(PyObject
*_self
, PyObject
*_args
)
1679 PyObject
*_res
= NULL
;
1681 if (!PyArg_ParseTuple(_args
, ""))
1683 _rv
= GetCurrentEventTime();
1684 _res
= Py_BuildValue("d",
1689 static PyObject
*CarbonEvents_TrackMouseLocation(PyObject
*_self
, PyObject
*_args
)
1691 PyObject
*_res
= NULL
;
1696 if (!PyArg_ParseTuple(_args
, "O&",
1697 GrafObj_Convert
, &inPort
))
1699 _err
= TrackMouseLocation(inPort
,
1702 if (_err
!= noErr
) return PyMac_Error(_err
);
1703 _res
= Py_BuildValue("O&H",
1704 PyMac_BuildPoint
, outPt
,
1709 static PyObject
*CarbonEvents_TrackMouseLocationWithOptions(PyObject
*_self
, PyObject
*_args
)
1711 PyObject
*_res
= NULL
;
1714 OptionBits inOptions
;
1717 UInt32 outModifiers
;
1719 if (!PyArg_ParseTuple(_args
, "O&ld",
1720 GrafObj_Convert
, &inPort
,
1724 _err
= TrackMouseLocationWithOptions(inPort
,
1730 if (_err
!= noErr
) return PyMac_Error(_err
);
1731 _res
= Py_BuildValue("O&lH",
1732 PyMac_BuildPoint
, outPt
,
1738 static PyObject
*CarbonEvents_TrackMouseRegion(PyObject
*_self
, PyObject
*_args
)
1740 PyObject
*_res
= NULL
;
1746 if (!PyArg_ParseTuple(_args
, "O&O&b",
1747 GrafObj_Convert
, &inPort
,
1748 ResObj_Convert
, &inRegion
,
1751 _err
= TrackMouseRegion(inPort
,
1755 if (_err
!= noErr
) return PyMac_Error(_err
);
1756 _res
= Py_BuildValue("bH",
1762 static PyObject
*CarbonEvents_GetLastUserEventTime(PyObject
*_self
, PyObject
*_args
)
1764 PyObject
*_res
= NULL
;
1766 if (!PyArg_ParseTuple(_args
, ""))
1768 _rv
= GetLastUserEventTime();
1769 _res
= Py_BuildValue("d",
1774 static PyObject
*CarbonEvents_GetWindowEventTarget(PyObject
*_self
, PyObject
*_args
)
1776 PyObject
*_res
= NULL
;
1779 if (!PyArg_ParseTuple(_args
, "O&",
1780 WinObj_Convert
, &inWindow
))
1782 _rv
= GetWindowEventTarget(inWindow
);
1783 _res
= Py_BuildValue("O&",
1784 EventTargetRef_New
, _rv
);
1788 static PyObject
*CarbonEvents_GetControlEventTarget(PyObject
*_self
, PyObject
*_args
)
1790 PyObject
*_res
= NULL
;
1792 ControlHandle inControl
;
1793 if (!PyArg_ParseTuple(_args
, "O&",
1794 CtlObj_Convert
, &inControl
))
1796 _rv
= GetControlEventTarget(inControl
);
1797 _res
= Py_BuildValue("O&",
1798 EventTargetRef_New
, _rv
);
1802 static PyObject
*CarbonEvents_GetMenuEventTarget(PyObject
*_self
, PyObject
*_args
)
1804 PyObject
*_res
= NULL
;
1807 if (!PyArg_ParseTuple(_args
, "O&",
1808 MenuObj_Convert
, &inMenu
))
1810 _rv
= GetMenuEventTarget(inMenu
);
1811 _res
= Py_BuildValue("O&",
1812 EventTargetRef_New
, _rv
);
1816 static PyObject
*CarbonEvents_GetApplicationEventTarget(PyObject
*_self
, PyObject
*_args
)
1818 PyObject
*_res
= NULL
;
1820 if (!PyArg_ParseTuple(_args
, ""))
1822 _rv
= GetApplicationEventTarget();
1823 _res
= Py_BuildValue("O&",
1824 EventTargetRef_New
, _rv
);
1828 static PyObject
*CarbonEvents_GetUserFocusEventTarget(PyObject
*_self
, PyObject
*_args
)
1830 PyObject
*_res
= NULL
;
1832 if (!PyArg_ParseTuple(_args
, ""))
1834 _rv
= GetUserFocusEventTarget();
1835 _res
= Py_BuildValue("O&",
1836 EventTargetRef_New
, _rv
);
1840 static PyObject
*CarbonEvents_GetEventDispatcherTarget(PyObject
*_self
, PyObject
*_args
)
1842 PyObject
*_res
= NULL
;
1844 if (!PyArg_ParseTuple(_args
, ""))
1846 _rv
= GetEventDispatcherTarget();
1847 _res
= Py_BuildValue("O&",
1848 EventTargetRef_New
, _rv
);
1852 static PyObject
*CarbonEvents_QuitApplicationEventLoop(PyObject
*_self
, PyObject
*_args
)
1854 PyObject
*_res
= NULL
;
1855 if (!PyArg_ParseTuple(_args
, ""))
1857 QuitApplicationEventLoop();
1863 static PyObject
*CarbonEvents_RunAppModalLoopForWindow(PyObject
*_self
, PyObject
*_args
)
1865 PyObject
*_res
= NULL
;
1868 if (!PyArg_ParseTuple(_args
, "O&",
1869 WinObj_Convert
, &inWindow
))
1871 _err
= RunAppModalLoopForWindow(inWindow
);
1872 if (_err
!= noErr
) return PyMac_Error(_err
);
1878 static PyObject
*CarbonEvents_QuitAppModalLoopForWindow(PyObject
*_self
, PyObject
*_args
)
1880 PyObject
*_res
= NULL
;
1883 if (!PyArg_ParseTuple(_args
, "O&",
1884 WinObj_Convert
, &inWindow
))
1886 _err
= QuitAppModalLoopForWindow(inWindow
);
1887 if (_err
!= noErr
) return PyMac_Error(_err
);
1893 static PyObject
*CarbonEvents_BeginAppModalStateForWindow(PyObject
*_self
, PyObject
*_args
)
1895 PyObject
*_res
= NULL
;
1898 if (!PyArg_ParseTuple(_args
, "O&",
1899 WinObj_Convert
, &inWindow
))
1901 _err
= BeginAppModalStateForWindow(inWindow
);
1902 if (_err
!= noErr
) return PyMac_Error(_err
);
1908 static PyObject
*CarbonEvents_EndAppModalStateForWindow(PyObject
*_self
, PyObject
*_args
)
1910 PyObject
*_res
= NULL
;
1913 if (!PyArg_ParseTuple(_args
, "O&",
1914 WinObj_Convert
, &inWindow
))
1916 _err
= EndAppModalStateForWindow(inWindow
);
1917 if (_err
!= noErr
) return PyMac_Error(_err
);
1923 static PyObject
*CarbonEvents_SetUserFocusWindow(PyObject
*_self
, PyObject
*_args
)
1925 PyObject
*_res
= NULL
;
1928 if (!PyArg_ParseTuple(_args
, "O&",
1929 WinObj_Convert
, &inWindow
))
1931 _err
= SetUserFocusWindow(inWindow
);
1932 if (_err
!= noErr
) return PyMac_Error(_err
);
1938 static PyObject
*CarbonEvents_GetUserFocusWindow(PyObject
*_self
, PyObject
*_args
)
1940 PyObject
*_res
= NULL
;
1942 if (!PyArg_ParseTuple(_args
, ""))
1944 _rv
= GetUserFocusWindow();
1945 _res
= Py_BuildValue("O&",
1950 static PyObject
*CarbonEvents_SetWindowDefaultButton(PyObject
*_self
, PyObject
*_args
)
1952 PyObject
*_res
= NULL
;
1955 ControlHandle inControl
;
1956 if (!PyArg_ParseTuple(_args
, "O&O&",
1957 WinObj_Convert
, &inWindow
,
1958 CtlObj_Convert
, &inControl
))
1960 _err
= SetWindowDefaultButton(inWindow
,
1962 if (_err
!= noErr
) return PyMac_Error(_err
);
1968 static PyObject
*CarbonEvents_SetWindowCancelButton(PyObject
*_self
, PyObject
*_args
)
1970 PyObject
*_res
= NULL
;
1973 ControlHandle inControl
;
1974 if (!PyArg_ParseTuple(_args
, "O&O&",
1975 WinObj_Convert
, &inWindow
,
1976 CtlObj_Convert
, &inControl
))
1978 _err
= SetWindowCancelButton(inWindow
,
1980 if (_err
!= noErr
) return PyMac_Error(_err
);
1986 static PyObject
*CarbonEvents_GetWindowDefaultButton(PyObject
*_self
, PyObject
*_args
)
1988 PyObject
*_res
= NULL
;
1991 ControlHandle outControl
;
1992 if (!PyArg_ParseTuple(_args
, "O&",
1993 WinObj_Convert
, &inWindow
))
1995 _err
= GetWindowDefaultButton(inWindow
,
1997 if (_err
!= noErr
) return PyMac_Error(_err
);
1998 _res
= Py_BuildValue("O&",
1999 CtlObj_New
, outControl
);
2003 static PyObject
*CarbonEvents_GetWindowCancelButton(PyObject
*_self
, PyObject
*_args
)
2005 PyObject
*_res
= NULL
;
2008 ControlHandle outControl
;
2009 if (!PyArg_ParseTuple(_args
, "O&",
2010 WinObj_Convert
, &inWindow
))
2012 _err
= GetWindowCancelButton(inWindow
,
2014 if (_err
!= noErr
) return PyMac_Error(_err
);
2015 _res
= Py_BuildValue("O&",
2016 CtlObj_New
, outControl
);
2020 static PyObject
*CarbonEvents_RegisterEventHotKey(PyObject
*_self
, PyObject
*_args
)
2022 PyObject
*_res
= NULL
;
2024 UInt32 inHotKeyCode
;
2025 UInt32 inHotKeyModifiers
;
2026 EventHotKeyID inHotKeyID
;
2027 EventTargetRef inTarget
;
2028 OptionBits inOptions
;
2029 EventHotKeyRef outRef
;
2030 if (!PyArg_ParseTuple(_args
, "llO&O&l",
2033 EventHotKeyID_Convert
, &inHotKeyID
,
2034 EventTargetRef_Convert
, &inTarget
,
2037 _err
= RegisterEventHotKey(inHotKeyCode
,
2043 if (_err
!= noErr
) return PyMac_Error(_err
);
2044 _res
= Py_BuildValue("O&",
2045 EventHotKeyRef_New
, outRef
);
2049 static PyObject
*CarbonEvents_RunApplicationEventLoop(PyObject
*_self
, PyObject
*_args
)
2051 PyObject
*_res
= NULL
;
2053 #if USE_MAC_MP_MULTITHREADING
2054 if (MPCreateCriticalRegion(&reentrantLock
) != noErr
) {
2055 PySys_WriteStderr("lock failure\n");
2058 _save
= PyEval_SaveThread();
2059 #endif /* USE_MAC_MP_MULTITHREADING */
2061 RunApplicationEventLoop();
2063 #if USE_MAC_MP_MULTITHREADING
2064 PyEval_RestoreThread(_save
);
2066 MPDeleteCriticalRegion(reentrantLock
);
2067 #endif /* USE_MAC_MP_MULTITHREADING */
2075 static PyMethodDef CarbonEvents_methods
[] = {
2076 {"GetCurrentEventLoop", (PyCFunction
)CarbonEvents_GetCurrentEventLoop
, 1,
2077 PyDoc_STR("() -> (EventLoopRef _rv)")},
2078 {"GetMainEventLoop", (PyCFunction
)CarbonEvents_GetMainEventLoop
, 1,
2079 PyDoc_STR("() -> (EventLoopRef _rv)")},
2080 {"RunCurrentEventLoop", (PyCFunction
)CarbonEvents_RunCurrentEventLoop
, 1,
2081 PyDoc_STR("(double inTimeout) -> None")},
2082 {"ReceiveNextEvent", (PyCFunction
)CarbonEvents_ReceiveNextEvent
, 1,
2083 PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList, double inTimeout, Boolean inPullEvent) -> (EventRef outEvent)")},
2084 {"GetCurrentEventQueue", (PyCFunction
)CarbonEvents_GetCurrentEventQueue
, 1,
2085 PyDoc_STR("() -> (EventQueueRef _rv)")},
2086 {"GetMainEventQueue", (PyCFunction
)CarbonEvents_GetMainEventQueue
, 1,
2087 PyDoc_STR("() -> (EventQueueRef _rv)")},
2088 {"GetCurrentEventTime", (PyCFunction
)CarbonEvents_GetCurrentEventTime
, 1,
2089 PyDoc_STR("() -> (double _rv)")},
2090 {"TrackMouseLocation", (PyCFunction
)CarbonEvents_TrackMouseLocation
, 1,
2091 PyDoc_STR("(GrafPtr inPort) -> (Point outPt, UInt16 outResult)")},
2092 {"TrackMouseLocationWithOptions", (PyCFunction
)CarbonEvents_TrackMouseLocationWithOptions
, 1,
2093 PyDoc_STR("(GrafPtr inPort, OptionBits inOptions, double inTimeout) -> (Point outPt, UInt32 outModifiers, UInt16 outResult)")},
2094 {"TrackMouseRegion", (PyCFunction
)CarbonEvents_TrackMouseRegion
, 1,
2095 PyDoc_STR("(GrafPtr inPort, RgnHandle inRegion, Boolean ioWasInRgn) -> (Boolean ioWasInRgn, UInt16 outResult)")},
2096 {"GetLastUserEventTime", (PyCFunction
)CarbonEvents_GetLastUserEventTime
, 1,
2097 PyDoc_STR("() -> (double _rv)")},
2098 {"GetWindowEventTarget", (PyCFunction
)CarbonEvents_GetWindowEventTarget
, 1,
2099 PyDoc_STR("(WindowPtr inWindow) -> (EventTargetRef _rv)")},
2100 {"GetControlEventTarget", (PyCFunction
)CarbonEvents_GetControlEventTarget
, 1,
2101 PyDoc_STR("(ControlHandle inControl) -> (EventTargetRef _rv)")},
2102 {"GetMenuEventTarget", (PyCFunction
)CarbonEvents_GetMenuEventTarget
, 1,
2103 PyDoc_STR("(MenuHandle inMenu) -> (EventTargetRef _rv)")},
2104 {"GetApplicationEventTarget", (PyCFunction
)CarbonEvents_GetApplicationEventTarget
, 1,
2105 PyDoc_STR("() -> (EventTargetRef _rv)")},
2106 {"GetUserFocusEventTarget", (PyCFunction
)CarbonEvents_GetUserFocusEventTarget
, 1,
2107 PyDoc_STR("() -> (EventTargetRef _rv)")},
2108 {"GetEventDispatcherTarget", (PyCFunction
)CarbonEvents_GetEventDispatcherTarget
, 1,
2109 PyDoc_STR("() -> (EventTargetRef _rv)")},
2110 {"QuitApplicationEventLoop", (PyCFunction
)CarbonEvents_QuitApplicationEventLoop
, 1,
2111 PyDoc_STR("() -> None")},
2112 {"RunAppModalLoopForWindow", (PyCFunction
)CarbonEvents_RunAppModalLoopForWindow
, 1,
2113 PyDoc_STR("(WindowPtr inWindow) -> None")},
2114 {"QuitAppModalLoopForWindow", (PyCFunction
)CarbonEvents_QuitAppModalLoopForWindow
, 1,
2115 PyDoc_STR("(WindowPtr inWindow) -> None")},
2116 {"BeginAppModalStateForWindow", (PyCFunction
)CarbonEvents_BeginAppModalStateForWindow
, 1,
2117 PyDoc_STR("(WindowPtr inWindow) -> None")},
2118 {"EndAppModalStateForWindow", (PyCFunction
)CarbonEvents_EndAppModalStateForWindow
, 1,
2119 PyDoc_STR("(WindowPtr inWindow) -> None")},
2120 {"SetUserFocusWindow", (PyCFunction
)CarbonEvents_SetUserFocusWindow
, 1,
2121 PyDoc_STR("(WindowPtr inWindow) -> None")},
2122 {"GetUserFocusWindow", (PyCFunction
)CarbonEvents_GetUserFocusWindow
, 1,
2123 PyDoc_STR("() -> (WindowPtr _rv)")},
2124 {"SetWindowDefaultButton", (PyCFunction
)CarbonEvents_SetWindowDefaultButton
, 1,
2125 PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")},
2126 {"SetWindowCancelButton", (PyCFunction
)CarbonEvents_SetWindowCancelButton
, 1,
2127 PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")},
2128 {"GetWindowDefaultButton", (PyCFunction
)CarbonEvents_GetWindowDefaultButton
, 1,
2129 PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
2130 {"GetWindowCancelButton", (PyCFunction
)CarbonEvents_GetWindowCancelButton
, 1,
2131 PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
2132 {"RegisterEventHotKey", (PyCFunction
)CarbonEvents_RegisterEventHotKey
, 1,
2133 PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")},
2134 {"RunApplicationEventLoop", (PyCFunction
)CarbonEvents_RunApplicationEventLoop
, 1,
2135 PyDoc_STR("() -> ()")},
2142 void init_CarbonEvt(void)
2149 PyMac_PRECHECK(NewEventHandlerUPP
); /* This can fail if CarbonLib is too old */
2150 myEventHandlerUPP
= NewEventHandlerUPP(myEventHandler
);
2153 m
= Py_InitModule("_CarbonEvt", CarbonEvents_methods
);
2154 d
= PyModule_GetDict(m
);
2155 CarbonEvents_Error
= PyMac_GetOSErrException();
2156 if (CarbonEvents_Error
== NULL
||
2157 PyDict_SetItemString(d
, "Error", CarbonEvents_Error
) != 0)
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
);
2217 /* ===================== End module _CarbonEvt ====================== */