ecore: Create callback wrappers
This gets rid of a lot of temporary variables and cleans the code up again... Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> SVN revision: 62342
This commit is contained in:
parent
cc7d5115c3
commit
f05e37addf
|
@ -99,17 +99,7 @@ _do_tick(void)
|
|||
{
|
||||
if (!animator->delete_me && !animator->suspended)
|
||||
{
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
Eina_Bool ret;
|
||||
|
||||
func = animator->func;
|
||||
data = animator->data;
|
||||
_ecore_unlock();
|
||||
ret = func(data);
|
||||
_ecore_lock();
|
||||
|
||||
if (!ret)
|
||||
if (!_ecore_call_task_cb(animator->func, animator->data))
|
||||
{
|
||||
animator->delete_me = EINA_TRUE;
|
||||
animators_delete_me++;
|
||||
|
|
|
@ -516,20 +516,7 @@ _ecore_event_del(Ecore_Event *event)
|
|||
void *data;
|
||||
|
||||
data = event->data;
|
||||
if (event->func_free)
|
||||
{
|
||||
Ecore_End_Cb func_free;
|
||||
void *ev;
|
||||
void *data;
|
||||
|
||||
func_free = event->func_free;
|
||||
ev = event->event;
|
||||
data = event->data;
|
||||
|
||||
_ecore_unlock();
|
||||
func_free(data, ev);
|
||||
_ecore_lock();
|
||||
}
|
||||
if (event->func_free) _ecore_call_end_cb(event->func_free, event->data, event->event);
|
||||
events = (Ecore_Event *) eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
|
||||
ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
|
||||
free(event);
|
||||
|
@ -583,18 +570,7 @@ _ecore_event_filters_apply()
|
|||
ef->references++;
|
||||
|
||||
if (ef->func_start)
|
||||
{
|
||||
Ecore_Data_Cb func_start;
|
||||
void *data;
|
||||
void *r;
|
||||
|
||||
func_start = ef->func_start;
|
||||
data = ef->data;
|
||||
_ecore_unlock();
|
||||
r = func_start(data);
|
||||
_ecore_lock();
|
||||
ef->loop_data = r;
|
||||
}
|
||||
ef->loop_data = _ecore_call_data_cb(ef->func_start, ef->data);
|
||||
|
||||
if (!event_filter_event_current)
|
||||
{
|
||||
|
@ -610,23 +586,9 @@ _ecore_event_filters_apply()
|
|||
while (event_filter_event_current)
|
||||
{
|
||||
Ecore_Event *e = event_filter_event_current;
|
||||
Ecore_Filter_Cb func_filter;
|
||||
void *loop_data;
|
||||
void *data;
|
||||
int type;
|
||||
void *event;
|
||||
Eina_Bool r;
|
||||
|
||||
func_filter = ef->func_filter;
|
||||
data = ef->data;
|
||||
loop_data = ef->loop_data;
|
||||
type = e->type;
|
||||
event = e->event;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func_filter(data, loop_data, type, event);
|
||||
_ecore_lock();
|
||||
if (!r)
|
||||
if (!_ecore_call_filter_cb(ef->func_filter, ef->data,
|
||||
ef->loop_data, e->type, e->event))
|
||||
{
|
||||
ecore_event_del(e);
|
||||
}
|
||||
|
@ -635,19 +597,7 @@ _ecore_event_filters_apply()
|
|||
event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
|
||||
}
|
||||
if (ef->func_end)
|
||||
{
|
||||
Ecore_End_Cb func_end;
|
||||
void *loop_data;
|
||||
void *data;
|
||||
|
||||
func_end = ef->func_end;
|
||||
data = ef->data;
|
||||
loop_data = ef->loop_data;
|
||||
|
||||
_ecore_unlock();
|
||||
ef->func_end(ef->data, ef->loop_data);
|
||||
_ecore_lock();
|
||||
}
|
||||
_ecore_call_end_cb(ef->func_end, ef->data, ef->loop_data);
|
||||
|
||||
ef->references--;
|
||||
}
|
||||
|
@ -727,22 +677,12 @@ _ecore_event_call(void)
|
|||
eh = event_handler_current;
|
||||
if (!eh->delete_me)
|
||||
{
|
||||
Ecore_Event_Handler_Cb func;
|
||||
void *data;
|
||||
int type;
|
||||
void *event;
|
||||
Eina_Bool ret;
|
||||
|
||||
handle_count++;
|
||||
|
||||
func = eh->func;
|
||||
data = eh->data;
|
||||
type = e->type;
|
||||
event = e->event;
|
||||
eh->references++;
|
||||
_ecore_unlock();
|
||||
ret = func(data, type, event);
|
||||
_ecore_lock();
|
||||
ret = _ecore_call_handler_cb(eh->func, eh->data, e->type, e->event);
|
||||
eh->references--;
|
||||
|
||||
if (!ret)
|
||||
|
|
|
@ -161,17 +161,8 @@ _ecore_idle_enterer_call(void)
|
|||
Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current;
|
||||
if (!ie->delete_me)
|
||||
{
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
Eina_Bool ret;
|
||||
|
||||
func = ie->func;
|
||||
data = ie->data;
|
||||
ie->references++;
|
||||
_ecore_unlock();
|
||||
ret = func(data);
|
||||
_ecore_lock();
|
||||
if (!ret)
|
||||
if (!_ecore_call_task_cb(ie->func, ie->data))
|
||||
{
|
||||
if (!ie->delete_me) _ecore_idle_enterer_del(ie);
|
||||
}
|
||||
|
|
|
@ -129,17 +129,8 @@ _ecore_idle_exiter_call(void)
|
|||
Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current;
|
||||
if (!ie->delete_me)
|
||||
{
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
Eina_Bool ret;
|
||||
|
||||
func = ie->func;
|
||||
data = ie->data;
|
||||
ie->references++;
|
||||
_ecore_unlock();
|
||||
ret = func(data);
|
||||
_ecore_lock();
|
||||
if (!ret)
|
||||
if (!_ecore_call_task_cb(ie->func, ie->data))
|
||||
{
|
||||
if (!ie->delete_me) _ecore_idle_exiter_del(ie);
|
||||
}
|
||||
|
|
|
@ -113,17 +113,8 @@ _ecore_idler_call(void)
|
|||
Ecore_Idler *ie = (Ecore_Idler *)idler_current;
|
||||
if (!ie->delete_me)
|
||||
{
|
||||
Eina_Bool ret;
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
|
||||
func = ie->func;
|
||||
data = ie->data;
|
||||
ie->references++;
|
||||
_ecore_unlock();
|
||||
ret = func(data);
|
||||
_ecore_lock();
|
||||
if (!ret)
|
||||
if (!_ecore_call_task_cb(ie->func, ie->data))
|
||||
{
|
||||
if (!ie->delete_me) _ecore_idler_del(ie);
|
||||
}
|
||||
|
|
|
@ -1255,15 +1255,8 @@ _ecore_main_prepare_handlers(void)
|
|||
}
|
||||
if (!fdh->delete_me && fdh->prep_func)
|
||||
{
|
||||
Ecore_Fd_Prep_Cb prep_func;
|
||||
void *prep_data;
|
||||
|
||||
prep_func = fdh->prep_func;
|
||||
prep_data = fdh->prep_data;
|
||||
fdh->references++;
|
||||
_ecore_unlock();
|
||||
prep_func(prep_data, fdh);
|
||||
_ecore_lock();
|
||||
_ecore_call_prep_cb(fdh->prep_func, fdh->prep_data, fdh);
|
||||
fdh->references--;
|
||||
}
|
||||
else
|
||||
|
@ -1413,13 +1406,9 @@ _ecore_main_fd_handlers_bads_rem(void)
|
|||
ERR("Found bad fd at index %d", fdh->fd);
|
||||
if (fdh->flags & ECORE_FD_ERROR)
|
||||
{
|
||||
Eina_Bool ret;
|
||||
ERR("Fd set for error! calling user");
|
||||
fdh->references++;
|
||||
_ecore_unlock();
|
||||
ret = fdh->func(fdh->data, fdh);
|
||||
_ecore_lock();
|
||||
if (!ret)
|
||||
if (!_ecore_call_fd_cb(fdh->func, fdh->data, fdh))
|
||||
{
|
||||
ERR("Fd function err returned 0, remove it");
|
||||
if (!fdh->delete_me)
|
||||
|
@ -1539,12 +1528,8 @@ _ecore_main_fd_handlers_call(void)
|
|||
(fdh->write_active) ||
|
||||
(fdh->error_active))
|
||||
{
|
||||
Eina_Bool ret;
|
||||
fdh->references++;
|
||||
_ecore_unlock();
|
||||
ret = fdh->func(fdh->data, fdh);
|
||||
_ecore_lock();
|
||||
if (!ret)
|
||||
if (!_ecore_call_fd_cb(fdh->func, fdh->data, fdh))
|
||||
{
|
||||
if (!fdh->delete_me)
|
||||
{
|
||||
|
@ -1592,27 +1577,10 @@ _ecore_main_fd_handlers_buf_call(void)
|
|||
}
|
||||
if ((!fdh->delete_me) && fdh->buf_func)
|
||||
{
|
||||
Ecore_Fd_Cb buf_func;
|
||||
void *buf_data;
|
||||
Eina_Bool r;
|
||||
|
||||
/* copy data before releasing lock */
|
||||
buf_func = fdh->buf_func;
|
||||
buf_data = fdh->buf_data;
|
||||
fdh->references++;
|
||||
_ecore_unlock();
|
||||
r = buf_func(buf_data, fdh);
|
||||
_ecore_lock();
|
||||
if (r)
|
||||
if (_ecore_call_fd_cb(fdh->buf_func, fdh->buf_data, fdh))
|
||||
{
|
||||
Ecore_Fd_Cb func;
|
||||
void *data;
|
||||
|
||||
func = fdh->func;
|
||||
data = fdh->data;
|
||||
_ecore_unlock();
|
||||
ret |= func(data, fdh);
|
||||
_ecore_lock();
|
||||
ret |= _ecore_call_fd_cb(fdh->func, fdh->data, fdh);
|
||||
fdh->read_active = EINA_TRUE;
|
||||
_ecore_try_add_to_call_list(fdh);
|
||||
}
|
||||
|
|
|
@ -203,17 +203,99 @@ void _ecore_throttle(void);
|
|||
void _ecore_lock(void);
|
||||
void _ecore_unlock(void);
|
||||
#else
|
||||
static inline void _ecore_lock(void)
|
||||
{
|
||||
/* at least check we're not being called from a thread */
|
||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||
}
|
||||
static inline void
|
||||
_ecore_lock(void)
|
||||
{
|
||||
/* at least check we're not being called from a thread */
|
||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||
}
|
||||
|
||||
static inline void _ecore_unlock(void)
|
||||
{
|
||||
}
|
||||
static inline void
|
||||
_ecore_unlock(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Callback wrappers all assume that ecore _ecore_lock has been called
|
||||
*/
|
||||
static inline Eina_Bool
|
||||
_ecore_call_task_cb(Ecore_Task_Cb func, void *data)
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func(data);
|
||||
_ecore_lock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
_ecore_call_data_cb(Ecore_Data_Cb func, void *data)
|
||||
{
|
||||
void *r;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func(data);
|
||||
_ecore_lock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_ecore_call_end_cb(Ecore_End_Cb func, void *user_data, void *func_data)
|
||||
{
|
||||
_ecore_unlock();
|
||||
func(user_data, func_data);
|
||||
_ecore_lock();
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_ecore_call_filter_cb(Ecore_Filter_Cb func, void *data,
|
||||
void *loop_data, int type, void *event)
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func(data, loop_data, type, event);
|
||||
_ecore_lock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_ecore_call_handler_cb(Ecore_Event_Handler_Cb func, void *data, int type, void *event)
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func(data, type, event);
|
||||
_ecore_lock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_ecore_call_prep_cb(Ecore_Fd_Prep_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
_ecore_unlock();
|
||||
func(data, fd_handler);
|
||||
_ecore_lock();
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_ecore_call_fd_cb(Ecore_Fd_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
_ecore_unlock();
|
||||
r = func(data, fd_handler);
|
||||
_ecore_lock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
extern int _ecore_fps_debug;
|
||||
extern double _ecore_time_loop_time;
|
||||
extern Eina_Bool _ecore_glib_always_integrate;
|
||||
|
|
|
@ -706,9 +706,6 @@ _ecore_timer_call(double when)
|
|||
while (timer_current)
|
||||
{
|
||||
Ecore_Timer *timer = timer_current;
|
||||
Eina_Bool cont;
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
|
||||
if (timer->at > when)
|
||||
{
|
||||
|
@ -723,12 +720,7 @@ _ecore_timer_call(double when)
|
|||
}
|
||||
|
||||
timer->references++;
|
||||
func = timer->func;
|
||||
data = timer->data;
|
||||
_ecore_unlock();
|
||||
cont = func(data);
|
||||
_ecore_lock();
|
||||
if (!cont)
|
||||
if (!_ecore_call_task_cb(timer->func, timer->data))
|
||||
{
|
||||
if (!timer->delete_me) _ecore_timer_del(timer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue