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