Eobj: s/__UNUSED__/EINA_UNUSED/ I had no idea that exists.
[profile/ivi/eobj.git] / examples / function_overrides / simple.c
1 #include "Eobj.h"
2 #include "simple.h"
3
4 #include "config.h"
5
6 EAPI Eobj_Op SIMPLE_BASE_ID = 0;
7
8 static const Eobj_Class *_my_class = NULL;
9
10 static void
11 _a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
12 {
13    Simple_Public_Data *pd = class_data;
14    int a;
15    a = va_arg(*list, int);
16    printf("%s %d\n", eobj_class_name_get(_my_class), a);
17    pd->a = a;
18 }
19
20 static void
21 _a_print(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
22 {
23    Simple_Public_Data *pd = class_data;
24    (void) list;
25    printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
26 }
27
28 static void
29 _class_constructor(Eobj_Class *klass)
30 {
31    const Eobj_Op_Func_Description func_desc[] = {
32         EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
33         EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
34         EOBJ_OP_FUNC_SENTINEL
35    };
36
37    eobj_class_funcs_set(klass, func_desc);
38 }
39
40 const Eobj_Class *
41 simple_class_get(void)
42 {
43    if (_my_class) return _my_class;
44
45    static const Eobj_Op_Description op_desc[] = {
46         EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
47         EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "", "Print property A"),
48         EOBJ_OP_DESCRIPTION_SENTINEL
49    };
50
51    static const Eobj_Class_Description class_desc = {
52         "Simple",
53         EOBJ_CLASS_TYPE_REGULAR,
54         EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
55         NULL,
56         sizeof(Simple_Public_Data),
57         NULL,
58         NULL,
59         _class_constructor,
60         NULL
61    };
62
63    return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
64 }