2 /* ======================= Module _CarbonEvt ======================== */
8 #include "pymactoolbox.h"
10 /* Macro to test whether a weak-loaded CFM function exists */
11 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
12 PyErr_SetString(PyExc_NotImplementedError, \
13 "Not available in this shared library/OS version"); \
18 #include <Carbon/Carbon.h>
20 extern int CFStringRef_New(CFStringRef
*);
22 extern int CFStringRef_Convert(PyObject
*, CFStringRef
*);
23 extern int CFBundleRef_Convert(PyObject
*, CFBundleRef
*);
25 int EventTargetRef_Convert(PyObject
*, EventTargetRef
*);
26 PyObject
*EventHandlerCallRef_New(EventHandlerCallRef itself
);
27 PyObject
*EventRef_New(EventRef itself
);
29 /********** EventTypeSpec *******/
31 EventTypeSpec_Convert(PyObject
*v
, EventTypeSpec
*out
)
33 if (PyArg_Parse(v
, "(O&l)",
34 PyMac_GetOSType
, &(out
->eventClass
),
40 /********** end EventTypeSpec *******/
42 /********** HIPoint *******/
44 #if 0 /* XXX doesn't compile */
46 HIPoint_New(HIPoint
*in
)
48 return Py_BuildValue("ff", in
->x
, in
->y
);
52 HIPoint_Convert(PyObject
*v
, HIPoint
*out
)
54 if (PyArg_ParseTuple(v
, "ff", &(out
->x
), &(out
->y
)))
60 /********** end HIPoint *******/
62 /********** EventHotKeyID *******/
65 EventHotKeyID_Convert(PyObject
*v
, EventHotKeyID
*out
)
67 if (PyArg_ParseTuple(v
, "ll", &out
->signature
, &out
->id
))
72 /********** end EventHotKeyID *******/
74 /******** myEventHandler ***********/
76 static EventHandlerUPP myEventHandlerUPP
;
78 static pascal OSStatus
79 myEventHandler(EventHandlerCallRef handlerRef
, EventRef event
, void *outPyObject
) {
83 retValue
= PyObject_CallFunction((PyObject
*)outPyObject
, "O&O&",
84 EventHandlerCallRef_New
, handlerRef
,
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? */
91 if (retValue
== Py_None
)
93 else if (PyInt_Check(retValue
)) {
94 status
= PyInt_AsLong(retValue
);
96 status
= noErr
; /* wrong object type, complain? */
103 /******** end myEventHandler ***********/
106 static PyObject
*CarbonEvents_Error
;
108 /* ---------------------- Object type EventRef ---------------------- */
110 PyTypeObject EventRef_Type
;
112 #define EventRef_Check(x) ((x)->ob_type == &EventRef_Type || PyObject_TypeCheck((x), &EventRef_Type))
114 typedef struct EventRefObject
{
119 PyObject
*EventRef_New(EventRef itself
)
122 it
= PyObject_NEW(EventRefObject
, &EventRef_Type
);
123 if (it
== NULL
) return NULL
;
124 it
->ob_itself
= itself
;
125 return (PyObject
*)it
;
128 int EventRef_Convert(PyObject
*v
, EventRef
*p_itself
)
130 if (!EventRef_Check(v
))
132 PyErr_SetString(PyExc_TypeError
, "EventRef required");
135 *p_itself
= ((EventRefObject
*)v
)->ob_itself
;
139 static void EventRef_dealloc(EventRefObject
*self
)
141 /* Cleanup of self->ob_itself goes here */
142 self
->ob_type
->tp_free((PyObject
*)self
);
145 static PyObject
*EventRef_RetainEvent(EventRefObject
*_self
, PyObject
*_args
)
147 PyObject
*_res
= NULL
;
149 if (!PyArg_ParseTuple(_args
, ""))
151 _rv
= RetainEvent(_self
->ob_itself
);
152 _res
= Py_BuildValue("O&",
157 static PyObject
*EventRef_GetEventRetainCount(EventRefObject
*_self
, PyObject
*_args
)
159 PyObject
*_res
= NULL
;
161 if (!PyArg_ParseTuple(_args
, ""))
163 _rv
= GetEventRetainCount(_self
->ob_itself
);
164 _res
= Py_BuildValue("l",
169 static PyObject
*EventRef_ReleaseEvent(EventRefObject
*_self
, PyObject
*_args
)
171 PyObject
*_res
= NULL
;
172 if (!PyArg_ParseTuple(_args
, ""))
174 ReleaseEvent(_self
->ob_itself
);
180 static PyObject
*EventRef_SetEventParameter(EventRefObject
*_self
, PyObject
*_args
)
182 PyObject
*_res
= NULL
;
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__
))
194 inDataPtr__len__
= inDataPtr__in_len__
;
195 _err
= SetEventParameter(_self
->ob_itself
,
198 inDataPtr__len__
, inDataPtr__in__
);
199 if (_err
!= noErr
) return PyMac_Error(_err
);
205 static PyObject
*EventRef_GetEventClass(EventRefObject
*_self
, PyObject
*_args
)
207 PyObject
*_res
= NULL
;
209 if (!PyArg_ParseTuple(_args
, ""))
211 _rv
= GetEventClass(_self
->ob_itself
);
212 _res
= Py_BuildValue("l",
217 static PyObject
*EventRef_GetEventKind(EventRefObject
*_self
, PyObject
*_args
)
219 PyObject
*_res
= NULL
;
221 if (!PyArg_ParseTuple(_args
, ""))
223 _rv
= GetEventKind(_self
->ob_itself
);
224 _res
= Py_BuildValue("l",
229 static PyObject
*EventRef_GetEventTime(EventRefObject
*_self
, PyObject
*_args
)
231 PyObject
*_res
= NULL
;
233 if (!PyArg_ParseTuple(_args
, ""))
235 _rv
= GetEventTime(_self
->ob_itself
);
236 _res
= Py_BuildValue("d",
241 static PyObject
*EventRef_SetEventTime(EventRefObject
*_self
, PyObject
*_args
)
243 PyObject
*_res
= NULL
;
246 if (!PyArg_ParseTuple(_args
, "d",
249 _err
= SetEventTime(_self
->ob_itself
,
251 if (_err
!= noErr
) return PyMac_Error(_err
);
257 static PyObject
*EventRef_IsUserCancelEventRef(EventRefObject
*_self
, PyObject
*_args
)
259 PyObject
*_res
= NULL
;
261 if (!PyArg_ParseTuple(_args
, ""))
263 _rv
= IsUserCancelEventRef(_self
->ob_itself
);
264 _res
= Py_BuildValue("b",
269 static PyObject
*EventRef_ConvertEventRefToEventRecord(EventRefObject
*_self
, PyObject
*_args
)
271 PyObject
*_res
= NULL
;
273 EventRecord outEvent
;
274 if (!PyArg_ParseTuple(_args
, ""))
276 _rv
= ConvertEventRefToEventRecord(_self
->ob_itself
,
278 _res
= Py_BuildValue("bO&",
280 PyMac_BuildEventRecord
, &outEvent
);
284 static PyObject
*EventRef_IsEventInMask(EventRefObject
*_self
, PyObject
*_args
)
286 PyObject
*_res
= NULL
;
289 if (!PyArg_ParseTuple(_args
, "H",
292 _rv
= IsEventInMask(_self
->ob_itself
,
294 _res
= Py_BuildValue("b",
299 static PyObject
*EventRef_SendEventToEventTarget(EventRefObject
*_self
, PyObject
*_args
)
301 PyObject
*_res
= NULL
;
303 EventTargetRef inTarget
;
304 if (!PyArg_ParseTuple(_args
, "O&",
305 EventTargetRef_Convert
, &inTarget
))
307 _err
= SendEventToEventTarget(_self
->ob_itself
,
309 if (_err
!= noErr
) return PyMac_Error(_err
);
315 static PyObject
*EventRef_GetEventParameter(EventRefObject
*_self
, PyObject
*_args
)
317 PyObject
*_res
= NULL
;
320 EventParamName inName
;
321 EventParamType inType
;
325 if (!PyArg_ParseTuple(_args
, "O&O&", PyMac_GetOSType
, &inName
, PyMac_GetOSType
, &inType
))
328 /* Figure out the size by passing a null buffer to GetEventParameter */
329 _err
= GetEventParameter(_self
->ob_itself
, inName
, inType
, NULL
, 0, &bufferSize
, NULL
);
332 return PyMac_Error(_err
);
333 buffer
= PyMem_NEW(char, bufferSize
);
335 return PyErr_NoMemory();
337 _err
= GetEventParameter(_self
->ob_itself
, inName
, inType
, NULL
, bufferSize
, NULL
, buffer
);
341 return PyMac_Error(_err
);
343 _res
= Py_BuildValue("s#", buffer
, bufferSize
);
349 static PyMethodDef EventRef_methods
[] = {
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)")},
379 #define EventRef_getsetlist NULL
382 #define EventRef_compare NULL
384 #define EventRef_repr NULL
386 #define EventRef_hash NULL
387 #define EventRef_tp_init 0
389 #define EventRef_tp_alloc PyType_GenericAlloc
391 static PyObject
*EventRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
395 char *kw
[] = {"itself", 0};
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
;
403 #define EventRef_tp_free PyObject_Del
406 PyTypeObject EventRef_Type
= {
407 PyObject_HEAD_INIT(NULL
)
409 "_CarbonEvt.EventRef", /*tp_name*/
410 sizeof(EventRefObject
), /*tp_basicsize*/
413 (destructor
) EventRef_dealloc
, /*tp_dealloc*/
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*/
425 PyObject_GenericGetAttr
, /*tp_getattro*/
426 PyObject_GenericSetAttr
, /*tp_setattro */
428 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
432 0, /*tp_richcompare*/
433 0, /*tp_weaklistoffset*/
436 EventRef_methods
, /* tp_methods */
438 EventRef_getsetlist
, /*tp_getset*/
444 EventRef_tp_init
, /* tp_init */
445 EventRef_tp_alloc
, /* tp_alloc */
446 EventRef_tp_new
, /* tp_new */
447 EventRef_tp_free
, /* tp_free */
450 /* -------------------- End object type EventRef -------------------- */
453 /* ------------------- Object type EventQueueRef -------------------- */
455 PyTypeObject EventQueueRef_Type
;
457 #define EventQueueRef_Check(x) ((x)->ob_type == &EventQueueRef_Type || PyObject_TypeCheck((x), &EventQueueRef_Type))
459 typedef struct EventQueueRefObject
{
461 EventQueueRef ob_itself
;
462 } EventQueueRefObject
;
464 PyObject
*EventQueueRef_New(EventQueueRef itself
)
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
;
473 int EventQueueRef_Convert(PyObject
*v
, EventQueueRef
*p_itself
)
475 if (!EventQueueRef_Check(v
))
477 PyErr_SetString(PyExc_TypeError
, "EventQueueRef required");
480 *p_itself
= ((EventQueueRefObject
*)v
)->ob_itself
;
484 static void EventQueueRef_dealloc(EventQueueRefObject
*self
)
486 /* Cleanup of self->ob_itself goes here */
487 self
->ob_type
->tp_free((PyObject
*)self
);
490 static PyObject
*EventQueueRef_PostEventToQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
492 PyObject
*_res
= NULL
;
496 if (!PyArg_ParseTuple(_args
, "O&h",
497 EventRef_Convert
, &inEvent
,
500 _err
= PostEventToQueue(_self
->ob_itself
,
503 if (_err
!= noErr
) return PyMac_Error(_err
);
509 static PyObject
*EventQueueRef_FlushEventsMatchingListFromQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
511 PyObject
*_res
= NULL
;
514 EventTypeSpec inList
;
515 if (!PyArg_ParseTuple(_args
, "lO&",
517 EventTypeSpec_Convert
, &inList
))
519 _err
= FlushEventsMatchingListFromQueue(_self
->ob_itself
,
522 if (_err
!= noErr
) return PyMac_Error(_err
);
528 static PyObject
*EventQueueRef_FlushEventQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
530 PyObject
*_res
= NULL
;
532 if (!PyArg_ParseTuple(_args
, ""))
534 _err
= FlushEventQueue(_self
->ob_itself
);
535 if (_err
!= noErr
) return PyMac_Error(_err
);
541 static PyObject
*EventQueueRef_GetNumEventsInQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
543 PyObject
*_res
= NULL
;
545 if (!PyArg_ParseTuple(_args
, ""))
547 _rv
= GetNumEventsInQueue(_self
->ob_itself
);
548 _res
= Py_BuildValue("l",
553 static PyObject
*EventQueueRef_RemoveEventFromQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
555 PyObject
*_res
= NULL
;
558 if (!PyArg_ParseTuple(_args
, "O&",
559 EventRef_Convert
, &inEvent
))
561 _err
= RemoveEventFromQueue(_self
->ob_itself
,
563 if (_err
!= noErr
) return PyMac_Error(_err
);
569 static PyObject
*EventQueueRef_IsEventInQueue(EventQueueRefObject
*_self
, PyObject
*_args
)
571 PyObject
*_res
= NULL
;
574 if (!PyArg_ParseTuple(_args
, "O&",
575 EventRef_Convert
, &inEvent
))
577 _rv
= IsEventInQueue(_self
->ob_itself
,
579 _res
= Py_BuildValue("b",
584 static PyMethodDef EventQueueRef_methods
[] = {
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)")},
600 #define EventQueueRef_getsetlist NULL
603 #define EventQueueRef_compare NULL
605 #define EventQueueRef_repr NULL
607 #define EventQueueRef_hash NULL
608 #define EventQueueRef_tp_init 0
610 #define EventQueueRef_tp_alloc PyType_GenericAlloc
612 static PyObject
*EventQueueRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
615 EventQueueRef itself
;
616 char *kw
[] = {"itself", 0};
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
;
624 #define EventQueueRef_tp_free PyObject_Del
627 PyTypeObject EventQueueRef_Type
= {
628 PyObject_HEAD_INIT(NULL
)
630 "_CarbonEvt.EventQueueRef", /*tp_name*/
631 sizeof(EventQueueRefObject
), /*tp_basicsize*/
634 (destructor
) EventQueueRef_dealloc
, /*tp_dealloc*/
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*/
646 PyObject_GenericGetAttr
, /*tp_getattro*/
647 PyObject_GenericSetAttr
, /*tp_setattro */
649 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
653 0, /*tp_richcompare*/
654 0, /*tp_weaklistoffset*/
657 EventQueueRef_methods
, /* tp_methods */
659 EventQueueRef_getsetlist
, /*tp_getset*/
665 EventQueueRef_tp_init
, /* tp_init */
666 EventQueueRef_tp_alloc
, /* tp_alloc */
667 EventQueueRef_tp_new
, /* tp_new */
668 EventQueueRef_tp_free
, /* tp_free */
671 /* ----------------- End object type EventQueueRef ------------------ */
674 /* -------------------- Object type EventLoopRef -------------------- */
676 PyTypeObject EventLoopRef_Type
;
678 #define EventLoopRef_Check(x) ((x)->ob_type == &EventLoopRef_Type || PyObject_TypeCheck((x), &EventLoopRef_Type))
680 typedef struct EventLoopRefObject
{
682 EventLoopRef ob_itself
;
683 } EventLoopRefObject
;
685 PyObject
*EventLoopRef_New(EventLoopRef itself
)
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
;
694 int EventLoopRef_Convert(PyObject
*v
, EventLoopRef
*p_itself
)
696 if (!EventLoopRef_Check(v
))
698 PyErr_SetString(PyExc_TypeError
, "EventLoopRef required");
701 *p_itself
= ((EventLoopRefObject
*)v
)->ob_itself
;
705 static void EventLoopRef_dealloc(EventLoopRefObject
*self
)
707 /* Cleanup of self->ob_itself goes here */
708 self
->ob_type
->tp_free((PyObject
*)self
);
711 static PyObject
*EventLoopRef_QuitEventLoop(EventLoopRefObject
*_self
, PyObject
*_args
)
713 PyObject
*_res
= NULL
;
715 if (!PyArg_ParseTuple(_args
, ""))
717 _err
= QuitEventLoop(_self
->ob_itself
);
718 if (_err
!= noErr
) return PyMac_Error(_err
);
724 static PyMethodDef EventLoopRef_methods
[] = {
725 {"QuitEventLoop", (PyCFunction
)EventLoopRef_QuitEventLoop
, 1,
726 PyDoc_STR("() -> None")},
730 #define EventLoopRef_getsetlist NULL
733 #define EventLoopRef_compare NULL
735 #define EventLoopRef_repr NULL
737 #define EventLoopRef_hash NULL
738 #define EventLoopRef_tp_init 0
740 #define EventLoopRef_tp_alloc PyType_GenericAlloc
742 static PyObject
*EventLoopRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
746 char *kw
[] = {"itself", 0};
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
;
754 #define EventLoopRef_tp_free PyObject_Del
757 PyTypeObject EventLoopRef_Type
= {
758 PyObject_HEAD_INIT(NULL
)
760 "_CarbonEvt.EventLoopRef", /*tp_name*/
761 sizeof(EventLoopRefObject
), /*tp_basicsize*/
764 (destructor
) EventLoopRef_dealloc
, /*tp_dealloc*/
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*/
776 PyObject_GenericGetAttr
, /*tp_getattro*/
777 PyObject_GenericSetAttr
, /*tp_setattro */
779 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
783 0, /*tp_richcompare*/
784 0, /*tp_weaklistoffset*/
787 EventLoopRef_methods
, /* tp_methods */
789 EventLoopRef_getsetlist
, /*tp_getset*/
795 EventLoopRef_tp_init
, /* tp_init */
796 EventLoopRef_tp_alloc
, /* tp_alloc */
797 EventLoopRef_tp_new
, /* tp_new */
798 EventLoopRef_tp_free
, /* tp_free */
801 /* ------------------ End object type EventLoopRef ------------------ */
804 /* ----------------- Object type EventLoopTimerRef ------------------ */
806 PyTypeObject EventLoopTimerRef_Type
;
808 #define EventLoopTimerRef_Check(x) ((x)->ob_type == &EventLoopTimerRef_Type || PyObject_TypeCheck((x), &EventLoopTimerRef_Type))
810 typedef struct EventLoopTimerRefObject
{
812 EventLoopTimerRef ob_itself
;
813 } EventLoopTimerRefObject
;
815 PyObject
*EventLoopTimerRef_New(EventLoopTimerRef itself
)
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
;
824 int EventLoopTimerRef_Convert(PyObject
*v
, EventLoopTimerRef
*p_itself
)
826 if (!EventLoopTimerRef_Check(v
))
828 PyErr_SetString(PyExc_TypeError
, "EventLoopTimerRef required");
831 *p_itself
= ((EventLoopTimerRefObject
*)v
)->ob_itself
;
835 static void EventLoopTimerRef_dealloc(EventLoopTimerRefObject
*self
)
837 /* Cleanup of self->ob_itself goes here */
838 self
->ob_type
->tp_free((PyObject
*)self
);
841 static PyObject
*EventLoopTimerRef_RemoveEventLoopTimer(EventLoopTimerRefObject
*_self
, PyObject
*_args
)
843 PyObject
*_res
= NULL
;
845 if (!PyArg_ParseTuple(_args
, ""))
847 _err
= RemoveEventLoopTimer(_self
->ob_itself
);
848 if (_err
!= noErr
) return PyMac_Error(_err
);
854 static PyObject
*EventLoopTimerRef_SetEventLoopTimerNextFireTime(EventLoopTimerRefObject
*_self
, PyObject
*_args
)
856 PyObject
*_res
= NULL
;
859 if (!PyArg_ParseTuple(_args
, "d",
862 _err
= SetEventLoopTimerNextFireTime(_self
->ob_itself
,
864 if (_err
!= noErr
) return PyMac_Error(_err
);
870 static PyMethodDef EventLoopTimerRef_methods
[] = {
871 {"RemoveEventLoopTimer", (PyCFunction
)EventLoopTimerRef_RemoveEventLoopTimer
, 1,
872 PyDoc_STR("() -> None")},
873 {"SetEventLoopTimerNextFireTime", (PyCFunction
)EventLoopTimerRef_SetEventLoopTimerNextFireTime
, 1,
874 PyDoc_STR("(double inNextFire) -> None")},
878 #define EventLoopTimerRef_getsetlist NULL
881 #define EventLoopTimerRef_compare NULL
883 #define EventLoopTimerRef_repr NULL
885 #define EventLoopTimerRef_hash NULL
886 #define EventLoopTimerRef_tp_init 0
888 #define EventLoopTimerRef_tp_alloc PyType_GenericAlloc
890 static PyObject
*EventLoopTimerRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
893 EventLoopTimerRef itself
;
894 char *kw
[] = {"itself", 0};
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
;
902 #define EventLoopTimerRef_tp_free PyObject_Del
905 PyTypeObject EventLoopTimerRef_Type
= {
906 PyObject_HEAD_INIT(NULL
)
908 "_CarbonEvt.EventLoopTimerRef", /*tp_name*/
909 sizeof(EventLoopTimerRefObject
), /*tp_basicsize*/
912 (destructor
) EventLoopTimerRef_dealloc
, /*tp_dealloc*/
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*/
924 PyObject_GenericGetAttr
, /*tp_getattro*/
925 PyObject_GenericSetAttr
, /*tp_setattro */
927 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
931 0, /*tp_richcompare*/
932 0, /*tp_weaklistoffset*/
935 EventLoopTimerRef_methods
, /* tp_methods */
937 EventLoopTimerRef_getsetlist
, /*tp_getset*/
943 EventLoopTimerRef_tp_init
, /* tp_init */
944 EventLoopTimerRef_tp_alloc
, /* tp_alloc */
945 EventLoopTimerRef_tp_new
, /* tp_new */
946 EventLoopTimerRef_tp_free
, /* tp_free */
949 /* --------------- End object type EventLoopTimerRef ---------------- */
952 /* ------------------ Object type EventHandlerRef ------------------- */
954 PyTypeObject EventHandlerRef_Type
;
956 #define EventHandlerRef_Check(x) ((x)->ob_type == &EventHandlerRef_Type || PyObject_TypeCheck((x), &EventHandlerRef_Type))
958 typedef struct EventHandlerRefObject
{
960 EventHandlerRef ob_itself
;
961 PyObject
*ob_callback
;
962 } EventHandlerRefObject
;
964 PyObject
*EventHandlerRef_New(EventHandlerRef itself
)
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
;
974 int EventHandlerRef_Convert(PyObject
*v
, EventHandlerRef
*p_itself
)
976 if (!EventHandlerRef_Check(v
))
978 PyErr_SetString(PyExc_TypeError
, "EventHandlerRef required");
981 *p_itself
= ((EventHandlerRefObject
*)v
)->ob_itself
;
985 static void EventHandlerRef_dealloc(EventHandlerRefObject
*self
)
987 if (self
->ob_itself
!= NULL
) {
988 RemoveEventHandler(self
->ob_itself
);
989 Py_DECREF(self
->ob_callback
);
991 self
->ob_type
->tp_free((PyObject
*)self
);
994 static PyObject
*EventHandlerRef_AddEventTypesToHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
996 PyObject
*_res
= NULL
;
999 EventTypeSpec inList
;
1000 if (_self
->ob_itself
== NULL
) {
1001 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1004 if (!PyArg_ParseTuple(_args
, "lO&",
1006 EventTypeSpec_Convert
, &inList
))
1008 _err
= AddEventTypesToHandler(_self
->ob_itself
,
1011 if (_err
!= noErr
) return PyMac_Error(_err
);
1017 static PyObject
*EventHandlerRef_RemoveEventTypesFromHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
1019 PyObject
*_res
= NULL
;
1022 EventTypeSpec inList
;
1023 if (_self
->ob_itself
== NULL
) {
1024 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1027 if (!PyArg_ParseTuple(_args
, "lO&",
1029 EventTypeSpec_Convert
, &inList
))
1031 _err
= RemoveEventTypesFromHandler(_self
->ob_itself
,
1034 if (_err
!= noErr
) return PyMac_Error(_err
);
1040 static PyObject
*EventHandlerRef_RemoveEventHandler(EventHandlerRefObject
*_self
, PyObject
*_args
)
1042 PyObject
*_res
= NULL
;
1045 if (_self
->ob_itself
== NULL
) {
1046 PyErr_SetString(CarbonEvents_Error
, "Handler has been removed");
1049 if (!PyArg_ParseTuple(_args
, ""))
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
;
1061 static PyMethodDef EventHandlerRef_methods
[] = {
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")},
1071 #define EventHandlerRef_getsetlist NULL
1074 #define EventHandlerRef_compare NULL
1076 #define EventHandlerRef_repr NULL
1078 #define EventHandlerRef_hash NULL
1079 #define EventHandlerRef_tp_init 0
1081 #define EventHandlerRef_tp_alloc PyType_GenericAlloc
1083 static PyObject
*EventHandlerRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1086 EventHandlerRef itself
;
1087 char *kw
[] = {"itself", 0};
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
;
1095 #define EventHandlerRef_tp_free PyObject_Del
1098 PyTypeObject EventHandlerRef_Type
= {
1099 PyObject_HEAD_INIT(NULL
)
1101 "_CarbonEvt.EventHandlerRef", /*tp_name*/
1102 sizeof(EventHandlerRefObject
), /*tp_basicsize*/
1105 (destructor
) EventHandlerRef_dealloc
, /*tp_dealloc*/
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*/
1117 PyObject_GenericGetAttr
, /*tp_getattro*/
1118 PyObject_GenericSetAttr
, /*tp_setattro */
1120 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1124 0, /*tp_richcompare*/
1125 0, /*tp_weaklistoffset*/
1128 EventHandlerRef_methods
, /* tp_methods */
1130 EventHandlerRef_getsetlist
, /*tp_getset*/
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 */
1142 /* ---------------- End object type EventHandlerRef ----------------- */
1145 /* ---------------- Object type EventHandlerCallRef ----------------- */
1147 PyTypeObject EventHandlerCallRef_Type
;
1149 #define EventHandlerCallRef_Check(x) ((x)->ob_type == &EventHandlerCallRef_Type || PyObject_TypeCheck((x), &EventHandlerCallRef_Type))
1151 typedef struct EventHandlerCallRefObject
{
1153 EventHandlerCallRef ob_itself
;
1154 } EventHandlerCallRefObject
;
1156 PyObject
*EventHandlerCallRef_New(EventHandlerCallRef itself
)
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
;
1165 int EventHandlerCallRef_Convert(PyObject
*v
, EventHandlerCallRef
*p_itself
)
1167 if (!EventHandlerCallRef_Check(v
))
1169 PyErr_SetString(PyExc_TypeError
, "EventHandlerCallRef required");
1172 *p_itself
= ((EventHandlerCallRefObject
*)v
)->ob_itself
;
1176 static void EventHandlerCallRef_dealloc(EventHandlerCallRefObject
*self
)
1178 /* Cleanup of self->ob_itself goes here */
1179 self
->ob_type
->tp_free((PyObject
*)self
);
1182 static PyObject
*EventHandlerCallRef_CallNextEventHandler(EventHandlerCallRefObject
*_self
, PyObject
*_args
)
1184 PyObject
*_res
= NULL
;
1187 if (!PyArg_ParseTuple(_args
, "O&",
1188 EventRef_Convert
, &inEvent
))
1190 _err
= CallNextEventHandler(_self
->ob_itself
,
1192 if (_err
!= noErr
) return PyMac_Error(_err
);
1198 static PyMethodDef EventHandlerCallRef_methods
[] = {
1199 {"CallNextEventHandler", (PyCFunction
)EventHandlerCallRef_CallNextEventHandler
, 1,
1200 PyDoc_STR("(EventRef inEvent) -> None")},
1204 #define EventHandlerCallRef_getsetlist NULL
1207 #define EventHandlerCallRef_compare NULL
1209 #define EventHandlerCallRef_repr NULL
1211 #define EventHandlerCallRef_hash NULL
1212 #define EventHandlerCallRef_tp_init 0
1214 #define EventHandlerCallRef_tp_alloc PyType_GenericAlloc
1216 static PyObject
*EventHandlerCallRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1219 EventHandlerCallRef itself
;
1220 char *kw
[] = {"itself", 0};
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
;
1228 #define EventHandlerCallRef_tp_free PyObject_Del
1231 PyTypeObject EventHandlerCallRef_Type
= {
1232 PyObject_HEAD_INIT(NULL
)
1234 "_CarbonEvt.EventHandlerCallRef", /*tp_name*/
1235 sizeof(EventHandlerCallRefObject
), /*tp_basicsize*/
1238 (destructor
) EventHandlerCallRef_dealloc
, /*tp_dealloc*/
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*/
1250 PyObject_GenericGetAttr
, /*tp_getattro*/
1251 PyObject_GenericSetAttr
, /*tp_setattro */
1253 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1257 0, /*tp_richcompare*/
1258 0, /*tp_weaklistoffset*/
1261 EventHandlerCallRef_methods
, /* tp_methods */
1263 EventHandlerCallRef_getsetlist
, /*tp_getset*/
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 */
1275 /* -------------- End object type EventHandlerCallRef --------------- */
1278 /* ------------------- Object type EventTargetRef ------------------- */
1280 PyTypeObject EventTargetRef_Type
;
1282 #define EventTargetRef_Check(x) ((x)->ob_type == &EventTargetRef_Type || PyObject_TypeCheck((x), &EventTargetRef_Type))
1284 typedef struct EventTargetRefObject
{
1286 EventTargetRef ob_itself
;
1287 } EventTargetRefObject
;
1289 PyObject
*EventTargetRef_New(EventTargetRef itself
)
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
;
1298 int EventTargetRef_Convert(PyObject
*v
, EventTargetRef
*p_itself
)
1300 if (!EventTargetRef_Check(v
))
1302 PyErr_SetString(PyExc_TypeError
, "EventTargetRef required");
1305 *p_itself
= ((EventTargetRefObject
*)v
)->ob_itself
;
1309 static void EventTargetRef_dealloc(EventTargetRefObject
*self
)
1311 /* Cleanup of self->ob_itself goes here */
1312 self
->ob_type
->tp_free((PyObject
*)self
);
1315 static PyObject
*EventTargetRef_InstallStandardEventHandler(EventTargetRefObject
*_self
, PyObject
*_args
)
1317 PyObject
*_res
= NULL
;
1319 if (!PyArg_ParseTuple(_args
, ""))
1321 _err
= InstallStandardEventHandler(_self
->ob_itself
);
1322 if (_err
!= noErr
) return PyMac_Error(_err
);
1328 static PyObject
*EventTargetRef_InstallEventHandler(EventTargetRefObject
*_self
, PyObject
*_args
)
1330 PyObject
*_res
= NULL
;
1332 EventTypeSpec inSpec
;
1334 EventHandlerRef outRef
;
1337 if (!PyArg_ParseTuple(_args
, "O&O", EventTypeSpec_Convert
, &inSpec
, &callback
))
1340 _err
= InstallEventHandler(_self
->ob_itself
, myEventHandlerUPP
, 1, &inSpec
, (void *)callback
, &outRef
);
1341 if (_err
!= noErr
) return PyMac_Error(_err
);
1343 _res
= EventHandlerRef_New(outRef
);
1345 ((EventHandlerRefObject
*)_res
)->ob_callback
= callback
;
1346 Py_INCREF(callback
);
1351 static PyMethodDef EventTargetRef_methods
[] = {
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)")},
1359 #define EventTargetRef_getsetlist NULL
1362 #define EventTargetRef_compare NULL
1364 #define EventTargetRef_repr NULL
1366 #define EventTargetRef_hash NULL
1367 #define EventTargetRef_tp_init 0
1369 #define EventTargetRef_tp_alloc PyType_GenericAlloc
1371 static PyObject
*EventTargetRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1374 EventTargetRef itself
;
1375 char *kw
[] = {"itself", 0};
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
;
1383 #define EventTargetRef_tp_free PyObject_Del
1386 PyTypeObject EventTargetRef_Type
= {
1387 PyObject_HEAD_INIT(NULL
)
1389 "_CarbonEvt.EventTargetRef", /*tp_name*/
1390 sizeof(EventTargetRefObject
), /*tp_basicsize*/
1393 (destructor
) EventTargetRef_dealloc
, /*tp_dealloc*/
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*/
1405 PyObject_GenericGetAttr
, /*tp_getattro*/
1406 PyObject_GenericSetAttr
, /*tp_setattro */
1408 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1412 0, /*tp_richcompare*/
1413 0, /*tp_weaklistoffset*/
1416 EventTargetRef_methods
, /* tp_methods */
1418 EventTargetRef_getsetlist
, /*tp_getset*/
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 */
1430 /* ----------------- End object type EventTargetRef ----------------- */
1433 /* ------------------- Object type EventHotKeyRef ------------------- */
1435 PyTypeObject EventHotKeyRef_Type
;
1437 #define EventHotKeyRef_Check(x) ((x)->ob_type == &EventHotKeyRef_Type || PyObject_TypeCheck((x), &EventHotKeyRef_Type))
1439 typedef struct EventHotKeyRefObject
{
1441 EventHotKeyRef ob_itself
;
1442 } EventHotKeyRefObject
;
1444 PyObject
*EventHotKeyRef_New(EventHotKeyRef itself
)
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
;
1453 int EventHotKeyRef_Convert(PyObject
*v
, EventHotKeyRef
*p_itself
)
1455 if (!EventHotKeyRef_Check(v
))
1457 PyErr_SetString(PyExc_TypeError
, "EventHotKeyRef required");
1460 *p_itself
= ((EventHotKeyRefObject
*)v
)->ob_itself
;
1464 static void EventHotKeyRef_dealloc(EventHotKeyRefObject
*self
)
1466 /* Cleanup of self->ob_itself goes here */
1467 self
->ob_type
->tp_free((PyObject
*)self
);
1470 static PyObject
*EventHotKeyRef_UnregisterEventHotKey(EventHotKeyRefObject
*_self
, PyObject
*_args
)
1472 PyObject
*_res
= NULL
;
1474 if (!PyArg_ParseTuple(_args
, ""))
1476 _err
= UnregisterEventHotKey(_self
->ob_itself
);
1477 if (_err
!= noErr
) return PyMac_Error(_err
);
1483 static PyMethodDef EventHotKeyRef_methods
[] = {
1484 {"UnregisterEventHotKey", (PyCFunction
)EventHotKeyRef_UnregisterEventHotKey
, 1,
1485 PyDoc_STR("() -> None")},
1489 #define EventHotKeyRef_getsetlist NULL
1492 #define EventHotKeyRef_compare NULL
1494 #define EventHotKeyRef_repr NULL
1496 #define EventHotKeyRef_hash NULL
1497 #define EventHotKeyRef_tp_init 0
1499 #define EventHotKeyRef_tp_alloc PyType_GenericAlloc
1501 static PyObject
*EventHotKeyRef_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1504 EventHotKeyRef itself
;
1505 char *kw
[] = {"itself", 0};
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
;
1513 #define EventHotKeyRef_tp_free PyObject_Del
1516 PyTypeObject EventHotKeyRef_Type
= {
1517 PyObject_HEAD_INIT(NULL
)
1519 "_CarbonEvt.EventHotKeyRef", /*tp_name*/
1520 sizeof(EventHotKeyRefObject
), /*tp_basicsize*/
1523 (destructor
) EventHotKeyRef_dealloc
, /*tp_dealloc*/
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*/
1535 PyObject_GenericGetAttr
, /*tp_getattro*/
1536 PyObject_GenericSetAttr
, /*tp_setattro */
1538 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1542 0, /*tp_richcompare*/
1543 0, /*tp_weaklistoffset*/
1546 EventHotKeyRef_methods
, /* tp_methods */
1548 EventHotKeyRef_getsetlist
, /*tp_getset*/
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 */
1560 /* ----------------- End object type EventHotKeyRef ----------------- */
1563 static PyObject
*CarbonEvents_GetCurrentEventLoop(PyObject
*_self
, PyObject
*_args
)
1565 PyObject
*_res
= NULL
;
1567 if (!PyArg_ParseTuple(_args
, ""))
1569 _rv
= GetCurrentEventLoop();
1570 _res
= Py_BuildValue("O&",
1571 EventLoopRef_New
, _rv
);
1575 static PyObject
*CarbonEvents_GetMainEventLoop(PyObject
*_self
, PyObject
*_args
)
1577 PyObject
*_res
= NULL
;
1579 if (!PyArg_ParseTuple(_args
, ""))
1581 _rv
= GetMainEventLoop();
1582 _res
= Py_BuildValue("O&",
1583 EventLoopRef_New
, _rv
);
1587 static PyObject
*CarbonEvents_RunCurrentEventLoop(PyObject
*_self
, PyObject
*_args
)
1589 PyObject
*_res
= NULL
;
1592 if (!PyArg_ParseTuple(_args
, "d",
1595 _err
= RunCurrentEventLoop(inTimeout
);
1596 if (_err
!= noErr
) return PyMac_Error(_err
);
1602 static PyObject
*CarbonEvents_ReceiveNextEvent(PyObject
*_self
, PyObject
*_args
)
1604 PyObject
*_res
= NULL
;
1607 EventTypeSpec inList
;
1609 Boolean inPullEvent
;
1611 if (!PyArg_ParseTuple(_args
, "lO&db",
1613 EventTypeSpec_Convert
, &inList
,
1617 _err
= ReceiveNextEvent(inNumTypes
,
1622 if (_err
!= noErr
) return PyMac_Error(_err
);
1623 _res
= Py_BuildValue("O&",
1624 EventRef_New
, outEvent
);
1628 static PyObject
*CarbonEvents_GetCurrentEventQueue(PyObject
*_self
, PyObject
*_args
)
1630 PyObject
*_res
= NULL
;
1632 if (!PyArg_ParseTuple(_args
, ""))
1634 _rv
= GetCurrentEventQueue();
1635 _res
= Py_BuildValue("O&",
1636 EventQueueRef_New
, _rv
);
1640 static PyObject
*CarbonEvents_GetMainEventQueue(PyObject
*_self
, PyObject
*_args
)
1642 PyObject
*_res
= NULL
;
1644 if (!PyArg_ParseTuple(_args
, ""))
1646 _rv
= GetMainEventQueue();
1647 _res
= Py_BuildValue("O&",
1648 EventQueueRef_New
, _rv
);
1652 static PyObject
*CarbonEvents_GetCurrentEventTime(PyObject
*_self
, PyObject
*_args
)
1654 PyObject
*_res
= NULL
;
1656 if (!PyArg_ParseTuple(_args
, ""))
1658 _rv
= GetCurrentEventTime();
1659 _res
= Py_BuildValue("d",
1664 static PyObject
*CarbonEvents_TrackMouseLocation(PyObject
*_self
, PyObject
*_args
)
1666 PyObject
*_res
= NULL
;
1671 if (!PyArg_ParseTuple(_args
, "O&",
1672 GrafObj_Convert
, &inPort
))
1674 _err
= TrackMouseLocation(inPort
,
1677 if (_err
!= noErr
) return PyMac_Error(_err
);
1678 _res
= Py_BuildValue("O&H",
1679 PyMac_BuildPoint
, outPt
,
1684 static PyObject
*CarbonEvents_TrackMouseLocationWithOptions(PyObject
*_self
, PyObject
*_args
)
1686 PyObject
*_res
= NULL
;
1689 OptionBits inOptions
;
1692 UInt32 outModifiers
;
1694 if (!PyArg_ParseTuple(_args
, "O&ld",
1695 GrafObj_Convert
, &inPort
,
1699 _err
= TrackMouseLocationWithOptions(inPort
,
1705 if (_err
!= noErr
) return PyMac_Error(_err
);
1706 _res
= Py_BuildValue("O&lH",
1707 PyMac_BuildPoint
, outPt
,
1713 static PyObject
*CarbonEvents_TrackMouseRegion(PyObject
*_self
, PyObject
*_args
)
1715 PyObject
*_res
= NULL
;
1721 if (!PyArg_ParseTuple(_args
, "O&O&b",
1722 GrafObj_Convert
, &inPort
,
1723 ResObj_Convert
, &inRegion
,
1726 _err
= TrackMouseRegion(inPort
,
1730 if (_err
!= noErr
) return PyMac_Error(_err
);
1731 _res
= Py_BuildValue("bH",
1737 static PyObject
*CarbonEvents_GetLastUserEventTime(PyObject
*_self
, PyObject
*_args
)
1739 PyObject
*_res
= NULL
;
1741 if (!PyArg_ParseTuple(_args
, ""))
1743 _rv
= GetLastUserEventTime();
1744 _res
= Py_BuildValue("d",
1749 static PyObject
*CarbonEvents_IsMouseCoalescingEnabled(PyObject
*_self
, PyObject
*_args
)
1751 PyObject
*_res
= NULL
;
1753 if (!PyArg_ParseTuple(_args
, ""))
1755 _rv
= IsMouseCoalescingEnabled();
1756 _res
= Py_BuildValue("b",
1761 static PyObject
*CarbonEvents_SetMouseCoalescingEnabled(PyObject
*_self
, PyObject
*_args
)
1763 PyObject
*_res
= NULL
;
1766 Boolean outOldState
;
1767 if (!PyArg_ParseTuple(_args
, "b",
1770 _err
= SetMouseCoalescingEnabled(inNewState
,
1772 if (_err
!= noErr
) return PyMac_Error(_err
);
1773 _res
= Py_BuildValue("b",
1778 static PyObject
*CarbonEvents_GetWindowEventTarget(PyObject
*_self
, PyObject
*_args
)
1780 PyObject
*_res
= NULL
;
1783 if (!PyArg_ParseTuple(_args
, "O&",
1784 WinObj_Convert
, &inWindow
))
1786 _rv
= GetWindowEventTarget(inWindow
);
1787 _res
= Py_BuildValue("O&",
1788 EventTargetRef_New
, _rv
);
1792 static PyObject
*CarbonEvents_GetControlEventTarget(PyObject
*_self
, PyObject
*_args
)
1794 PyObject
*_res
= NULL
;
1796 ControlHandle inControl
;
1797 if (!PyArg_ParseTuple(_args
, "O&",
1798 CtlObj_Convert
, &inControl
))
1800 _rv
= GetControlEventTarget(inControl
);
1801 _res
= Py_BuildValue("O&",
1802 EventTargetRef_New
, _rv
);
1806 static PyObject
*CarbonEvents_GetMenuEventTarget(PyObject
*_self
, PyObject
*_args
)
1808 PyObject
*_res
= NULL
;
1811 if (!PyArg_ParseTuple(_args
, "O&",
1812 MenuObj_Convert
, &inMenu
))
1814 _rv
= GetMenuEventTarget(inMenu
);
1815 _res
= Py_BuildValue("O&",
1816 EventTargetRef_New
, _rv
);
1820 static PyObject
*CarbonEvents_GetApplicationEventTarget(PyObject
*_self
, PyObject
*_args
)
1822 PyObject
*_res
= NULL
;
1824 if (!PyArg_ParseTuple(_args
, ""))
1826 _rv
= GetApplicationEventTarget();
1827 _res
= Py_BuildValue("O&",
1828 EventTargetRef_New
, _rv
);
1832 static PyObject
*CarbonEvents_GetUserFocusEventTarget(PyObject
*_self
, PyObject
*_args
)
1834 PyObject
*_res
= NULL
;
1836 if (!PyArg_ParseTuple(_args
, ""))
1838 _rv
= GetUserFocusEventTarget();
1839 _res
= Py_BuildValue("O&",
1840 EventTargetRef_New
, _rv
);
1844 static PyObject
*CarbonEvents_GetEventDispatcherTarget(PyObject
*_self
, PyObject
*_args
)
1846 PyObject
*_res
= NULL
;
1848 if (!PyArg_ParseTuple(_args
, ""))
1850 _rv
= GetEventDispatcherTarget();
1851 _res
= Py_BuildValue("O&",
1852 EventTargetRef_New
, _rv
);
1856 static PyObject
*CarbonEvents_RunApplicationEventLoop(PyObject
*_self
, PyObject
*_args
)
1858 PyObject
*_res
= NULL
;
1859 if (!PyArg_ParseTuple(_args
, ""))
1861 RunApplicationEventLoop();
1867 static PyObject
*CarbonEvents_QuitApplicationEventLoop(PyObject
*_self
, PyObject
*_args
)
1869 PyObject
*_res
= NULL
;
1870 if (!PyArg_ParseTuple(_args
, ""))
1872 QuitApplicationEventLoop();
1878 static PyObject
*CarbonEvents_RunAppModalLoopForWindow(PyObject
*_self
, PyObject
*_args
)
1880 PyObject
*_res
= NULL
;
1883 if (!PyArg_ParseTuple(_args
, "O&",
1884 WinObj_Convert
, &inWindow
))
1886 _err
= RunAppModalLoopForWindow(inWindow
);
1887 if (_err
!= noErr
) return PyMac_Error(_err
);
1893 static PyObject
*CarbonEvents_QuitAppModalLoopForWindow(PyObject
*_self
, PyObject
*_args
)
1895 PyObject
*_res
= NULL
;
1898 if (!PyArg_ParseTuple(_args
, "O&",
1899 WinObj_Convert
, &inWindow
))
1901 _err
= QuitAppModalLoopForWindow(inWindow
);
1902 if (_err
!= noErr
) return PyMac_Error(_err
);
1908 static PyObject
*CarbonEvents_BeginAppModalStateForWindow(PyObject
*_self
, PyObject
*_args
)
1910 PyObject
*_res
= NULL
;
1913 if (!PyArg_ParseTuple(_args
, "O&",
1914 WinObj_Convert
, &inWindow
))
1916 _err
= BeginAppModalStateForWindow(inWindow
);
1917 if (_err
!= noErr
) return PyMac_Error(_err
);
1923 static PyObject
*CarbonEvents_EndAppModalStateForWindow(PyObject
*_self
, PyObject
*_args
)
1925 PyObject
*_res
= NULL
;
1928 if (!PyArg_ParseTuple(_args
, "O&",
1929 WinObj_Convert
, &inWindow
))
1931 _err
= EndAppModalStateForWindow(inWindow
);
1932 if (_err
!= noErr
) return PyMac_Error(_err
);
1938 static PyObject
*CarbonEvents_SetUserFocusWindow(PyObject
*_self
, PyObject
*_args
)
1940 PyObject
*_res
= NULL
;
1943 if (!PyArg_ParseTuple(_args
, "O&",
1944 WinObj_Convert
, &inWindow
))
1946 _err
= SetUserFocusWindow(inWindow
);
1947 if (_err
!= noErr
) return PyMac_Error(_err
);
1953 static PyObject
*CarbonEvents_GetUserFocusWindow(PyObject
*_self
, PyObject
*_args
)
1955 PyObject
*_res
= NULL
;
1957 if (!PyArg_ParseTuple(_args
, ""))
1959 _rv
= GetUserFocusWindow();
1960 _res
= Py_BuildValue("O&",
1965 static PyObject
*CarbonEvents_SetWindowDefaultButton(PyObject
*_self
, PyObject
*_args
)
1967 PyObject
*_res
= NULL
;
1970 ControlHandle inControl
;
1971 if (!PyArg_ParseTuple(_args
, "O&O&",
1972 WinObj_Convert
, &inWindow
,
1973 CtlObj_Convert
, &inControl
))
1975 _err
= SetWindowDefaultButton(inWindow
,
1977 if (_err
!= noErr
) return PyMac_Error(_err
);
1983 static PyObject
*CarbonEvents_SetWindowCancelButton(PyObject
*_self
, PyObject
*_args
)
1985 PyObject
*_res
= NULL
;
1988 ControlHandle inControl
;
1989 if (!PyArg_ParseTuple(_args
, "O&O&",
1990 WinObj_Convert
, &inWindow
,
1991 CtlObj_Convert
, &inControl
))
1993 _err
= SetWindowCancelButton(inWindow
,
1995 if (_err
!= noErr
) return PyMac_Error(_err
);
2001 static PyObject
*CarbonEvents_GetWindowDefaultButton(PyObject
*_self
, PyObject
*_args
)
2003 PyObject
*_res
= NULL
;
2006 ControlHandle outControl
;
2007 if (!PyArg_ParseTuple(_args
, "O&",
2008 WinObj_Convert
, &inWindow
))
2010 _err
= GetWindowDefaultButton(inWindow
,
2012 if (_err
!= noErr
) return PyMac_Error(_err
);
2013 _res
= Py_BuildValue("O&",
2014 CtlObj_New
, outControl
);
2018 static PyObject
*CarbonEvents_GetWindowCancelButton(PyObject
*_self
, PyObject
*_args
)
2020 PyObject
*_res
= NULL
;
2023 ControlHandle outControl
;
2024 if (!PyArg_ParseTuple(_args
, "O&",
2025 WinObj_Convert
, &inWindow
))
2027 _err
= GetWindowCancelButton(inWindow
,
2029 if (_err
!= noErr
) return PyMac_Error(_err
);
2030 _res
= Py_BuildValue("O&",
2031 CtlObj_New
, outControl
);
2035 static PyObject
*CarbonEvents_RegisterEventHotKey(PyObject
*_self
, PyObject
*_args
)
2037 PyObject
*_res
= NULL
;
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",
2048 EventHotKeyID_Convert
, &inHotKeyID
,
2049 EventTargetRef_Convert
, &inTarget
,
2052 _err
= RegisterEventHotKey(inHotKeyCode
,
2058 if (_err
!= noErr
) return PyMac_Error(_err
);
2059 _res
= Py_BuildValue("O&",
2060 EventHotKeyRef_New
, outRef
);
2064 static PyMethodDef CarbonEvents_methods
[] = {
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)")},
2132 #else /* __LP64__ */
2134 static PyMethodDef CarbonEvents_methods
[] = {
2138 #endif /* __LP64__ */
2142 void init_CarbonEvt(void)
2147 #endif /* !__LP64__ */
2150 m
= Py_InitModule("_CarbonEvt", CarbonEvents_methods
);
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)
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
);
2215 #endif /* !__LP64__ */
2218 /* ===================== End module _CarbonEvt ====================== */