Eobj: Pass the private data to functions automatically.

This saves us from having to call the data_get function. This makes the
code nicer and potentially faster.

Thanks to raster for the tip.

SVN revision: 70145
This commit is contained in:
Tom Hacohen 2012-04-12 13:52:13 +00:00
parent 0395f7943c
commit 697c58026f
22 changed files with 123 additions and 144 deletions

View File

@ -4,15 +4,16 @@
#include "inherit.h"
#include "config.h"
EAPI Eobj_Op INHERIT_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_prot_print(Eobj *obj, Eobj_Op op, va_list *list)
_prot_print(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Simple_Protected_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
(void) op;
(void) list;
printf("%s %d\n", __func__, pd->protected_x1);
}

View File

@ -16,10 +16,9 @@ EAPI const Eobj_Event_Description _SIG_A_CHANGED =
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj, void *class_data, va_list *list)
{
Private_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Private_Data *pd = class_data;
int a;
a = va_arg(*list, int);
pd->a = a;

View File

@ -2,6 +2,8 @@
#include "simple.h"
#include "comp.h"
#include "config.h"
#include "../eunit_tests.h"
EAPI Eobj_Op COMP_BASE_ID = 0;
@ -9,16 +11,15 @@ EAPI Eobj_Op COMP_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_a_get(Eobj *obj, Eobj_Op op, va_list *list)
_a_get(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
int *a;
a = va_arg(*list, int *);
eobj_super_do(obj, SIMPLE_A_GET(a));
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);

View File

@ -1,6 +1,8 @@
#include "Eobj.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
@ -9,10 +11,9 @@ EAPI const Eobj_Event_Description _SIG_A_CHANGED =
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
int a;
a = va_arg(*list, int);
printf("%s %d\n", eobj_class_name_get(_my_class), a);
@ -22,10 +23,9 @@ _a_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_a_get(Eobj *obj, Eobj_Op op, va_list *list)
_a_get(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
int *a;
a = va_arg(*list, int *);
*a = pd->a;

View File

@ -2,14 +2,15 @@
#include "mixin.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op MIXIN_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
_add_and_print_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
int a, b, x;
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b));
x = va_arg(*list, const int);
@ -19,7 +20,7 @@ _add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
extern int my_init_count;
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
@ -27,7 +28,7 @@ _constructor(Eobj *obj)
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_destructor_super(obj);

View File

@ -2,6 +2,8 @@
#include "mixin.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
typedef struct
@ -14,20 +16,18 @@ static Eobj_Class *_my_class = NULL;
#define _GET_SET_FUNC(name) \
static void \
_##name##_get(Eobj *obj, Eobj_Op op, va_list *list) \
_##name##_get(Eobj *obj __UNUSED__, void *class_data, va_list *list) \
{ \
Private_Data *pd = eobj_data_get(obj, _my_class); \
(void) op; \
Private_Data *pd = class_data; \
int *name; \
name = va_arg(*list, int *); \
*name = pd->name; \
printf("%s %d\n", __func__, pd->name); \
} \
static void \
_##name##_set(Eobj *obj, Eobj_Op op, va_list *list) \
_##name##_set(Eobj *obj __UNUSED__, void *class_data, va_list *list) \
{ \
Private_Data *pd = eobj_data_get(obj, _my_class); \
(void) op; \
Private_Data *pd = class_data; \
int name; \
name = va_arg(*list, int); \
pd->name = name; \
@ -40,7 +40,7 @@ _GET_SET_FUNC(b)
extern int my_init_count;
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
@ -48,7 +48,7 @@ _constructor(Eobj *obj)
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_destructor_super(obj);

View File

@ -2,10 +2,12 @@
#include "mixin.h"
#include "simple2.h"
#include "config.h"
static Eobj_Class *_my_class = NULL;
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);

View File

@ -2,10 +2,12 @@
#include "mixin.h"
#include "simple3.h"
#include "config.h"
static Eobj_Class *_my_class = NULL;
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
(void) obj;
}

View File

@ -4,6 +4,8 @@
#include "evas_obj.h"
#include "elw_box.h"
#include "config.h"
EAPI Eobj_Op ELW_BOX_BASE_ID = 0;
typedef struct
@ -14,10 +16,9 @@ typedef struct
static Eobj_Class *_my_class = NULL;
static void
_pack_end(Eobj *obj, Eobj_Op op, va_list *list)
_pack_end(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Widget_Data *wd = eobj_data_get(obj, _my_class);
(void) op;
Widget_Data *wd = class_data;
Eobj *child_obj;
child_obj = va_arg(*list, Eobj *);
/* FIXME: Ref and the later uref child_obj here... */
@ -25,11 +26,11 @@ _pack_end(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data)
{
eobj_constructor_super(obj);
Widget_Data *wd = eobj_data_get(obj, _my_class);
Widget_Data *wd = class_data;
/* FIXME: An hack, because our tree is not yet only Eobj */
wd->bx = elm_box_add(eobj_evas_object_get(eobj_parent_get(obj)));

View File

@ -6,6 +6,8 @@
#include "elw_button.h"
#include "elw_boxedbutton.h"
#include "config.h"
typedef struct
{
// Evas_Object *bx;
@ -14,7 +16,7 @@ typedef struct
static Eobj_Class *_my_class = NULL;
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
@ -27,12 +29,6 @@ _constructor(Eobj *obj)
eobj_unref(bt);
}
static void
_destructor(Eobj *obj)
{
eobj_destructor_super(obj);
}
const Eobj_Class *
elw_boxedbutton_class_get(void)
{
@ -45,7 +41,7 @@ elw_boxedbutton_class_get(void)
NULL,
sizeof(Widget_Data),
_constructor,
_destructor,
NULL,
NULL,
NULL
};

View File

@ -4,6 +4,8 @@
#include "evas_obj.h"
#include "elw_button.h"
#include "config.h"
EAPI Eobj_Op ELW_BUTTON_BASE_ID = 0;
EAPI const Eobj_Event_Description _SIG_CLICKED =
@ -17,9 +19,8 @@ typedef struct
static Eobj_Class *_my_class = NULL;
static void
_position_set(Eobj *obj, Eobj_Op op, va_list *list)
_position_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
(void) obj;
Evas_Coord x, y;
x = va_arg(*list, Evas_Coord);
@ -29,10 +30,9 @@ _position_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_text_set(Eobj *obj, Eobj_Op op, va_list *list)
_text_set(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Widget_Data *wd = eobj_data_get(obj, _my_class);
(void) op;
Widget_Data *wd = class_data;
const char *text;
text = va_arg(*list, const char *);
elm_object_text_set(wd->bt, text);
@ -48,11 +48,11 @@ _btn_clicked(void *data, Evas_Object *evas_obj, void *event_info)
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data)
{
eobj_constructor_super(obj);
Widget_Data *wd = eobj_data_get(obj, _my_class);
Widget_Data *wd = class_data;
/* FIXME: An hack, because our tree is not yet only Eobj */
wd->bt = elm_button_add(eobj_evas_object_get(eobj_parent_get(obj)));
@ -64,11 +64,11 @@ _constructor(Eobj *obj)
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_destructor_super(obj);
//Widget_Data *wd = eobj_data_get(obj, _my_class);
//Widget_Data *wd = class_data;
/* FIXME: Commented out because it's automatically done because our tree
* is not made of only eobj */
//evas_object_del(wd->bt);

View File

@ -23,11 +23,11 @@ my_win_del(void *data, Evas_Object *obj, void *event_info)
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data)
{
eobj_constructor_super(obj);
Widget_Data *wd = eobj_data_get(obj, _my_class);
Widget_Data *wd = class_data;
/* FIXME: Will actually do something about those when I care... */
wd->win = elm_win_add(NULL, "eobj-test", ELM_WIN_BASIC);
@ -43,17 +43,6 @@ _constructor(Eobj *obj)
eobj_evas_object_set(obj, wd->win);
}
static void
_destructor(Eobj *obj)
{
eobj_destructor_super(obj);
//Widget_Data *wd = eobj_data_get(obj, _my_class);
/* FIXME: Commented out because it's automatically done because our tree
* is not made of only eobj */
// evas_object_del(wd->bx);
}
const Eobj_Class *
elw_win_class_get(void)
{
@ -66,7 +55,7 @@ elw_win_class_get(void)
NULL,
sizeof(Widget_Data),
_constructor,
_destructor,
NULL,
NULL,
NULL
};

View File

@ -3,6 +3,8 @@
#include "Eobj.h"
#include "evas_obj.h"
#include "config.h"
static Eobj_Class *_my_class = NULL;
EAPI Eobj_Op EVAS_OBJ_BASE_ID = 0;
@ -13,10 +15,9 @@ typedef struct
} Widget_Data;
static void
_position_set(Eobj *obj, Eobj_Op op, va_list *list)
_position_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Evas_Object *evas_obj = eobj_evas_object_get(obj);
(void) op;
Evas_Coord x, y;
x = va_arg(*list, Evas_Coord);
y = va_arg(*list, Evas_Coord);
@ -24,10 +25,9 @@ _position_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_size_set(Eobj *obj, Eobj_Op op, va_list *list)
_size_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Evas_Object *evas_obj = eobj_evas_object_get(obj);
(void) op;
Evas_Coord w, h;
w = va_arg(*list, Evas_Coord);
h = va_arg(*list, Evas_Coord);
@ -35,10 +35,9 @@ _size_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_color_set(Eobj *obj, Eobj_Op op, va_list *list)
_color_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Evas_Object *evas_obj = eobj_evas_object_get(obj);
(void) op;
int r, g, b, a;
r = va_arg(*list, int);
g = va_arg(*list, int);
@ -48,10 +47,9 @@ _color_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_color_get(Eobj *obj, Eobj_Op op, va_list *list)
_color_get(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Evas_Object *evas_obj = eobj_evas_object_get(obj);
(void) op;
int *r, *g, *b, *a;
r = va_arg(*list, int*);
g = va_arg(*list, int*);
@ -61,10 +59,9 @@ _color_get(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_visibility_set(Eobj *obj, Eobj_Op op, va_list *list)
_visibility_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
Evas_Object *evas_obj = eobj_evas_object_get(obj);
(void) op;
Eina_Bool v;
v = va_arg(*list, int);
if (v) evas_object_show(evas_obj);
@ -72,17 +69,16 @@ _visibility_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_child_add(Eobj *obj, Eobj_Op op, va_list *list)
_child_add(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Widget_Data *wd = eobj_data_get(obj, _my_class);
(void) op;
Widget_Data *wd = class_data;
Eobj *child;
child = va_arg(*list, Eobj *);
wd->children = eina_list_append(wd->children, eobj_ref(child));
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
@ -93,11 +89,11 @@ _constructor(Eobj *obj)
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data)
{
eobj_destructor_super(obj);
Widget_Data *wd = eobj_data_get(obj, _my_class);
Widget_Data *wd = class_data;
Eobj *child;
EINA_LIST_FREE(wd->children, child)

View File

@ -4,14 +4,15 @@
#include "inherit.h"
#include "inherit2.h"
#include "config.h"
EAPI Eobj_Op INHERIT2_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
int a;
a = va_arg(*list, int);
printf("%s %d\n", eobj_class_name_get(_my_class), a);

View File

@ -4,14 +4,15 @@
#include "inherit2.h"
#include "inherit3.h"
#include "config.h"
EAPI Eobj_Op INHERIT3_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
int a;
a = va_arg(*list, int);
printf("%s %d\n", eobj_class_name_get(_my_class), a);

View File

@ -1,15 +1,16 @@
#include "Eobj.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
int a;
a = va_arg(*list, int);
printf("%s %d\n", eobj_class_name_get(_my_class), a);
@ -17,10 +18,9 @@ _a_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_a_print(Eobj *obj, Eobj_Op op, va_list *list)
_a_print(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
(void) list;
printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
}

View File

@ -2,14 +2,15 @@
#include "mixin.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op MIXIN_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
_add_and_print_set(Eobj *obj, void *class_data __UNUSED__, va_list *list)
{
(void) op;
int a, b, x;
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b));
x = va_arg(*list, const int);
@ -17,13 +18,13 @@ _add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_destructor_super(obj);
}

View File

@ -2,6 +2,8 @@
#include "mixin.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
typedef struct
@ -14,20 +16,18 @@ static Eobj_Class *_my_class = NULL;
#define _GET_SET_FUNC(name) \
static void \
_##name##_get(Eobj *obj, Eobj_Op op, va_list *list) \
_##name##_get(Eobj *obj __UNUSED__, void *class_data, va_list *list) \
{ \
Private_Data *pd = eobj_data_get(obj, _my_class); \
(void) op; \
Private_Data *pd = class_data; \
int *name; \
name = va_arg(*list, int *); \
*name = pd->name; \
printf("%s %d\n", __func__, pd->name); \
} \
static void \
_##name##_set(Eobj *obj, Eobj_Op op, va_list *list) \
_##name##_set(Eobj *obj __UNUSED__, void *class_data, va_list *list) \
{ \
Private_Data *pd = eobj_data_get(obj, _my_class); \
(void) op; \
Private_Data *pd = class_data; \
int name; \
name = va_arg(*list, int); \
pd->name = name; \
@ -37,18 +37,6 @@ _##name##_set(Eobj *obj, Eobj_Op op, va_list *list) \
_GET_SET_FUNC(a)
_GET_SET_FUNC(b)
static void
_constructor(Eobj *obj)
{
eobj_constructor_super(obj);
}
static void
_destructor(Eobj *obj)
{
eobj_destructor_super(obj);
}
static void
_class_constructor(Eobj_Class *klass)
{
@ -82,8 +70,8 @@ simple_class_get(void)
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
_constructor,
_destructor,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -1,6 +1,8 @@
#include "Eobj.h"
#include "simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
typedef struct
@ -15,10 +17,9 @@ EAPI const Eobj_Event_Description _SIG_A_CHANGED =
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj, void *class_data, va_list *list)
{
Private_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Private_Data *pd = class_data;
int a;
a = va_arg(*list, int);
pd->a = a;
@ -62,7 +63,7 @@ _cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event
}
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
eobj_constructor_super(obj);
@ -72,12 +73,6 @@ _constructor(Eobj *obj)
eobj_generic_data_set(obj, "cb_count", (intptr_t) 0);
}
static void
_destructor(Eobj *obj)
{
eobj_destructor_super(obj);
}
static void
_class_constructor(Eobj_Class *klass)
{
@ -111,7 +106,7 @@ simple_class_get(void)
event_desc,
sizeof(Private_Data),
_constructor,
_destructor,
NULL,
_class_constructor,
NULL
};

View File

@ -31,7 +31,7 @@ typedef enum
EOBJ_CLASS_TYPE_MIXIN
} Eobj_Class_Type;
typedef void (*eobj_op_func_type)(Eobj *, Eobj_Op, va_list *list);
typedef void (*eobj_op_func_type)(Eobj *, void *class_data, va_list *list);
typedef struct
{
@ -71,9 +71,9 @@ typedef struct
size_t count;
} ops;
const Eobj_Event_Description **events;
size_t private_size;
void (*constructor)(Eobj *obj);
void (*destructor)(Eobj *obj);
size_t data_size;
void (*constructor)(Eobj *obj, void *class_data);
void (*destructor)(Eobj *obj, void *class_data);
void (*class_constructor)(Eobj_Class *klass);
void (*class_destructor)(Eobj_Class *klass);
} Eobj_Class_Description;

View File

@ -2,6 +2,8 @@
#include "Eobj.h"
#include "config.h"
static int _eobj_log_dom = -1;
static Eobj_Class **_eobj_classes;
@ -333,7 +335,7 @@ _eobj_op_internal(Eobj *obj, Eobj_Op op, va_list *p_list)
if (func)
{
func(obj, op, p_list);
func(obj, eobj_data_get(obj, klass), p_list);
ret = EINA_TRUE;
goto end;
}
@ -638,9 +640,9 @@ eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...
/* Update the current offset. */
/* FIXME: Make sure this alignment is enough. */
klass->data_offset = klass->parent->data_offset +
klass->parent->desc->private_size +
klass->parent->desc->data_size +
(sizeof(void *) -
(klass->parent->desc->private_size % sizeof(void *)));
(klass->parent->desc->data_size % sizeof(void *)));
}
klass->class_id = ++_eobj_classes_last_id;
@ -707,7 +709,7 @@ eobj_add(const Eobj_Class *klass, Eobj *parent)
obj->refcount++;
obj->data_blob = calloc(1, klass->data_offset + klass->desc->private_size);
obj->data_blob = calloc(1, klass->data_offset + klass->desc->data_size);
_eobj_kls_itr_init(obj, EOBJ_NOOP);
eobj_class_constructor(obj, klass);
@ -836,7 +838,7 @@ eobj_class_constructor(Eobj *obj, const Eobj_Class *klass)
return;
if (klass->desc->constructor)
klass->desc->constructor(obj);
klass->desc->constructor(obj, eobj_data_get(obj, klass));
else
_eobj_constructor_default(obj);
}
@ -848,7 +850,7 @@ eobj_class_destructor(Eobj *obj, const Eobj_Class *klass)
return;
if (klass->desc->destructor)
klass->desc->destructor(obj);
klass->desc->destructor(obj, eobj_data_get(obj, klass));
else
_eobj_destructor_default(obj);
}
@ -870,7 +872,10 @@ eobj_data_get(Eobj *obj, const Eobj_Class *klass)
{
/* FIXME: Add a check that this is of the right klass and we don't seg.
* Probably just return NULL. */
return ((char *) obj->data_blob) + klass->data_offset;
if (klass->desc->data_size > 0)
return ((char *) obj->data_blob) + klass->data_offset;
else
return NULL;
}
typedef struct
@ -1248,13 +1253,13 @@ EAPI const Eobj_Event_Description _EOBJ_SIG_CALLBACK_DEL =
EOBJ_EVENT_DESCRIPTION("callback,del", "?", "Called when a callback was deleted.");
static void
_constructor(Eobj *obj)
_constructor(Eobj *obj, void *class_data __UNUSED__)
{
DBG("%p - %s.", obj, _my_class->desc->name);
}
static void
_destructor(Eobj *obj)
_destructor(Eobj *obj, void *class_data __UNUSED__)
{
DBG("%p - %s.", obj, _my_class->desc->name);
}

View File

@ -1,15 +1,16 @@
#include "Eobj.h"
#include "class_simple.h"
#include "config.h"
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
static Eobj_Class *_my_class = NULL;
static void
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
_a_set(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
int a;
a = va_arg(*list, int);
printf("%s %d\n", eobj_class_name_get(_my_class), a);
@ -17,10 +18,9 @@ _a_set(Eobj *obj, Eobj_Op op, va_list *list)
}
static void
_a_print(Eobj *obj, Eobj_Op op, va_list *list)
_a_print(Eobj *obj __UNUSED__, void *class_data, va_list *list)
{
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
(void) op;
Simple_Public_Data *pd = class_data;
(void) list;
printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
}