Esempio n. 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;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
static int
_ab_sum_get(Eo *obj, void *class_data)
{
   /* This cast is a hack just for the tests... */
   Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
   int sum = 0;
   printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
   eo_do_super(obj, MY_CLASS, sum = mixin_ab_sum_get());

   ++sum;
   pd->count += 2;

     {
        int _a = 0, _b = 0;
        eo_do(obj, _a = simple_a_get(), _b = simple_b_get());
        fail_if(sum != _a + _b + 1);
     }

   return sum;
}
Esempio n. 6
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;
}
Esempio n. 7
0
{ \
   Private_Data *pd = class_data; \
   pd->name = name; \
   printf("%s %d\n", __func__, pd->name); \
} \
EO_VOID_FUNC_BODYV(simple_##name##_set, EO_FUNC_CALL(name), int name); \
EO_FUNC_BODY(simple_##name##_get, int, 0);

_GET_SET_FUNC(a)
_GET_SET_FUNC(b)

static int
_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
{
   int a = 0, b = 0;
   eo_do(obj, a = simple_a_get(), b = simple_b_get());
   printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
   return a + b;
}

static int
_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED)
{
   int a = 0, b = 0;
   eo_do(obj, a = simple_a_get(), b = simple_b_get());
   printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
   return a + b + 1;
}

static Eo_Op_Description op_descs[] = {
     EO_OP_FUNC(simple_a_set, _a_set),
Esempio n. 8
0
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "simple_mixin.h"
#include "simple_simple.h"

#define MY_CLASS MIXIN_CLASS

static int
_a_square_get(Eo *obj, void *class_data EINA_UNUSED)
{
   int a = eo_do(obj, simple_a_get());
   printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
   return a * a;
}

EAPI EO_FUNC_BODY(mixin_a_square_get, int, 0);

static Eo_Op_Description op_desc[] = {
     EO_OP_FUNC(mixin_a_square_get, _a_square_get, "Get the value of A^2"),
     EO_OP_SENTINEL
};

static const Eo_Class_Description class_desc = {
     EO_VERSION,
     "Mixin",
     EO_CLASS_TYPE_MIXIN,
     EO_CLASS_DESCRIPTION_OPS(op_desc),
     NULL,
Esempio n. 9
0
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "constructors_mixin.h"
#include "constructors_simple.h"

#define MY_CLASS MIXIN_CLASS

static void
_add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, int x)
{
   int a = 0, b = 0;
   a = simple_a_get(obj);
   b = simple_b_get(obj);
   printf("%s %d\n", __func__, a + b + x);
}

extern int my_init_count;

static Eo *
_constructor(Eo *obj, void *class_data EINA_UNUSED)
{
   my_init_count++;

   return efl_constructor(efl_super(obj, MY_CLASS));
}

static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
Esempio n. 10
0
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "mixin_simple.h"
#include "mixin_mixin4.h"
#include "mixin_inherit.h"

#define MY_CLASS INHERIT_CLASS

static int
_a_get(Eo *obj, void *class_data EINA_UNUSED)
{
   int ret = 0;
   eo_do_super(obj, MY_CLASS, ret = simple_a_get());
   printf("%s %d\n", __func__, ret);

   return ret;
}

static Eo_Op_Description op_descs[] = {
     EO_OP_FUNC_OVERRIDE(simple_a_get, _a_get),
     EO_OP_SENTINEL
};

static const Eo_Class_Description class_desc = {
     EO_VERSION,
     "Inherit",
     EO_CLASS_TYPE_REGULAR,
     EO_CLASS_DESCRIPTION_OPS(op_descs),