PageRenderTime 88ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/Mac/Modules/carbonevt/_CarbonEvtmodule.c

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