diff options
author | tasn <tasn> | 2012-06-25 09:07:39 +0000 |
---|---|---|
committer | tasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-06-25 09:07:39 +0000 |
commit | 70e2be76af844c1f7acb48a06d015576c0a70606 (patch) | |
tree | adea95e6f0ffd25adf51db1e33a5cf8a616618e4 /src/examples/eo_isa/simple.c | |
parent | 1f55d0c124ed19a0acc0d8ee883b8eb70aebed99 (diff) | |
download | eobj-70e2be76af844c1f7acb48a06d015576c0a70606.tar.gz eobj-70e2be76af844c1f7acb48a06d015576c0a70606.tar.bz2 eobj-70e2be76af844c1f7acb48a06d015576c0a70606.zip |
Eo: Added an eo_isa example.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@72793 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
Diffstat (limited to 'src/examples/eo_isa/simple.c')
-rw-r--r-- | src/examples/eo_isa/simple.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/examples/eo_isa/simple.c b/src/examples/eo_isa/simple.c new file mode 100644 index 0000000..7a32757 --- /dev/null +++ b/src/examples/eo_isa/simple.c @@ -0,0 +1,75 @@ +#include "Eo.h" +#include "simple.h" + +#include "config.h" + +EAPI Eo_Op SIMPLE_BASE_ID = 0; + +typedef struct +{ + int a; +} Private_Data; + +#define MY_CLASS SIMPLE_CLASS + +static void +_a_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list) +{ + const Private_Data *pd = class_data; + int *a; + a = va_arg(*list, int *); + *a = pd->a; + printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); +} + +static void +_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) +{ + Private_Data *pd = class_data; + int a; + a = va_arg(*list, int); + pd->a = a; + printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); +} + +static void +_a_power_3_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list) +{ + const Private_Data *pd = class_data; + int *ret; + ret = va_arg(*list, int *); + if (ret) + *ret = pd->a * pd->a * pd->a; + printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__); +} + +static void +_class_constructor(Eo_Class *klass) +{ + const Eo_Op_Func_Description func_desc[] = { + EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), + EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), + EO_OP_FUNC_CONST(INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), _a_power_3_get), + EO_OP_FUNC_SENTINEL + }; + + eo_class_funcs_set(klass, func_desc); +} + +static const Eo_Op_Description op_desc[] = { + EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), + EO_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "Get property A"), + EO_OP_DESCRIPTION_SENTINEL +}; + +static const Eo_Class_Description class_desc = { + "Simple", + EO_CLASS_TYPE_REGULAR, + EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST), + NULL, + sizeof(Private_Data), + _class_constructor, + NULL +}; + +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL); |