From 44363096d95835c07758e2b627e7fa20d011fa8a Mon Sep 17 00:00:00 2001 From: discomfitor Date: Thu, 4 Nov 2010 20:51:17 +0000 Subject: [PATCH] ++ecore_event_handler_data_{set,get} git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@54162 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore/Ecore.h | 2 ++ src/lib/ecore/ecore_events.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h index b786de6..c96babd 100644 --- a/src/lib/ecore/Ecore.h +++ b/src/lib/ecore/Ecore.h @@ -361,6 +361,8 @@ extern "C" { EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler); EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data); EAPI void *ecore_event_del(Ecore_Event *event); + EAPI void *ecore_event_handler_data_get(Ecore_Event_Handler *eh); + EAPI void *ecore_event_handler_data_set(Ecore_Event_Handler *eh, void *data); EAPI int ecore_event_type_new(void); EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data); EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef); diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c index 0c788cd..8256d94 100644 --- a/src/lib/ecore/ecore_events.c +++ b/src/lib/ecore/ecore_events.c @@ -170,6 +170,45 @@ ecore_event_handler_del(Ecore_Event_Handler *event_handler) return event_handler->data; } +/** + * @brief Get the data associated with an #Ecore_Event_Handler + * @param eh The event handler + * @return The data + * This function returns the data previously associated with @p eh. + */ +EAPI void * +ecore_event_handler_data_get(Ecore_Event_Handler *eh) +{ + if (!ECORE_MAGIC_CHECK(eh, ECORE_MAGIC_EVENT_HANDLER)) + { + ECORE_MAGIC_FAIL(eh, ECORE_MAGIC_EVENT_HANDLER, "ecore_event_handler_data_get"); + return NULL; + } + return eh->data; +} + +/** + * @brief Set the data associated with an #Ecore_Event_Handler + * @param eh The event handler + * @param data The data to associate + * @return The previous data + * This function sets @p data to @p eh and returns the old data pointer + * which was previously associated with @p eh. + */ +EAPI void * +ecore_event_handler_data_set(Ecore_Event_Handler *eh, void *data) +{ + void *old; + if (!ECORE_MAGIC_CHECK(eh, ECORE_MAGIC_EVENT_HANDLER)) + { + ECORE_MAGIC_FAIL(eh, ECORE_MAGIC_EVENT_HANDLER, "ecore_event_handler_data_get"); + return NULL; + } + old = eh->data; + eh->data = data; + return old; +} + static void _ecore_event_generic_free (void *data __UNUSED__, void *event) { -- 2.7.4