forked from enlightenment/efl
eo2: migrated signals test to eo2.
This commit is contained in:
parent
760a74a150
commit
18698086b4
|
@ -29,8 +29,8 @@ _a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event
|
|||
|
||||
cb_count++;
|
||||
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423));
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423));
|
||||
|
||||
/* Stop as we reached the 3rd one. */
|
||||
return (cb_count != 3);
|
||||
|
@ -43,136 +43,136 @@ main(int argc, char *argv[])
|
|||
(void) argv;
|
||||
eo_init();
|
||||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||
|
||||
/* The order of these two is undetermined. */
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
/* This will be called afterwards. */
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3));
|
||||
/* This will never be called because the previous callback returns NULL. */
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4));
|
||||
|
||||
eo_do(obj, simple_a_set(1));
|
||||
eo2_do(obj, simple_a_set(1));
|
||||
|
||||
fail_if(cb_count != 3);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3));
|
||||
fail_if(pd->cb_count != 3);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12));
|
||||
fail_if(pd->cb_count != 3);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4));
|
||||
fail_if(pd->cb_count != 2);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
|
||||
fail_if(pd->cb_count != 0);
|
||||
|
||||
/* Freeze/thaw. */
|
||||
int fcount = 0;
|
||||
cb_count = 0;
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(obj, eo_event_freeze());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_freeze());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(obj, eo_event_freeze());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_freeze());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 2);
|
||||
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eo_do(obj, simple_a_set(2));
|
||||
eo2_do(obj, simple_a_set(2));
|
||||
fail_if(cb_count != 0);
|
||||
eo_do(obj, eo_event_thaw());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_thaw());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(obj, eo_event_thaw());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_thaw());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(obj, simple_a_set(3));
|
||||
eo2_do(obj, simple_a_set(3));
|
||||
fail_if(cb_count != 2);
|
||||
|
||||
cb_count = 0;
|
||||
eo_do(obj, eo_event_thaw());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_thaw());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(obj, eo_event_freeze());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_freeze());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(obj, simple_a_set(2));
|
||||
eo2_do(obj, simple_a_set(2));
|
||||
fail_if(cb_count != 0);
|
||||
eo_do(obj, eo_event_thaw());
|
||||
eo_do(obj, eo_event_freeze_get(&fcount));
|
||||
eo2_do(obj, eo2_event_thaw());
|
||||
eo2_do(obj, fcount = eo2_event_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
|
||||
fail_if(pd->cb_count != 0);
|
||||
eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
|
||||
fail_if(pd->cb_count != -1);
|
||||
|
||||
/* Global Freeze/thaw. */
|
||||
fcount = 0;
|
||||
cb_count = 0;
|
||||
pd->cb_count = 0;
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 2);
|
||||
|
||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eo_do(obj, simple_a_set(2));
|
||||
eo2_do(obj, simple_a_set(2));
|
||||
fail_if(cb_count != 0);
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_thaw());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_thaw());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(obj, simple_a_set(3));
|
||||
eo2_do(obj, simple_a_set(3));
|
||||
fail_if(cb_count != 2);
|
||||
|
||||
cb_count = 0;
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_thaw());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_freeze());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 1);
|
||||
|
||||
eo_do(obj, simple_a_set(2));
|
||||
eo2_do(obj, simple_a_set(2));
|
||||
fail_if(cb_count != 0);
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_thaw());
|
||||
eo_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
|
||||
eo2_do(EO2_BASE_CLASS, eo2_event_global_thaw());
|
||||
eo2_do(EO2_BASE_CLASS, fcount = eo2_event_global_freeze_get());
|
||||
fail_if(fcount != 0);
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include "Eo.h"
|
||||
#include "signals_simple.h"
|
||||
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Simple_Public_Data pub;
|
||||
|
@ -19,15 +17,13 @@ EAPI const Eo_Event_Description _EV_A_CHANGED =
|
|||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eo *obj, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data, int a)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
pd->a = a;
|
||||
printf("%s %d\n", __func__, pd->a);
|
||||
|
||||
eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
|
||||
eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a));
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
|
@ -65,48 +61,40 @@ _cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_inf
|
|||
}
|
||||
|
||||
static void
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eo_do_super(obj, MY_CLASS, eo_constructor());
|
||||
eo2_do_super(obj, MY_CLASS, eo2_constructor());
|
||||
|
||||
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
|
||||
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
|
||||
eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
|
||||
eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
|
||||
|
||||
eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL));
|
||||
eo2_do(obj, eo2_base_data_set("cb_count", (intptr_t) 0, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a);
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
static Eo2_Op_Description op_descs[] = {
|
||||
EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor),
|
||||
EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"),
|
||||
EO2_OP_SENTINEL
|
||||
};
|
||||
|
||||
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
EV_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO2_CLASS_DESCRIPTION_OPS(op_descs),
|
||||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
_class_constructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,26 +1,12 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
SIMPLE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int cb_count;
|
||||
} Simple_Public_Data;
|
||||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
/**
|
||||
* @def simple_a_set(a)
|
||||
* @brief Set value to a - property
|
||||
* @param[in] a integer value to set
|
||||
*/
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
EAPI void simple_a_set(int a);
|
||||
|
||||
extern const Eo_Event_Description _EV_A_CHANGED;
|
||||
#define EV_A_CHANGED (&(_EV_A_CHANGED))
|
||||
|
|
Loading…
Reference in New Issue