Eobj: Pass the private data to functions automatically.
authortasn <tasn>
Thu, 12 Apr 2012 13:52:13 +0000 (13:52 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 12 Apr 2012 13:52:13 +0000 (13:52 +0000)
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.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@70145 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

22 files changed:
examples/access/inherit.c
examples/access/simple.c
examples/composite_objects/comp.c
examples/composite_objects/simple.c
examples/constructors/mixin.c
examples/constructors/simple.c
examples/constructors/simple2.c
examples/constructors/simple3.c
examples/evas/elw_box.c
examples/evas/elw_boxedbutton.c
examples/evas/elw_button.c
examples/evas/elw_win.c
examples/evas/evas_obj.c
examples/function_overrides/inherit2.c
examples/function_overrides/inherit3.c
examples/function_overrides/simple.c
examples/mixin/mixin.c
examples/mixin/simple.c
examples/signals/simple.c
lib/Eobj.h
lib/eobj.c
tests/class_simple.c

index 3e6786d..68e0db7 100644 (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);
 }
index 8dbd155..73fa1ac 100644 (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;
index a688d20..48fabd1 100644 (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);
 
index e0bd735..0c7ab95 100644 (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;
index a591482..fc44893 100644 (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);
 
index 13d0426..3a2090b 100644 (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);
 
index 6390333..0633998 100644 (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);
 
index e47b32c..83675ef 100644 (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;
 }
index d825579..9002a8d 100644 (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)));
index e95071a..9a0ec9f 100644 (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
    };
index 4f454c6..71ae888 100644 (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);
index afddb13..95db40c 100644 (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
    };
index e53caaa..19426e5 100644 (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)
index be628d4..412ed47 100644 (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);
index b7c754b..7b8c840 100644 (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);
index 4c5fc87..65232d1 100644 (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);
 }
index 7a6eff9..19fd0b0 100644 (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);
 }
index f03947a..c26488a 100644 (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; \
@@ -38,18 +38,6 @@ _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)
 {
    const Eobj_Op_Func_Description func_desc[] = {
@@ -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
    };
index 4dbb8fc..b636482 100644 (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);
 
@@ -73,12 +74,6 @@ _constructor(Eobj *obj)
 }
 
 static void
-_destructor(Eobj *obj)
-{
-   eobj_destructor_super(obj);
-}
-
-static void
 _class_constructor(Eobj_Class *klass)
 {
    const Eobj_Op_Func_Description func_desc[] = {
@@ -111,7 +106,7 @@ simple_class_get(void)
         event_desc,
         sizeof(Private_Data),
         _constructor,
-        _destructor,
+        NULL,
         _class_constructor,
         NULL
    };
index afb4f96..856c252 100644 (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;
index 26552a8..a4269d8 100644 (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);
 }
index 2bbf052..57e9810 100644 (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);
 }