Пример #1
0
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);

   eo_do(obj, simple_a_set(1), simple_b_set(2));

   int a, b, sum = 0;
   eo_do(obj, simple_a_get(&a), simple_b_get(&b),  mixin_ab_sum_get(&sum));
   fail_if(sum != a + b + 2); /* 2 for the two mixins... */

   eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));

   Mixin2_Public_Data *pd2 = eo_data_get(obj, MIXIN2_CLASS);
   fail_if(pd2->count != 6);

   Mixin3_Public_Data *pd3 = eo_data_get(obj, MIXIN3_CLASS);
   fail_if(pd3->count != 9);

   eo_unref(obj);

   obj = eo_add(INHERIT_CLASS, NULL);
   eo_do(obj, simple_a_set(5), simple_a_get(&a));
   fail_if(a != 5);

   eo_unref(obj);
   eo_shutdown();
   return 0;
}
Пример #2
0
Файл: main.c Проект: wargio/e17
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(INHERIT2_CLASS, NULL);

   eo_do(obj, simple_a_set(1));
   Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
   fail_if(pd->a != 2);

   eo_unref(obj);

   obj = eo_add(INHERIT3_CLASS, NULL);

   eo_do(obj, simple_a_set(1));
   pd = eo_data_get(obj, SIMPLE_CLASS);
   fail_if(pd->a != 3);

   eo_unref(obj);

   obj = eo_add(INHERIT2_CLASS, NULL);
   eo_do(obj, inherit2_print());
   eo_unref(obj);

   obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(eo_do(obj, inherit2_print2()));

   fail_if(eo_do_super(obj, simple_a_print()));

   fail_if(eo_do(obj, simple_class_print()));

   fail_if(!eo_class_do(SIMPLE_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT2_CLASS, simple_class_print()));
   fail_if(!eo_class_do(INHERIT3_CLASS, simple_class_print()));

   fail_if(eo_class_do(SIMPLE_CLASS, simple_a_print()));

   eo_constructor_super(obj);
   eo_destructor_super(obj);

   eo_unref(obj);

   eo_shutdown();
   return 0;
}
Пример #3
0
int
main(int argc, char *argv[])
{
   int ret = 0;
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);

   fail_if(my_init_count != 2);

   eo_do(obj, simple_a_set(1), simple_b_set(2));

   int a, b;
   eo_do(obj, simple_a_get(&a), simple_b_get(&b),  mixin_add_and_print(5));

   eo_unref(obj);

   fail_if(my_init_count != 0);

   obj = eo_add(SIMPLE2_CLASS, NULL);
   fail_if(obj);

   obj = eo_add(SIMPLE3_CLASS, NULL);
   fail_if(obj);

   my_init_count = 0;
   obj = eo_add(SIMPLE4_CLASS, NULL);

   fail_if(my_init_count != 2);

   eo_unref(obj);

   fail_if(my_init_count != 0);

   obj = eo_add(SIMPLE5_CLASS, NULL);
   fail_if(!obj);
   eo_unref(obj);

   obj = eo_add(SIMPLE6_CLASS, NULL);
   fail_if(!obj);
   eo_unref(obj);

   obj = eo_add(SIMPLE7_CLASS, NULL);
   fail_if(obj);

   my_init_count = 0;
   obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7));
   fail_if(!obj);

   fail_if(my_init_count != 2);
   eo_do(obj, simple_a_get(&a));
   fail_if(a != 7);

   eo_unref(obj);

   eo_shutdown();
   return ret;
}
Пример #4
0
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);

   eo_do(obj, simple_a_set(1), simple_b_set(2));

   int a, b, sum = 0;
   eo_do(obj, simple_a_get(&a), simple_b_get(&b),  interface_ab_sum_get(&sum));
   fail_if(sum != a + b);

   sum = 0;
   eo_do(obj, interface_ab_sum_get(&sum), interface_ab_sum_get(&sum));
   fail_if(sum != a + b);
   eo_do(obj, interface2_ab_sum_get2(&sum), interface2_ab_sum_get2(&sum));
   fail_if(sum != a + b + 1);

   eo_unref(obj);
   eo_shutdown();
   return 0;
}
Пример #5
0
static void
bench_eo_do_general(int request)
{
   int i;
   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   for (i = 0 ; i < request ; i++)
     {
        eo_do(obj, simple_a_set(i));
     }

   eo_unref(obj);
}
Пример #6
0
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   efl_object_init();

   Eo *obj = efl_add(SIMPLE_CLASS, NULL);

   simple_a_set(obj, 1);
   simple_b_set(obj, 2);

   int a = 0, b = 0, sum = 0;
   a = simple_a_get(obj);
   b = simple_b_get(obj);
   sum = mixin_ab_sum_get(obj);
   fail_if(sum != a + b + 2); /* 2 for the two mixins... */

   sum = mixin_ab_sum_get(obj);
   sum = mixin_ab_sum_get(obj);

   Mixin2_Public_Data *pd2 = efl_data_scope_get(obj, MIXIN2_CLASS);
   fail_if(pd2->count != 6);

   Mixin3_Public_Data *pd3 = efl_data_scope_get(obj, MIXIN3_CLASS);
   fail_if(pd3->count != 9);

   efl_unref(obj);

   obj = efl_add(INHERIT_CLASS, NULL);
   simple_a_set(obj, 5);
   a = simple_a_get(obj);
   printf("%d\n", a);
   fail_if(a != 5);

   efl_unref(obj);
   efl_object_shutdown();
   return 0;
}
Пример #7
0
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(INHERIT_CLASS, NULL);

   eo_do(obj, simple_a_set(1), inherit_prot_print());

   Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
   printf("Pub: %d\n", pd->public_x2);

   eo_unref(obj);
   eo_shutdown();
   return 0;
}
Пример #8
0
END_TEST

START_TEST(eo_op_not_found_in_super)
{
   eo_init();
   eina_log_print_cb_set(eo_test_print_cb, &ctx);

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   fail_if(!obj);

   TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'.");
   eo_do_super(obj, SIMPLE_CLASS, simple_a_set(10));
   fail_unless(ctx.did);

   eo_unref(obj);
   eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
   eo_shutdown();
}
Пример #9
0
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);

   eo_do(obj, simple_a_set(4));

   int a = 0, a2 = 0, a3 = 0;

   eo_do(obj, a = simple_a_get(),
              a3 = interface_a_power_3_get(),
              a2 = mixin_a_square_get());

   printf("Got %d %d %d\n", a, a2, a3);

   eo_unref(obj);
   eo_shutdown();
   return 0;
}
Пример #10
0
#include "config.h"

#include "../eunit_tests.h"

EAPI Eobj_Op INHERIT2_BASE_ID = 0;

#define MY_CLASS INHERIT2_CLASS

static void
_a_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
{
   int a;
   a = va_arg(*list, int);
   printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
   eobj_do(obj, simple_a_print());
   eobj_do_super(obj, simple_a_set(a + 1));

   fail_if(eobj_do_super(obj, simple_a_print()));
}

static void
_print(Eobj *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
   printf("Hey\n");
   fail_if(eobj_do_super(obj, inherit2_print()));
}

static void
_print2(Eobj *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
   printf("Hey2\n");
Пример #11
0
Файл: main.c Проект: wargio/e17
int
main(int argc, char *argv[])
{
   (void) argc;
   (void) argv;
   eo_init();

   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
   Simple_Public_Data *pd = eo_data_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));
   /* 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));
   /* 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));

   eo_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));
   fail_if(pd->cb_count != 3);

   eo_do(obj, eo_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));
   fail_if(pd->cb_count != 2);
   void *ret;

   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(pd->cb_count != 1);

   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, NULL, &ret));
   fail_if(ret);
   fail_if(pd->cb_count != 1);
   eo_do(obj, eo_event_callback_del(EV_A_CHANGED, NULL, 0));
   fail_if(pd->cb_count != 1);

   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(pd->cb_count != 0);

   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(ret);
   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));
   fail_if(pd->cb_count != 1);

   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 0);

   eo_do(obj, eo_event_freeze());
   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_do(obj, eo_event_freeze());
   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 2);

   eo_do(obj, eo_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));
   fail_if(cb_count != 0);
   eo_do(obj, eo_event_thaw());
   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_do(obj, eo_event_thaw());
   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 0);

   eo_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));
   fail_if(fcount != 0);

   eo_do(obj, eo_event_freeze());
   eo_do(obj, eo_event_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_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));
   fail_if(fcount != 0);

   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(!ret);
   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(!ret);
   eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret));
   fail_if(ret);

   /* 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));
   fail_if(pd->cb_count != 1);

   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 0);

   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 2);

   eo_do(obj, eo_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));
   fail_if(cb_count != 0);
   eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 0);

   eo_do(obj, simple_a_set(3));
   fail_if(cb_count != 2);

   cb_count = 0;
   eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 0);

   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 1);

   eo_do(obj, simple_a_set(2));
   fail_if(cb_count != 0);
   eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
   eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
   fail_if(fcount != 0);


   eo_unref(obj);
   eo_shutdown();
   return 0;
}