summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
commit3b5a3448b7dfc53c2f129bdb04bea9f7a02741a6 (patch)
tree18ad8a6b1841e9832c85a46f887b2cd6d6dacc4b /src/examples
parent195d31c73fef88cfaa803b07b2ae3cba983a4093 (diff)
merge: add eo
SVN revision: 77072
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/Makefile.am8
-rw-r--r--src/examples/eo/Makefile.am83
-rw-r--r--src/examples/eo/evas/evas_elw_box.c74
-rw-r--r--src/examples/eo/evas/evas_elw_box.h25
-rw-r--r--src/examples/eo/evas/evas_elw_boxedbutton.c57
-rw-r--r--src/examples/eo/evas/evas_elw_boxedbutton.h9
-rw-r--r--src/examples/eo/evas/evas_elw_button.c115
-rw-r--r--src/examples/eo/evas/evas_elw_button.h29
-rw-r--r--src/examples/eo/evas/evas_elw_win.c74
-rw-r--r--src/examples/eo/evas/evas_elw_win.h9
-rw-r--r--src/examples/eo/evas/evas_evas_obj.c146
-rw-r--r--src/examples/eo/evas/evas_evas_obj.h90
-rw-r--r--src/examples/eo/evas/evas_test.c68
-rw-r--r--src/examples/eo/isa/eo_isa_complex.c21
-rw-r--r--src/examples/eo/isa/eo_isa_complex.h10
-rw-r--r--src/examples/eo/isa/eo_isa_interface.c29
-rw-r--r--src/examples/eo/isa/eo_isa_interface.h26
-rw-r--r--src/examples/eo/isa/eo_isa_main.c36
-rw-r--r--src/examples/eo/isa/eo_isa_mixin.c53
-rw-r--r--src/examples/eo/isa/eo_isa_mixin.h26
-rw-r--r--src/examples/eo/isa/eo_isa_simple.c78
-rw-r--r--src/examples/eo/isa/eo_isa_simple.h35
-rw-r--r--src/examples/eo/simple/simple_interface.c29
-rw-r--r--src/examples/eo/simple/simple_interface.h26
-rw-r--r--src/examples/eo/simple/simple_main.c31
-rw-r--r--src/examples/eo/simple/simple_mixin.c53
-rw-r--r--src/examples/eo/simple/simple_mixin.h26
-rw-r--r--src/examples/eo/simple/simple_simple.c78
-rw-r--r--src/examples/eo/simple/simple_simple.h35
29 files changed, 1378 insertions, 1 deletions
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index abdebd74f9..0a874138fb 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -1,15 +1,21 @@
1MAINTAINERCLEANFILES = Makefile.in 1MAINTAINERCLEANFILES = Makefile.in
2 2
3SUBDIRS = eina eet 3SUBDIRS = eina eet eo
4 4
5examples: 5examples:
6 @$(MAKE) $(AM_MAKEFLAGS) -C eina examples 6 @$(MAKE) $(AM_MAKEFLAGS) -C eina examples
7if EFL_BUILD_EET 7if EFL_BUILD_EET
8 @$(MAKE) $(AM_MAKEFLAGS) -C eet examples 8 @$(MAKE) $(AM_MAKEFLAGS) -C eet examples
9endif 9endif
10if EFL_BUILD_EO
11 @$(MAKE) $(AM_MAKEFLAGS) -C eo examples
12endif
10 13
11install-examples: 14install-examples:
12 @$(MAKE) $(AM_MAKEFLAGS) -C eina install-examples 15 @$(MAKE) $(AM_MAKEFLAGS) -C eina install-examples
13if EFL_BUILD_EET 16if EFL_BUILD_EET
14 @$(MAKE) $(AM_MAKEFLAGS) -C eet install-examples 17 @$(MAKE) $(AM_MAKEFLAGS) -C eet install-examples
15endif 18endif
19if EFL_BUILD_EO
20 @$(MAKE) $(AM_MAKEFLAGS) -C eo install-examples
21endif
diff --git a/src/examples/eo/Makefile.am b/src/examples/eo/Makefile.am
new file mode 100644
index 0000000000..d7719be5b8
--- /dev/null
+++ b/src/examples/eo/Makefile.am
@@ -0,0 +1,83 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I. \
5-I$(top_srcdir)/src/lib/eo \
6-I$(top_builddir)/src/lib/eo \
7@EFL_EO_BUILD@ \
8@EO_CFLAGS@
9
10EXTRA_PROGRAMS = eo_isa eo_simple
11
12if EO_BUILD_EXAMPLE_EVAS
13
14EXTRA_PROGRAMS += eo_evas
15
16endif
17
18eo_isa_SOURCES = \
19isa/eo_isa_complex.c \
20isa/eo_isa_complex.h \
21isa/eo_isa_interface.c \
22isa/eo_isa_interface.h \
23isa/eo_isa_main.c \
24isa/eo_isa_mixin.c \
25isa/eo_isa_mixin.h \
26isa/eo_isa_simple.c \
27isa/eo_isa_simple.h
28
29eo_isa_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
30
31if EO_BUILD_EXAMPLE_EVAS
32
33eo_evas_SOURCES = \
34evas/evas_elw_box.c \
35evas/evas_elw_box.h \
36evas/evas_elw_boxedbutton.c \
37evas/evas_elw_boxedbutton.h \
38evas/evas_elw_button.c \
39evas/evas_elw_button.h \
40evas/evas_elw_win.h \
41evas/evas_elw_win.c \
42evas/evas_evas_obj.c \
43evas/evas_evas_obj.h \
44evas/evas_test.c
45
46eo_evas_LDADD = $(top_builddir)/src/lib/eo/libeo.la @ELM_LIBS@ @EO_LIBS@
47
48endif
49
50eo_simple_SOURCES = \
51simple/simple_interface.c \
52simple/simple_interface.h \
53simple/simple_main.c \
54simple/simple_mixin.c \
55simple/simple_mixin.h \
56simple/simple_simple.c \
57simple/simple_simple.h
58
59eo_simple_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
60
61examples: $(EXTRA_PROGRAMS)
62
63clean-local:
64 rm -f $(EXTRA_PROGRAMS)
65
66install-examples:
67 mkdir -p $(pkgdatadir)/examples/eo/isa
68 $(install_sh_DATA) -c $(eo_isa_SOURCES) $(pkgdatadir)/examples/eo/isa
69 mkdir -p $(pkgdatadir)/examples/eo/evas
70 $(install_sh_DATA) -c $(evas_SOURCES) $(pkgdatadir)/examples/eo/evas
71 mkdir -p $(pkgdatadir)/examples/eo/simple
72 $(install_sh_DATA) -c $(simple_SOURCES) $(pkgdatadir)/examples/eo/simple
73
74uninstall-local:
75 for f in $(eo_isa_SOURCES) ; do \
76 rm -f $(pkgdatadir)/examples/eo/isa/$$f ; \
77 done
78 for f in $(evas_SOURCES) ; do \
79 rm -f $(pkgdatadir)/examples/eo/evas/$$f ; \
80 done
81 for f in $(simple_SOURCES) ; do \
82 rm -f $(pkgdatadir)/examples/eo/simple/$$f ; \
83 done
diff --git a/src/examples/eo/evas/evas_elw_box.c b/src/examples/eo/evas/evas_elw_box.c
new file mode 100644
index 0000000000..1a2330f845
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_box.c
@@ -0,0 +1,74 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "Eo.h"
8#include "evas_obj.h"
9#include "elw_box.h"
10
11EAPI Eo_Op ELW_BOX_BASE_ID = 0;
12
13typedef struct
14{
15 Evas_Object *bx;
16} Widget_Data;
17
18#define MY_CLASS ELW_BOX_CLASS
19
20static void
21_pack_end(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
22{
23 Widget_Data *wd = class_data;
24 Eo *child_obj;
25 child_obj = va_arg(*list, Eo *);
26 /* FIXME: Ref and the later uref child_obj here... */
27 elm_box_pack_end(wd->bx, eo_evas_object_get(child_obj));
28}
29
30static void
31_constructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED)
32{
33 eo_do_super(obj, eo_constructor());
34
35 Widget_Data *wd = class_data;
36
37 /* FIXME: An hack, because our tree is not yet only Eo */
38 wd->bx = elm_box_add(eo_evas_object_get(eo_parent_get(obj)));
39 evas_object_size_hint_align_set(wd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
40 evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
41
42 eo_evas_object_set(obj, wd->bx);
43}
44
45static void
46_class_constructor(Eo_Class *klass)
47{
48 const Eo_Op_Func_Description func_desc[] = {
49 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
50 EO_OP_FUNC(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
51 EO_OP_FUNC_SENTINEL
52 };
53
54 eo_class_funcs_set(klass, func_desc);
55}
56
57static const Eo_Op_Description op_desc[] = {
58 EO_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "Pack obj at the end of box."),
59 EO_OP_DESCRIPTION_SENTINEL
60};
61
62static const Eo_Class_Description class_desc = {
63 EO_VERSION,
64 "Elw Box",
65 EO_CLASS_TYPE_REGULAR,
66 EO_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
67 NULL,
68 sizeof(Widget_Data),
69 _class_constructor,
70 NULL
71};
72
73EO_DEFINE_CLASS(elw_box_class_get, &class_desc, EXEVAS_OBJ_CLASS, NULL)
74
diff --git a/src/examples/eo/evas/evas_elw_box.h b/src/examples/eo/evas/evas_elw_box.h
new file mode 100644
index 0000000000..c25382cf34
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_box.h
@@ -0,0 +1,25 @@
1#ifndef ELW_BOX_H
2#define ELW_BOX_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op ELW_BOX_BASE_ID;
7
8enum {
9 ELW_BOX_SUB_ID_PACK_END,
10 ELW_BOX_SUB_ID_LAST
11};
12
13#define ELW_BOX_ID(sub_id) (ELW_BOX_BASE_ID + sub_id)
14
15/**
16 * @def elw_box_pack_end(obj)
17 * @brief Pack object to the end of the box
18 * @param[in] obj object to pack into box
19 */
20#define elw_box_pack_end(obj) ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), EO_TYPECHECK(Eo *, obj)
21
22#define ELW_BOX_CLASS elw_box_class_get()
23const Eo_Class *elw_box_class_get(void);
24
25#endif
diff --git a/src/examples/eo/evas/evas_elw_boxedbutton.c b/src/examples/eo/evas/evas_elw_boxedbutton.c
new file mode 100644
index 0000000000..457dba892a
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_boxedbutton.c
@@ -0,0 +1,57 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "Eo.h"
8#include "evas_obj.h"
9#include "elw_box.h"
10#include "elw_button.h"
11#include "elw_boxedbutton.h"
12
13typedef struct
14{
15// Evas_Object *bx;
16} Widget_Data;
17
18#define MY_CLASS ELW_BOXEDBUTTON_CLASS
19
20static void
21_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
22{
23 eo_do_super(obj, eo_constructor());
24
25 Eo *bt = eo_add(ELW_BUTTON_CLASS, obj);
26 eo_composite_attach(bt, obj);
27 eo_do(bt, eo_event_callback_forwarder_add(EV_CLICKED, obj));
28 eo_do(bt, exevas_obj_visibility_set(EINA_TRUE));
29
30 eo_do(obj, elw_box_pack_end(bt));
31 eo_unref(bt);
32}
33
34static void
35_class_constructor(Eo_Class *klass)
36{
37 const Eo_Op_Func_Description func_desc[] = {
38 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
39 EO_OP_FUNC_SENTINEL
40 };
41
42 eo_class_funcs_set(klass, func_desc);
43}
44
45static const Eo_Class_Description class_desc = {
46 EO_VERSION,
47 "Elw BoxedButton",
48 EO_CLASS_TYPE_REGULAR,
49 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
50 NULL,
51 sizeof(Widget_Data),
52 _class_constructor,
53 NULL
54};
55
56EO_DEFINE_CLASS(elw_boxedbutton_class_get, &class_desc, ELW_BOX_CLASS, ELW_BUTTON_CLASS, NULL)
57
diff --git a/src/examples/eo/evas/evas_elw_boxedbutton.h b/src/examples/eo/evas/evas_elw_boxedbutton.h
new file mode 100644
index 0000000000..e4ecfd2f83
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_boxedbutton.h
@@ -0,0 +1,9 @@
1#ifndef ELW_BOXEDBUTTON_H
2#define ELW_BOXEDBUTTON_H
3
4#include "Eo.h"
5
6#define ELW_BOXEDBUTTON_CLASS elw_boxedbutton_class_get()
7const Eo_Class *elw_boxedbutton_class_get(void);
8
9#endif
diff --git a/src/examples/eo/evas/evas_elw_button.c b/src/examples/eo/evas/evas_elw_button.c
new file mode 100644
index 0000000000..82fa39b354
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_button.c
@@ -0,0 +1,115 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "Eo.h"
8#include "evas_obj.h"
9#include "elw_button.h"
10
11EAPI Eo_Op ELW_BUTTON_BASE_ID = 0;
12
13EAPI const Eo_Event_Description _EV_CLICKED =
14 EO_EVENT_DESCRIPTION("clicked", "Called when there was a click.");
15
16typedef struct
17{
18 Evas_Object *bt;
19} Widget_Data;
20
21#define MY_CLASS ELW_BUTTON_CLASS
22
23static void
24_position_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
25{
26 (void) obj;
27 Evas_Coord x, y;
28 x = va_arg(*list, Evas_Coord);
29 y = va_arg(*list, Evas_Coord);
30 printf("But set position %d,%d\n", x, y);
31 eo_do_super(obj, exevas_obj_position_set(x, y));
32}
33
34static void
35_text_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
36{
37 Widget_Data *wd = class_data;
38 const char *text;
39 text = va_arg(*list, const char *);
40 elm_object_text_set(wd->bt, text);
41}
42
43static void
44_btn_clicked(void *data, Evas_Object *evas_obj, void *event_info)
45{
46 (void) evas_obj;
47 (void) event_info;
48 Eo *obj = data;
49 eo_do(obj, eo_event_callback_call(EV_CLICKED, NULL, NULL));
50}
51
52static void
53_constructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED)
54{
55 eo_do_super(obj, eo_constructor());
56
57 Widget_Data *wd = class_data;
58
59 /* FIXME: An hack, because our tree is not yet only Eo */
60 wd->bt = elm_button_add(eo_evas_object_get(eo_parent_get(obj)));
61 evas_object_size_hint_align_set(wd->bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
62 evas_object_size_hint_weight_set(wd->bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63 evas_object_smart_callback_add(wd->bt, "clicked", _btn_clicked, obj);
64
65 eo_evas_object_set(obj, wd->bt);
66}
67
68static void
69_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
70{
71 eo_do_super(obj, eo_destructor());
72
73 //Widget_Data *wd = class_data;
74 /* FIXME: Commented out because it's automatically done because our tree
75 * is not made of only eo */
76 //evas_object_del(wd->bt);
77}
78
79static void
80_class_constructor(Eo_Class *klass)
81{
82 const Eo_Op_Func_Description func_desc[] = {
83 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
84 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
85 EO_OP_FUNC(ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), _text_set),
86 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
87 EO_OP_FUNC_SENTINEL
88 };
89
90 eo_class_funcs_set(klass, func_desc);
91}
92
93static const Eo_Op_Description op_desc[] = {
94 EO_OP_DESCRIPTION(ELW_BUTTON_SUB_ID_TEXT_SET, "Text of a text supporting evas object."), // FIXME: This ID sholudn't really be defined here...
95 EO_OP_DESCRIPTION_SENTINEL
96};
97
98static const Eo_Event_Description *event_desc[] = {
99 EV_CLICKED,
100 NULL
101};
102
103static const Eo_Class_Description class_desc = {
104 EO_VERSION,
105 "Elw Button",
106 EO_CLASS_TYPE_REGULAR,
107 EO_CLASS_DESCRIPTION_OPS(&ELW_BUTTON_BASE_ID, op_desc, ELW_BUTTON_SUB_ID_LAST),
108 event_desc,
109 sizeof(Widget_Data),
110 _class_constructor,
111 NULL
112};
113
114EO_DEFINE_CLASS(elw_button_class_get, &class_desc, EXEVAS_OBJ_CLASS, NULL)
115
diff --git a/src/examples/eo/evas/evas_elw_button.h b/src/examples/eo/evas/evas_elw_button.h
new file mode 100644
index 0000000000..8cecb8104e
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_button.h
@@ -0,0 +1,29 @@
1#ifndef ELW_BUTTON_H
2#define ELW_BUTTON_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op ELW_BUTTON_BASE_ID;
7
8enum {
9 ELW_BUTTON_SUB_ID_TEXT_SET,
10 ELW_BUTTON_SUB_ID_LAST
11};
12
13#define ELW_BUTTON_ID(sub_id) (ELW_BUTTON_BASE_ID + sub_id)
14
15/**
16 * @def elw_button_text_set(text)
17 * @brief Set button text
18 * @param[in] text text to assing to button
19 * FIXME Doesn't belong here, but just for the example...
20 */
21#define elw_button_text_set(text) ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), EO_TYPECHECK(const char *, text)
22
23extern const Eo_Event_Description _EV_CLICKED;
24#define EV_CLICKED (&(_EV_CLICKED))
25
26#define ELW_BUTTON_CLASS elw_button_class_get()
27const Eo_Class *elw_button_class_get(void);
28
29#endif
diff --git a/src/examples/eo/evas/evas_elw_win.c b/src/examples/eo/evas/evas_elw_win.c
new file mode 100644
index 0000000000..dd9e1002f5
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_win.c
@@ -0,0 +1,74 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "Eo.h"
8#include "evas_obj.h"
9#include "elw_win.h"
10
11typedef struct
12{
13 Evas_Object *win;
14 Evas_Object *bg;
15} Widget_Data;
16
17#define MY_CLASS ELW_WIN_CLASS
18
19static void
20my_win_del(void *data, Evas_Object *obj, void *event_info)
21{
22 /* called when my_win_main is requested to be deleted */
23 elm_exit(); /* exit the program's main loop that runs in elm_run() */
24 (void) data;
25 (void) obj;
26 (void) event_info;
27}
28
29static void
30_constructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED)
31{
32 eo_do_super(obj, eo_constructor());
33
34 Widget_Data *wd = class_data;
35
36 /* FIXME: Will actually do something about those when I care... */
37 wd->win = elm_win_add(NULL, "eo-test", ELM_WIN_BASIC);
38 elm_win_title_set(wd->win, "Eo Test");
39 elm_win_autodel_set(wd->win, EINA_TRUE);
40 evas_object_smart_callback_add(wd->win, "delete,request", my_win_del, NULL);
41
42 wd->bg = elm_bg_add(wd->win);
43 elm_win_resize_object_add(wd->win, wd->bg);
44 evas_object_size_hint_weight_set(wd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
45 evas_object_show(wd->bg);
46
47 eo_evas_object_set(obj, wd->win);
48}
49
50static void
51_class_constructor(Eo_Class *klass)
52{
53 const Eo_Op_Func_Description func_desc[] = {
54 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
55 EO_OP_FUNC_SENTINEL
56 };
57
58 eo_class_funcs_set(klass, func_desc);
59}
60
61static const Eo_Class_Description class_desc = {
62 EO_VERSION,
63 "Elw Win",
64 EO_CLASS_TYPE_REGULAR,
65 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
66 NULL,
67 sizeof(Widget_Data),
68 _class_constructor,
69 NULL
70};
71
72
73EO_DEFINE_CLASS(elw_win_class_get, &class_desc, EXEVAS_OBJ_CLASS, NULL)
74
diff --git a/src/examples/eo/evas/evas_elw_win.h b/src/examples/eo/evas/evas_elw_win.h
new file mode 100644
index 0000000000..babb28b11a
--- /dev/null
+++ b/src/examples/eo/evas/evas_elw_win.h
@@ -0,0 +1,9 @@
1#ifndef ELW_WIN_H
2#define ELW_WIN_H
3
4#include "Eo.h"
5
6#define ELW_WIN_CLASS elw_win_class_get()
7const Eo_Class *elw_win_class_get(void);
8
9#endif
diff --git a/src/examples/eo/evas/evas_evas_obj.c b/src/examples/eo/evas/evas_evas_obj.c
new file mode 100644
index 0000000000..9d13c66813
--- /dev/null
+++ b/src/examples/eo/evas/evas_evas_obj.c
@@ -0,0 +1,146 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "Eo.h"
8#include "evas_obj.h"
9
10#define MY_CLASS EXEVAS_OBJ_CLASS
11
12EAPI Eo_Op EXEVAS_OBJ_BASE_ID = 0;
13
14typedef struct
15{
16 Eina_List *children;
17} Widget_Data;
18
19static void
20_position_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
21{
22 Evas_Object *evas_obj = eo_evas_object_get(obj);
23 Evas_Coord x, y;
24 x = va_arg(*list, Evas_Coord);
25 y = va_arg(*list, Evas_Coord);
26 evas_object_move(evas_obj, x, y);
27}
28
29static void
30_size_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
31{
32 Evas_Object *evas_obj = eo_evas_object_get(obj);
33 Evas_Coord w, h;
34 w = va_arg(*list, Evas_Coord);
35 h = va_arg(*list, Evas_Coord);
36 evas_object_resize(evas_obj, w, h);
37}
38
39static void
40_color_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
41{
42 Evas_Object *evas_obj = eo_evas_object_get(obj);
43 int r, g, b, a;
44 r = va_arg(*list, int);
45 g = va_arg(*list, int);
46 b = va_arg(*list, int);
47 a = va_arg(*list, int);
48 evas_object_color_set(evas_obj, r, g, b, a);
49}
50
51static void
52_color_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
53{
54 Evas_Object *evas_obj = eo_evas_object_get(obj);
55 int *r, *g, *b, *a;
56 r = va_arg(*list, int *);
57 g = va_arg(*list, int *);
58 b = va_arg(*list, int *);
59 a = va_arg(*list, int *);
60 evas_object_color_get(evas_obj, r, g, b, a);
61}
62
63static void
64_visibility_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
65{
66 Evas_Object *evas_obj = eo_evas_object_get(obj);
67 Eina_Bool v;
68 v = va_arg(*list, int);
69 if (v) evas_object_show(evas_obj);
70 else evas_object_hide(evas_obj);
71}
72
73static void
74_child_add(Eo *obj, void *class_data, va_list *list)
75{
76 Widget_Data *wd = class_data;
77 Eo *child;
78 child = va_arg(*list, Eo *);
79 wd->children = eina_list_append(wd->children, eo_xref(child, obj));
80}
81
82static void
83_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
84{
85 eo_do_super(obj, eo_constructor());
86
87 /* Add type check. */
88 Eo *parent = eo_parent_get(obj);
89 if (parent)
90 eo_do(parent, exevas_obj_child_add(obj));
91}
92
93static void
94_destructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED)
95{
96 eo_do_super(obj, eo_destructor());
97
98 Widget_Data *wd = class_data;
99
100 Eo *child;
101 EINA_LIST_FREE(wd->children, child)
102 {
103 eo_xunref(child, obj);
104 }
105}
106
107static void
108_class_constructor(Eo_Class *klass)
109{
110 const Eo_Op_Func_Description func_desc[] = {
111 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
112 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
113 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
114 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_SIZE_SET), _size_set),
115 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_COLOR_SET), _color_set),
116 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_COLOR_GET), _color_get),
117 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_VISIBILITY_SET), _visibility_set),
118 EO_OP_FUNC(EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_CHILD_ADD), _child_add),
119 EO_OP_FUNC_SENTINEL
120 };
121
122 eo_class_funcs_set(klass, func_desc);
123}
124
125static const Eo_Op_Description op_desc[] = {
126 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_POSITION_SET, "Position of an evas object."),
127 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_SIZE_SET, "Size of an evas object."),
128 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_COLOR_SET, "Color of an evas object."),
129 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_COLOR_GET, "Color of an evas object."),
130 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_VISIBILITY_SET, "Visibility of an evas object."),
131 EO_OP_DESCRIPTION(EXEVAS_OBJ_SUB_ID_CHILD_ADD, "Add a child eo."),
132 EO_OP_DESCRIPTION_SENTINEL
133};
134
135static const Eo_Class_Description class_desc = {
136 EO_VERSION,
137 "Evas Object",
138 EO_CLASS_TYPE_REGULAR_NO_INSTANT,
139 EO_CLASS_DESCRIPTION_OPS(&EXEVAS_OBJ_BASE_ID, op_desc, EXEVAS_OBJ_SUB_ID_LAST),
140 NULL,
141 sizeof(Widget_Data),
142 _class_constructor,
143 NULL
144};
145
146EO_DEFINE_CLASS(evas_object_class_get, &class_desc, EO_BASE_CLASS, NULL)
diff --git a/src/examples/eo/evas/evas_evas_obj.h b/src/examples/eo/evas/evas_evas_obj.h
new file mode 100644
index 0000000000..7aa761c648
--- /dev/null
+++ b/src/examples/eo/evas/evas_evas_obj.h
@@ -0,0 +1,90 @@
1#ifndef EXEVAS_OBJ_H
2#define EXEVAS_OBJ_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op EXEVAS_OBJ_BASE_ID;
7
8enum {
9 EXEVAS_OBJ_SUB_ID_POSITION_SET,
10 EXEVAS_OBJ_SUB_ID_SIZE_SET,
11 EXEVAS_OBJ_SUB_ID_COLOR_SET,
12 EXEVAS_OBJ_SUB_ID_COLOR_GET,
13 EXEVAS_OBJ_SUB_ID_VISIBILITY_SET,
14 EXEVAS_OBJ_SUB_ID_CHILD_ADD,
15 EXEVAS_OBJ_SUB_ID_LAST
16};
17
18#define EXEVAS_OBJ_ID(sub_id) (EXEVAS_OBJ_BASE_ID + sub_id)
19
20/**
21 * @def exevas_obj_position_set(x, y)
22 * @brief Set object's position
23 * @param[in] x object's X position
24 * @param[in] y object's Y position
25 */
26#define exevas_obj_position_set(x, y) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_POSITION_SET), EO_TYPECHECK(Evas_Coord, x), EO_TYPECHECK(Evas_Coord, y)
27
28/**
29 * @def exevas_obj_size_set(w, h)
30 * @brief Set object's size
31 * @param[in] w object's width
32 * @param[in] h object's height
33 */
34#define exevas_obj_size_set(w, h) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_SIZE_SET), EO_TYPECHECK(Evas_Coord, w), EO_TYPECHECK(Evas_Coord, h)
35
36/**
37 * @def exevas_obj_color_set(r, g, b, a)
38 * @brief Set object's color
39 * @param[in] r r-value of color
40 * @param[in] g g-value of color
41 * @param[in] b b-value of color
42 * @param[in] a a-value of color
43 */
44#define exevas_obj_color_set(r, g, b, a) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_COLOR_SET), EO_TYPECHECK(int, r), EO_TYPECHECK(int, g), EO_TYPECHECK(int, b), EO_TYPECHECK(int, a)
45
46/**
47 * @def exevas_obj_color_get(r, g, b, a)
48 * @brief Set object's position
49 * @param[out] r integer pointer for r-value of color
50 * @param[out] g integer pointer for g-value of color
51 * @param[out] b integer pointer for b-value of color
52 * @param[out] a integer pointer for a-value of color
53 */
54#define exevas_obj_color_get(r, g, b, a) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_COLOR_GET), EO_TYPECHECK(int *, r), EO_TYPECHECK(int *, g), EO_TYPECHECK(int *, b), EO_TYPECHECK(int *, a)
55
56/**
57 * @def exevas_obj_visibility_set(v)
58 * @brief Set object's visible property
59 * @param[in] v True/False value
60 */
61#define exevas_obj_visibility_set(v) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_VISIBILITY_SET), EO_TYPECHECK(Eina_Bool, v)
62
63/**
64 * @def exevas_obj_child_add(child)
65 * @brief Add child to current object
66 * @param[in] pointer to child object
67 */
68#define exevas_obj_child_add(child) EXEVAS_OBJ_ID(EXEVAS_OBJ_SUB_ID_CHILD_ADD), EO_TYPECHECK(Eo *, child)
69
70#define EXEVAS_OBJ_CLASS evas_object_class_get()
71const Eo_Class *evas_object_class_get(void);
72
73#define EXEVAS_OBJ_STR "Evas_Obj"
74/* FIXME: Hack in the meanwhile. */
75static inline Evas_Object *
76eo_evas_object_get(const Eo *obj)
77{
78 void *data;
79 eo_do((Eo *) obj, eo_base_data_get(EXEVAS_OBJ_STR, &data));
80 return data;
81}
82
83/* FIXME: Hack in the meanwhile. */
84static inline void
85eo_evas_object_set(Eo *obj, Evas_Object *evas_obj)
86{
87 eo_do(obj, eo_base_data_set(EXEVAS_OBJ_STR, evas_obj, NULL));
88}
89
90#endif
diff --git a/src/examples/eo/evas/evas_test.c b/src/examples/eo/evas/evas_test.c
new file mode 100644
index 0000000000..7a5751367b
--- /dev/null
+++ b/src/examples/eo/evas/evas_test.c
@@ -0,0 +1,68 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Elementary.h>
6
7#include "evas_obj.h"
8#include "elw_button.h"
9#include "elw_box.h"
10#include "elw_boxedbutton.h"
11#include "elw_win.h"
12
13Eina_Bool
14_btn_clicked_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
15{
16 (void) obj;
17 (void) event_info;
18 const Eo_Class *klass = eo_class_get(obj);
19 printf("%s obj-type:'%s' data:'%s'\n", desc->name, eo_class_name_get(klass), (const char *) data);
20
21 return EO_CALLBACK_CONTINUE;
22}
23
24int
25main(int argc, char *argv[])
26{
27 Evas_Coord winw, winh;
28 {
29 winw = 400;
30 winh = 400;
31 }
32
33 elm_init(argc, argv);
34 eo_init();
35
36 Eo *win = eo_add(ELW_WIN_CLASS, NULL);
37 eo_do(win, exevas_obj_size_set(winw, winh), exevas_obj_visibility_set(EINA_TRUE));
38
39 Eo *bt = eo_add(ELW_BUTTON_CLASS, win);
40 eo_do(bt, exevas_obj_position_set(25, 25),
41 exevas_obj_size_set(50, 50),
42 exevas_obj_color_set(255, 0, 0, 255),
43 elw_button_text_set("Click"),
44 exevas_obj_visibility_set(EINA_TRUE));
45 eo_do(bt, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "btn"));
46
47 int r, g, b, a;
48 eo_do(bt, exevas_obj_color_get(&r, &g, &b, &a));
49 printf("RGBa(%d, %d, %d, %d)\n", r, g, b, a);
50
51 Eo *bx = eo_add(ELW_BOXEDBUTTON_CLASS, win);
52 eo_do(bx, exevas_obj_position_set(100, 100),
53 exevas_obj_size_set(70, 70),
54 exevas_obj_color_set(0, 0, 255, 255),
55 elw_button_text_set("Click2"),
56 exevas_obj_visibility_set(EINA_TRUE));
57 eo_do(bx, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "bxedbtn"));
58
59 elm_run();
60
61 eo_unref(bx);
62 eo_unref(bt);
63 eo_unref(win);
64 eo_shutdown();
65 elm_shutdown();
66 return 0;
67}
68
diff --git a/src/examples/eo/isa/eo_isa_complex.c b/src/examples/eo/isa/eo_isa_complex.c
new file mode 100644
index 0000000000..4e4ff3e2c9
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_complex.c
@@ -0,0 +1,21 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_isa_complex.h"
7
8#define MY_CLASS COMPLEX_CLASS
9
10static const Eo_Class_Description class_desc = {
11 EO_VERSION,
12 "Complex",
13 EO_CLASS_TYPE_REGULAR,
14 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
15 NULL,
16 0,
17 NULL,
18 NULL
19};
20
21EO_DEFINE_CLASS(complex_class_get, &class_desc, SIMPLE_CLASS, NULL);
diff --git a/src/examples/eo/isa/eo_isa_complex.h b/src/examples/eo/isa/eo_isa_complex.h
new file mode 100644
index 0000000000..035eca0741
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_complex.h
@@ -0,0 +1,10 @@
1#ifndef COMPLEX_H
2#define COMPLEX_H
3
4#include "Eo.h"
5#include "eo_isa_simple.h"
6
7#define COMPLEX_CLASS complex_class_get()
8const Eo_Class *complex_class_get(void);
9
10#endif
diff --git a/src/examples/eo/isa/eo_isa_interface.c b/src/examples/eo/isa/eo_isa_interface.c
new file mode 100644
index 0000000000..8009012e21
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_interface.c
@@ -0,0 +1,29 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_isa_interface.h"
7
8EAPI Eo_Op INTERFACE_BASE_ID = 0;
9
10#define MY_CLASS INTERFACE_CLASS
11
12static const Eo_Op_Description op_desc[] = {
13 EO_OP_DESCRIPTION(INTERFACE_SUB_ID_A_POWER_3_GET, "Get the a^3"),
14 EO_OP_DESCRIPTION_SENTINEL
15};
16
17static const Eo_Class_Description class_desc = {
18 EO_VERSION,
19 "Interface",
20 EO_CLASS_TYPE_INTERFACE,
21 EO_CLASS_DESCRIPTION_OPS(&INTERFACE_BASE_ID, op_desc, INTERFACE_SUB_ID_LAST),
22 NULL,
23 0,
24 NULL,
25 NULL
26};
27
28EO_DEFINE_CLASS(interface_class_get, &class_desc, NULL, NULL)
29
diff --git a/src/examples/eo/isa/eo_isa_interface.h b/src/examples/eo/isa/eo_isa_interface.h
new file mode 100644
index 0000000000..c5bf43e135
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_interface.h
@@ -0,0 +1,26 @@
1#ifndef INTERFACE_H
2#define INTERFACE_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op INTERFACE_BASE_ID;
7
8enum {
9 INTERFACE_SUB_ID_A_POWER_3_GET,
10 INTERFACE_SUB_ID_LAST
11};
12
13#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id)
14
15
16/**
17 * @def interface_a_power_3_get(ret)
18 * @brief Get a^3
19 * @param[out] ret integer pointer to ret - value
20 */
21#define interface_a_power_3_get(ret) INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), EO_TYPECHECK(int *, ret)
22
23#define INTERFACE_CLASS interface_class_get()
24const Eo_Class *interface_class_get(void);
25
26#endif
diff --git a/src/examples/eo/isa/eo_isa_main.c b/src/examples/eo/isa/eo_isa_main.c
new file mode 100644
index 0000000000..567ef32542
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_main.c
@@ -0,0 +1,36 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_isa_simple.h"
7#include "eo_isa_complex.h"
8
9int
10main(int argc, char *argv[])
11{
12 (void) argc;
13 (void) argv;
14 eo_init();
15
16 Eo *simpleobj = eo_add(SIMPLE_CLASS, NULL);
17 Eo *complexobj = eo_add(COMPLEX_CLASS, NULL);
18
19 printf("Simple: isa-simple:%d isa-complex:%d isa-mixin:%d isa-interface:%d\n",
20 eo_isa(simpleobj, SIMPLE_CLASS),
21 eo_isa(simpleobj, COMPLEX_CLASS),
22 eo_isa(simpleobj, MIXIN_CLASS),
23 eo_isa(simpleobj, INTERFACE_CLASS));
24 printf("Complex: isa-simple:%d isa-complex:%d isa-mixin:%d isa-interface:%d\n",
25 eo_isa(complexobj, SIMPLE_CLASS),
26 eo_isa(complexobj, COMPLEX_CLASS),
27 eo_isa(complexobj, MIXIN_CLASS),
28 eo_isa(complexobj, INTERFACE_CLASS));
29
30 eo_unref(simpleobj);
31 eo_unref(complexobj);
32
33 eo_shutdown();
34 return 0;
35}
36
diff --git a/src/examples/eo/isa/eo_isa_mixin.c b/src/examples/eo/isa/eo_isa_mixin.c
new file mode 100644
index 0000000000..71f1d859cc
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_mixin.c
@@ -0,0 +1,53 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_isa_mixin.h"
7#include "eo_isa_simple.h"
8
9EAPI Eo_Op MIXIN_BASE_ID = 0;
10
11#define MY_CLASS MIXIN_CLASS
12
13static void
14_a_square_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
15{
16 int a;
17 eo_do(obj, simple_a_get(&a));
18 int *ret = va_arg(*list, int *);
19 if (ret)
20 *ret = a * a;
21 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
22}
23
24static void
25_class_constructor(Eo_Class *klass)
26{
27 const Eo_Op_Func_Description func_desc[] = {
28 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), _a_square_get),
29 EO_OP_FUNC_SENTINEL
30 };
31
32 eo_class_funcs_set(klass, func_desc);
33}
34
35
36static const Eo_Op_Description op_desc[] = {
37 EO_OP_DESCRIPTION(MIXIN_SUB_ID_A_SQUARE_GET, "Get the value of A^2"),
38 EO_OP_DESCRIPTION_SENTINEL
39};
40
41static const Eo_Class_Description class_desc = {
42 EO_VERSION,
43 "Mixin",
44 EO_CLASS_TYPE_MIXIN,
45 EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
46 NULL,
47 0,
48 _class_constructor,
49 NULL
50};
51
52EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
53
diff --git a/src/examples/eo/isa/eo_isa_mixin.h b/src/examples/eo/isa/eo_isa_mixin.h
new file mode 100644
index 0000000000..539504d3ad
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_mixin.h
@@ -0,0 +1,26 @@
1#ifndef MIXIN_H
2#define MIXIN_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op MIXIN_BASE_ID;
7
8enum {
9 MIXIN_SUB_ID_A_SQUARE_GET,
10 MIXIN_SUB_ID_LAST
11};
12
13#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
14
15
16/**
17 * @def mixin_a_square_get(ret)
18 * @brief Get the square of a.
19 * @param[out] ret the square of a
20 */
21#define mixin_a_square_get(ret) MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), EO_TYPECHECK(int *, ret)
22
23#define MIXIN_CLASS mixin_class_get()
24const Eo_Class *mixin_class_get(void);
25
26#endif
diff --git a/src/examples/eo/isa/eo_isa_simple.c b/src/examples/eo/isa/eo_isa_simple.c
new file mode 100644
index 0000000000..789c5f4711
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_simple.c
@@ -0,0 +1,78 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_isa_simple.h"
7
8EAPI Eo_Op SIMPLE_BASE_ID = 0;
9
10typedef struct
11{
12 int a;
13} Private_Data;
14
15#define MY_CLASS SIMPLE_CLASS
16
17static void
18_a_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
19{
20 const Private_Data *pd = class_data;
21 int *a;
22 a = va_arg(*list, int *);
23 *a = pd->a;
24 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
25}
26
27static void
28_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
29{
30 Private_Data *pd = class_data;
31 int a;
32 a = va_arg(*list, int);
33 pd->a = a;
34 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
35}
36
37static void
38_a_power_3_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
39{
40 const Private_Data *pd = class_data;
41 int *ret;
42 ret = va_arg(*list, int *);
43 if (ret)
44 *ret = pd->a * pd->a * pd->a;
45 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
46}
47
48static void
49_class_constructor(Eo_Class *klass)
50{
51 const Eo_Op_Func_Description func_desc[] = {
52 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
53 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
54 EO_OP_FUNC(INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), _a_power_3_get),
55 EO_OP_FUNC_SENTINEL
56 };
57
58 eo_class_funcs_set(klass, func_desc);
59}
60
61static const Eo_Op_Description op_desc[] = {
62 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
63 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
64 EO_OP_DESCRIPTION_SENTINEL
65};
66
67static const Eo_Class_Description class_desc = {
68 EO_VERSION,
69 "Simple",
70 EO_CLASS_TYPE_REGULAR,
71 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
72 NULL,
73 sizeof(Private_Data),
74 _class_constructor,
75 NULL
76};
77
78EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL);
diff --git a/src/examples/eo/isa/eo_isa_simple.h b/src/examples/eo/isa/eo_isa_simple.h
new file mode 100644
index 0000000000..eead797238
--- /dev/null
+++ b/src/examples/eo/isa/eo_isa_simple.h
@@ -0,0 +1,35 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4#include "Eo.h"
5#include "eo_isa_interface.h"
6#include "eo_isa_mixin.h"
7
8extern EAPI Eo_Op SIMPLE_BASE_ID;
9
10enum {
11 SIMPLE_SUB_ID_A_SET,
12 SIMPLE_SUB_ID_A_GET,
13 SIMPLE_SUB_ID_LAST
14};
15
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17
18/**
19 * @def simple_a_set(a)
20 * @brief Set value to a-property
21 * @param[in] a integer value to set
22 */
23#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
24
25/**
26 * @def simple_a_get(a)
27 * @brief Get value of a-property
28 * @param[out] integer pointer to a-value
29 */
30#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
31
32#define SIMPLE_CLASS simple_class_get()
33const Eo_Class *simple_class_get(void);
34
35#endif
diff --git a/src/examples/eo/simple/simple_interface.c b/src/examples/eo/simple/simple_interface.c
new file mode 100644
index 0000000000..e59107267a
--- /dev/null
+++ b/src/examples/eo/simple/simple_interface.c
@@ -0,0 +1,29 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "simple_interface.h"
7
8EAPI Eo_Op INTERFACE_BASE_ID = 0;
9
10#define MY_CLASS INTERFACE_CLASS
11
12static const Eo_Op_Description op_desc[] = {
13 EO_OP_DESCRIPTION(INTERFACE_SUB_ID_A_POWER_3_GET, "Get the a^3"),
14 EO_OP_DESCRIPTION_SENTINEL
15};
16
17static const Eo_Class_Description class_desc = {
18 EO_VERSION,
19 "Interface",
20 EO_CLASS_TYPE_INTERFACE,
21 EO_CLASS_DESCRIPTION_OPS(&INTERFACE_BASE_ID, op_desc, INTERFACE_SUB_ID_LAST),
22 NULL,
23 0,
24 NULL,
25 NULL
26};
27
28EO_DEFINE_CLASS(interface_class_get, &class_desc, NULL, NULL)
29
diff --git a/src/examples/eo/simple/simple_interface.h b/src/examples/eo/simple/simple_interface.h
new file mode 100644
index 0000000000..c5bf43e135
--- /dev/null
+++ b/src/examples/eo/simple/simple_interface.h
@@ -0,0 +1,26 @@
1#ifndef INTERFACE_H
2#define INTERFACE_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op INTERFACE_BASE_ID;
7
8enum {
9 INTERFACE_SUB_ID_A_POWER_3_GET,
10 INTERFACE_SUB_ID_LAST
11};
12
13#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id)
14
15
16/**
17 * @def interface_a_power_3_get(ret)
18 * @brief Get a^3
19 * @param[out] ret integer pointer to ret - value
20 */
21#define interface_a_power_3_get(ret) INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), EO_TYPECHECK(int *, ret)
22
23#define INTERFACE_CLASS interface_class_get()
24const Eo_Class *interface_class_get(void);
25
26#endif
diff --git a/src/examples/eo/simple/simple_main.c b/src/examples/eo/simple/simple_main.c
new file mode 100644
index 0000000000..a93a5e37d2
--- /dev/null
+++ b/src/examples/eo/simple/simple_main.c
@@ -0,0 +1,31 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "simple_simple.h"
7
8int
9main(int argc, char *argv[])
10{
11 (void) argc;
12 (void) argv;
13 eo_init();
14
15 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
16
17 eo_do(obj, simple_a_set(4));
18
19 int a = 0, a2 = 0, a3 = 0;
20
21 eo_do(obj, simple_a_get(&a),
22 interface_a_power_3_get(&a3),
23 mixin_a_square_get(&a2));
24
25 printf("Got %d %d %d\n", a, a2, a3);
26
27 eo_unref(obj);
28 eo_shutdown();
29 return 0;
30}
31
diff --git a/src/examples/eo/simple/simple_mixin.c b/src/examples/eo/simple/simple_mixin.c
new file mode 100644
index 0000000000..389b0891f9
--- /dev/null
+++ b/src/examples/eo/simple/simple_mixin.c
@@ -0,0 +1,53 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "simple_mixin.h"
7#include "simple_simple.h"
8
9EAPI Eo_Op MIXIN_BASE_ID = 0;
10
11#define MY_CLASS MIXIN_CLASS
12
13static void
14_a_square_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
15{
16 int a;
17 eo_do(obj, simple_a_get(&a));
18 int *ret = va_arg(*list, int *);
19 if (ret)
20 *ret = a * a;
21 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
22}
23
24static void
25_class_constructor(Eo_Class *klass)
26{
27 const Eo_Op_Func_Description func_desc[] = {
28 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), _a_square_get),
29 EO_OP_FUNC_SENTINEL
30 };
31
32 eo_class_funcs_set(klass, func_desc);
33}
34
35
36static const Eo_Op_Description op_desc[] = {
37 EO_OP_DESCRIPTION(MIXIN_SUB_ID_A_SQUARE_GET, "Get the value of A^2"),
38 EO_OP_DESCRIPTION_SENTINEL
39};
40
41static const Eo_Class_Description class_desc = {
42 EO_VERSION,
43 "Mixin",
44 EO_CLASS_TYPE_MIXIN,
45 EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
46 NULL,
47 0,
48 _class_constructor,
49 NULL
50};
51
52EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
53
diff --git a/src/examples/eo/simple/simple_mixin.h b/src/examples/eo/simple/simple_mixin.h
new file mode 100644
index 0000000000..539504d3ad
--- /dev/null
+++ b/src/examples/eo/simple/simple_mixin.h
@@ -0,0 +1,26 @@
1#ifndef MIXIN_H
2#define MIXIN_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op MIXIN_BASE_ID;
7
8enum {
9 MIXIN_SUB_ID_A_SQUARE_GET,
10 MIXIN_SUB_ID_LAST
11};
12
13#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
14
15
16/**
17 * @def mixin_a_square_get(ret)
18 * @brief Get the square of a.
19 * @param[out] ret the square of a
20 */
21#define mixin_a_square_get(ret) MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), EO_TYPECHECK(int *, ret)
22
23#define MIXIN_CLASS mixin_class_get()
24const Eo_Class *mixin_class_get(void);
25
26#endif
diff --git a/src/examples/eo/simple/simple_simple.c b/src/examples/eo/simple/simple_simple.c
new file mode 100644
index 0000000000..a172bce3fc
--- /dev/null
+++ b/src/examples/eo/simple/simple_simple.c
@@ -0,0 +1,78 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "simple_simple.h"
7
8EAPI Eo_Op SIMPLE_BASE_ID = 0;
9
10typedef struct
11{
12 int a;
13} Private_Data;
14
15#define MY_CLASS SIMPLE_CLASS
16
17static void
18_a_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
19{
20 const Private_Data *pd = class_data;
21 int *a;
22 a = va_arg(*list, int *);
23 *a = pd->a;
24 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
25}
26
27static void
28_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
29{
30 Private_Data *pd = class_data;
31 int a;
32 a = va_arg(*list, int);
33 pd->a = a;
34 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
35}
36
37static void
38_a_power_3_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
39{
40 const Private_Data *pd = class_data;
41 int *ret;
42 ret = va_arg(*list, int *);
43 if (ret)
44 *ret = pd->a * pd->a * pd->a;
45 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
46}
47
48static void
49_class_constructor(Eo_Class *klass)
50{
51 const Eo_Op_Func_Description func_desc[] = {
52 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
53 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
54 EO_OP_FUNC(INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), _a_power_3_get),
55 EO_OP_FUNC_SENTINEL
56 };
57
58 eo_class_funcs_set(klass, func_desc);
59}
60
61static const Eo_Op_Description op_desc[] = {
62 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
63 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
64 EO_OP_DESCRIPTION_SENTINEL
65};
66
67static const Eo_Class_Description class_desc = {
68 EO_VERSION,
69 "Simple",
70 EO_CLASS_TYPE_REGULAR,
71 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
72 NULL,
73 sizeof(Private_Data),
74 _class_constructor,
75 NULL
76};
77
78EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL);
diff --git a/src/examples/eo/simple/simple_simple.h b/src/examples/eo/simple/simple_simple.h
new file mode 100644
index 0000000000..36d4a00713
--- /dev/null
+++ b/src/examples/eo/simple/simple_simple.h
@@ -0,0 +1,35 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4#include "Eo.h"
5#include "simple_interface.h"
6#include "simple_mixin.h"
7
8extern EAPI Eo_Op SIMPLE_BASE_ID;
9
10enum {
11 SIMPLE_SUB_ID_A_SET,
12 SIMPLE_SUB_ID_A_GET,
13 SIMPLE_SUB_ID_LAST
14};
15
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17
18/**
19 * @def simple_a_set(a)
20 * @brief Set value to a-property
21 * @param[in] a integer value to set
22 */
23#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
24
25/**
26 * @def simple_a_get(a)
27 * @brief Get value of a-property
28 * @param[out] integer pointer to a-value
29 */
30#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
31
32#define SIMPLE_CLASS simple_class_get()
33const Eo_Class *simple_class_get(void);
34
35#endif