eo2: updated the access test to use eo2.

This commit is contained in:
Tom Hacohen 2013-07-30 16:08:25 +01:00
parent 5f45e57b89
commit ac2f6d0bf5
5 changed files with 22 additions and 65 deletions

View File

@ -7,42 +7,30 @@
#include "access_simple_protected.h"
#include "access_inherit.h"
EAPI Eo_Op INHERIT_BASE_ID = 0;
#define MY_CLASS INHERIT_CLASS
static void
_prot_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
_prot_print(Eo *obj, void *class_data EINA_UNUSED)
{
Simple_Protected_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
(void) list;
printf("%s %d\n", __func__, pd->protected_x1);
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
EO_OP_FUNC_SENTINEL
};
EAPI EO2_VOID_FUNC_BODY(inherit_prot_print);
eo_class_funcs_set(klass, func_desc);
}
static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "Print protected var x1."),
EO_OP_DESCRIPTION_SENTINEL
static Eo2_Op_Description op_desc[] = {
EO2_OP_FUNC(_prot_print, inherit_prot_print, "Print protocted var x1."),
EO2_OP_SENTINEL
};
static const Eo_Class_Description class_desc = {
EO_VERSION,
EO2_VERSION,
"Inherit",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
EO2_CLASS_DESCRIPTION_OPS(op_desc),
NULL,
0,
_class_constructor,
NULL,
NULL
};

View File

@ -1,16 +1,7 @@
#ifndef INHERIT_H
#define INHERIT_H
extern EAPI Eo_Op INHERIT_BASE_ID;
enum {
INHERIT_SUB_ID_PROT_PRINT,
INHERIT_SUB_ID_LAST
};
#define INHERIT_ID(sub_id) (INHERIT_BASE_ID + sub_id)
#define inherit_prot_print() INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT)
EAPI void inherit_prot_print(void);
#define INHERIT_CLASS inherit_class_get()
const Eo_Class *inherit_class_get(void);

View File

@ -13,9 +13,9 @@ main(int argc, char *argv[])
(void) argv;
eo_init();
Eo *obj = eo_add(INHERIT_CLASS, NULL);
Eo *obj = eo2_add(INHERIT_CLASS, NULL);
eo_do(obj, simple_a_set(1), inherit_prot_print());
eo2_do(obj, simple_a_set(1), inherit_prot_print());
Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
printf("Pub: %d\n", pd->public_x2);

View File

@ -6,8 +6,6 @@
#include "access_simple.h"
#include "access_simple_protected.h"
EAPI Eo_Op SIMPLE_BASE_ID = 0;
typedef struct
{
Simple_Protected_Data protected;
@ -20,34 +18,23 @@ EAPI const Eo_Event_Description _EV_A_CHANGED =
#define MY_CLASS SIMPLE_CLASS
static void
_a_set(Eo *obj, void *class_data, va_list *list)
_a_set(Eo *obj, void *class_data, int a)
{
Private_Data *pd = class_data;
int a;
a = va_arg(*list, int);
pd->a = a;
printf("%s %d\n", __func__, pd->a);
pd->protected.protected_x1 = a + 1;
pd->protected.public.public_x2 = a + 2;
eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a));
}
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_SENTINEL
};
EAPI EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a);
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_SENTINEL
static Eo2_Op_Description op_desc[] = {
EO2_OP_FUNC(_a_set, simple_a_set, "Set property A."),
EO2_OP_SENTINEL
};
static const Eo_Event_Description *event_desc[] = {
@ -56,15 +43,15 @@ static const Eo_Event_Description *event_desc[] = {
};
static const Eo_Class_Description class_desc = {
EO_VERSION,
EO2_VERSION,
"Simple",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
EO2_CLASS_DESCRIPTION_OPS(op_desc),
event_desc,
sizeof(Private_Data),
_class_constructor,
NULL,
NULL
};
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL)

View File

@ -1,21 +1,12 @@
#ifndef SIMPLE_H
#define SIMPLE_H
extern EAPI Eo_Op SIMPLE_BASE_ID;
enum {
SIMPLE_SUB_ID_A_SET,
SIMPLE_SUB_ID_LAST
};
typedef struct
{
int public_x2;
} Simple_Public_Data;
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
EAPI void simple_a_set(int a);
extern const Eo_Event_Description _EV_A_CHANGED;
#define EV_A_CHANGED (&(_EV_A_CHANGED))