jeyzu pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=a7dfaef21522ef239ed802eae125d655f537c757
commit a7dfaef21522ef239ed802eae125d655f537c757 Author: Jérémy Zurcher <jer...@asynk.ch> Date: Thu Jul 3 23:05:57 2014 +0200 Revert "ecore: animator use eo_add() instead of eo_add_custom()" mmhhmm, missing @ Constructor tag, bad for the bindings, maybe we must split animator and timeline into 2 classes, maybe support callback hot swaping ... This reverts commit ec4ffb86d6bc9a3d4e4e81b80359abd7bbdb8f22. --- src/lib/ecore/ecore_anim.c | 84 ++++++++++++++++------------------- src/lib/ecore/ecore_animator.eo | 64 +++++--------------------- src/tests/ecore/ecore_test_animator.c | 7 +-- 3 files changed, 52 insertions(+), 103 deletions(-) diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c index 0ff0169..892359f 100644 --- a/src/lib/ecore/ecore_anim.c +++ b/src/lib/ecore/ecore_anim.c @@ -154,35 +154,42 @@ _do_tick(void) return ECORE_CALLBACK_RENEW; } -EOLIAN static Eo * -_ecore_animator_eo_base_finalize(Eo *obj, Ecore_Animator_Data *animator) +static Eina_Bool +_ecore_animator_add(Ecore_Animator *obj, + Ecore_Animator_Data *animator, + Ecore_Task_Cb func, + const void *data) { - if (!animator->func) - { - eo_error_set(obj); - ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); - goto finalize; - } + if (EINA_UNLIKELY(!eina_main_loop_is())) + { + eo_error_set(obj); + EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE); + } + + animator->obj = obj; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_manual_free_set(obj, EINA_TRUE); - if (EINA_UNLIKELY(!eina_main_loop_is())) + if (!func) { eo_error_set(obj); - EINA_MAIN_LOOP_CHECK_RETURN_VAL( - eo_do_super(obj, MY_CLASS, eo_finalize())); - goto finalize; + ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); + return EINA_FALSE; } - _ecore_lock(); - - eo_manual_free_set(obj, EINA_TRUE); + animator->func = func; + animator->data = (void *)data; animator->just_added = EINA_TRUE; animators = (Ecore_Animator_Data *)eina_inlist_append(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); - _begin_tick(); - _ecore_unlock(); + return EINA_TRUE; +} -finalize: - return eo_do_super(obj, MY_CLASS, eo_finalize()); +EOLIAN static void +_ecore_animator_eo_base_constructor(Eo *obj, Ecore_Animator_Data *_pd EINA_UNUSED) +{ + eo_error_set(obj); + ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); } EAPI Ecore_Animator * @@ -191,27 +198,17 @@ ecore_animator_add(Ecore_Task_Cb func, { Ecore_Animator *animator = NULL; - animator = eo_add(MY_CLASS, _ecore_parent, - ecore_obj_animator_init(func, data)); + animator = eo_add_custom(MY_CLASS, _ecore_parent, + ecore_animator_constructor(func, data)); eo_unref(animator); return animator; } EOLIAN static void -_ecore_animator_init(Eo *obj, Ecore_Animator_Data *animator, Ecore_Task_Cb func, const void *data) +_ecore_animator_constructor(Eo *obj, Ecore_Animator_Data *animator, Ecore_Task_Cb func, const void *data) { - if (animator->func != NULL) - { - ERR("do not call this function out of '%s' object construction", MY_CLASS_NAME); - return; - } - _ecore_lock(); - - animator->obj = obj; - animator->func = func; - animator->data = (void *)data; - + _ecore_animator_add(obj, animator, func, data); _ecore_unlock(); } @@ -221,32 +218,27 @@ ecore_animator_timeline_add(double runtime, const void *data) { Ecore_Animator *animator; - animator = eo_add(MY_CLASS, _ecore_parent, - ecore_obj_animator_timeline_init(runtime, func, data)); + animator = eo_add_custom(MY_CLASS, _ecore_parent, + ecore_animator_timeline_constructor(runtime, func, data)); eo_unref(animator); return animator; } EOLIAN static void -_ecore_animator_timeline_init(Eo *obj, Ecore_Animator_Data *animator, double runtime, Ecore_Timeline_Cb func, const void *data) +_ecore_animator_timeline_constructor(Eo *obj, Ecore_Animator_Data *animator, double runtime, Ecore_Timeline_Cb func, const void *data) { - if (animator->func != NULL) - { - ERR("do not call this function out of '%s' object construction", MY_CLASS_NAME); - return; - } - if (runtime < 0.0) runtime = 0.0; - _ecore_lock(); + if (runtime <= 0.0) runtime = 0.0; + + if (!_ecore_animator_add(obj, animator, _ecore_animator_run, NULL)) goto unlock; - animator->obj = obj; - animator->func = _ecore_animator_run; animator->data = obj; animator->run_func = func; animator->run_data = (void *)data; animator->start = ecore_loop_time_get(); animator->run = runtime; +unlock: _ecore_unlock(); } @@ -695,4 +687,4 @@ _ecore_animator(void *data EINA_UNUSED) return r; } -#include "ecore_animator.eo.c" +#include "ecore_animator.eo.c" \ No newline at end of file diff --git a/src/lib/ecore/ecore_animator.eo b/src/lib/ecore/ecore_animator.eo index 213dcd3..e9a3999 100644 --- a/src/lib/ecore/ecore_animator.eo +++ b/src/lib/ecore/ecore_animator.eo @@ -1,65 +1,25 @@ class Ecore.Animator (Eo.Base) { - legacy_prefix: null; - eo_prefix: ecore_obj_animator; - methods { - init { - /*@ - Set the @p func to be called at every animation tick during main loop execution. - - The function @p func will be called every N seconds where N is - the @p frametime interval set by ecore_animator_frametime_set(). The - function will be passed the @p data pointer as its parameter. - - When the animator @p func is called, it must return a boolean value. - If it returns EINA_TRUE (or ECORE_CALLBACK_RENEW), it will be called again at - the next tick, or if it returns EINA_FALSE (or ECORE_CALLBACK_CANCEL) it will be - deleted automatically making any references/handles for it invalid. - - @note Do NOT call this method outside of object constructor. - - @note The default @p frametime value is 1/30th of a second. - - @see ecore_obj_animator_timeline_set() - @see ecore_animator_frametime_set() */ + eo_prefix: ecore_animator; + constructors { + timeline_constructor { + /*@ Contructor. */ params { - @in Ecore_Task_Cb func; /*@ The function to call when it ticks off */ - @in const(void)* data; /*@ The data to pass to the function */ + @in double runtime; + @in Ecore_Timeline_Cb func; + @in const(void)* data; } } - timeline_init { - /*@ - Set the @p func to be called at every animation tick during main loop execution, that runs for a limited time - - This function is just like ecore_obj_animator_task_set() except the animator only - runs for a limited time specified in seconds by @p runtime. Once the - runtime the animator has elapsed (animator finished) it will automatically - be deleted. The callback function @p func can return ECORE_CALLBACK_RENEW - to keep the animator running or ECORE_CALLBACK_CANCEL ro stop it and have - it be deleted automatically at any time. - - The @p func will ALSO be passed a position parameter that will be in value - from 0.0 to 1.0 to indicate where along the timeline (0.0 start, 1.0 end) - the animator run is at. If the callback wishes not to have a linear - transition it can "map" this value to one of several curves and mappings - via ecore_animator_pos_map(). - - @note Do NOT call this method outside of object constructor. - - @note The default @p frametime value is 1/30th of a second. - - @see ecore_obj_animator_task_set() - @see ecore_animator_pos_map() - @since 1.1.0 */ + constructor { + /*@ Contructor. */ params { - @in double runtime; /*@ The time to run in seconds */ - @in Ecore_Timeline_Cb func; /*@ The function to call when it ticks off */ - @in const(void)* data; /*@ The data to pass to the function */ + @in Ecore_Task_Cb func; + @in const(void)* data; } } } implements { - Eo.Base.finalize; + Eo.Base.constructor; Eo.Base.destructor; Eo.Base.event_freeze; Eo.Base.event_thaw; diff --git a/src/tests/ecore/ecore_test_animator.c b/src/tests/ecore/ecore_test_animator.c index 170379b..852e8b5 100644 --- a/src/tests/ecore/ecore_test_animator.c +++ b/src/tests/ecore/ecore_test_animator.c @@ -29,18 +29,15 @@ START_TEST(ecore_test_animators) fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n"); ecore_animator_frametime_set(interval1); + animator = eo_add_custom(ECORE_ANIMATOR_CLASS, NULL, ecore_animator_timeline_constructor(1, _anim_cb, &interval1)); - animator = eo_add(ECORE_ANIMATOR_CLASS, NULL); - fail_if(animator); - - animator = eo_add(ECORE_ANIMATOR_CLASS, NULL, ecore_obj_animator_timeline_init(1, _anim_cb, &interval1)); fail_if(!animator); ecore_main_loop_begin(); ecore_animator_frametime_set(interval2); prev = 0; - animator = eo_add(ECORE_ANIMATOR_CLASS, NULL, ecore_obj_animator_timeline_init(1, _anim_cb, &interval2)); + animator = eo_add_custom(ECORE_ANIMATOR_CLASS, NULL, ecore_animator_timeline_constructor(1, _anim_cb, &interval2)); fail_if(!animator); ecore_main_loop_begin(); --