Eobj: s/__UNUSED__/EINA_UNUSED/ I had no idea that exists.
[profile/ivi/eobj.git] / examples / access / inherit.c
1 #include "Eobj.h"
2 #include "simple.h"
3 #include "simple_protected.h"
4
5 #include "inherit.h"
6
7 #include "config.h"
8
9 EAPI Eobj_Op INHERIT_BASE_ID = 0;
10
11 static const Eobj_Class *_my_class = NULL;
12
13 static void
14 _prot_print(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
15 {
16    Simple_Protected_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
17    (void) list;
18    printf("%s %d\n", __func__, pd->protected_x1);
19 }
20
21 static void
22 _class_constructor(Eobj_Class *klass)
23 {
24    const Eobj_Op_Func_Description func_desc[] = {
25         EOBJ_OP_FUNC(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
26         EOBJ_OP_FUNC_SENTINEL
27    };
28
29    eobj_class_funcs_set(klass, func_desc);
30 }
31
32 const Eobj_Class *
33 inherit_class_get(void)
34 {
35    if (_my_class) return _my_class;
36
37    static const Eobj_Op_Description op_desc[] = {
38         EOBJ_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "", "Print protected var x1."),
39         EOBJ_OP_DESCRIPTION_SENTINEL
40    };
41
42    static const Eobj_Class_Description class_desc = {
43         "Inherit",
44         EOBJ_CLASS_TYPE_REGULAR,
45         EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
46         NULL,
47         0,
48         NULL,
49         NULL,
50         _class_constructor,
51         NULL
52    };
53
54    return _my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
55 }