summaryrefslogtreecommitdiff
path: root/src/tests/eo/function_overrides/function_overrides_simple.c
blob: 45d19d283876b9e85437bc729fe013c6fd4d684f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "function_overrides_simple.h"

#include "../eunit_tests.h"

#define MY_CLASS SIMPLE_CLASS

Eina_Bool class_print_called = EINA_FALSE;
Eina_Bool class_print2_called = EINA_FALSE;

static void
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
{
   Simple_Public_Data *pd = class_data;
   printf("%s %d\n", efl_class_name_get(MY_CLASS), a);
   pd->a = a;
}

static Eina_Bool
_a_print(Eo *obj EINA_UNUSED, void *class_data)
{
   Simple_Public_Data *pd = class_data;
   printf("Print %s %d\n", efl_class_name_get(MY_CLASS), pd->a);

   return EINA_TRUE;
}

static Eina_Bool
_class_print(Efl_Class *klass, void *class_data EINA_UNUSED)
{
   printf("Print %s-%s\n", efl_class_name_get(klass), efl_class_name_get(MY_CLASS));
   Eina_Bool called = EINA_FALSE;
   called = simple_class_print(efl_super(klass, MY_CLASS));
   fail_if(called);

   called = simple_class_print2(efl_super(klass, MY_CLASS));
   fail_if(called);

   return EINA_TRUE;
}

static Eina_Bool
_class_print2(Efl_Class *klass, void *class_data EINA_UNUSED)
{
   printf("Print %s-%s\n", efl_class_name_get(klass), efl_class_name_get(MY_CLASS));

   return EINA_TRUE;
}

EAPI EFL_VOID_FUNC_BODYV(simple_a_set, EFL_FUNC_CALL(a), int a);
EAPI EFL_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE);
EAPI EFL_FUNC_BODY_CONST(simple_class_print, Eina_Bool, EINA_FALSE);
EAPI EFL_FUNC_BODY_CONST(simple_class_print2, Eina_Bool, EINA_FALSE);

static Efl_Op_Description op_descs[] = {
     EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
     EFL_OBJECT_OP_FUNC(simple_a_print, _a_print),
     EFL_OBJECT_OP_FUNC(simple_class_print, _class_print),
     EFL_OBJECT_OP_FUNC(simple_class_print2, _class_print2),
};

static const Efl_Class_Description class_desc = {
     EO_VERSION,
     "Simple",
     EFL_CLASS_TYPE_REGULAR,
     EFL_CLASS_DESCRIPTION_OPS(op_descs),
     NULL,
     sizeof(Simple_Public_Data),
     NULL,
     NULL
};

EFL_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL);