forked from enlightenment/efl
Eobj: Add a convenience macro for defining the class_get functions.
This macro makes the code a tad simpler, but more importantly, makes it easier for us to be thread safe, or more corrctly, easier for us the make user code thread safe. SVN revision: 70407
This commit is contained in:
parent
1390200ede
commit
e0f6adbea6
|
@ -8,7 +8,7 @@
|
|||
|
||||
EAPI Eobj_Op INHERIT_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS INHERIT_CLASS
|
||||
|
||||
static void
|
||||
_prot_print(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
|
@ -29,17 +29,12 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
inherit_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "", "Print protected var x1."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Inherit",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
|
||||
|
@ -49,7 +44,6 @@ inherit_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL)
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct
|
|||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
|
@ -41,22 +41,17 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -66,7 +61,7 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
EAPI Eobj_Op COMP_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS COMP_CLASS
|
||||
|
||||
static void
|
||||
_a_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
|
@ -46,12 +46,7 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
comp_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Comp",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -61,8 +56,8 @@ comp_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS,
|
||||
EOBJ_DEFINE_CLASS(comp_class_get, &class_desc, EOBJ_BASE_CLASS,
|
||||
SIMPLE_CLASS, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
|||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
|
@ -16,7 +16,7 @@ _a_set(Eobj *obj, void *class_data, va_list *list)
|
|||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
|
||||
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
|
@ -43,23 +43,18 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -69,7 +64,7 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS MIXIN_CLASS
|
||||
|
||||
static void
|
||||
_add_and_print_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
|
@ -46,17 +46,12 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
mixin_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
|
@ -66,7 +61,7 @@ mixin_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ typedef struct
|
|||
int b;
|
||||
} Private_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static char *class_var = NULL;
|
||||
|
||||
|
@ -79,20 +79,15 @@ _class_destructor(Eobj_Class *klass EINA_UNUSED)
|
|||
free(class_var);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -102,7 +97,8 @@ simple_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
_class_destructor
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS,
|
||||
MIXIN_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, MIXIN_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE2_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
|
@ -14,12 +14,7 @@ _constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
|||
eobj_constructor_error_set(obj);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple2_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple2",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -29,8 +24,7 @@ simple2_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple2_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE3_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
|
@ -12,12 +12,7 @@ _constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
|||
(void) obj;
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple3_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple3",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -27,8 +22,7 @@ simple3_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple3_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
#include "simple.h"
|
||||
#include "simple4.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE4_CLASS
|
||||
|
||||
const Eobj_Class *
|
||||
simple4_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple4",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -20,8 +15,7 @@ simple4_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple4_class_get, &class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE5_CLASS
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
|
@ -12,12 +12,7 @@ _destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
|||
(void) obj;
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple5_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple5",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -27,8 +22,7 @@ simple5_class_get(void)
|
|||
_destructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple5_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE6_CLASS
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
|
@ -14,12 +14,7 @@ _destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
|||
eobj_constructor_error_set(obj);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple6_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple6",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -29,8 +24,7 @@ simple6_class_get(void)
|
|||
_destructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple6_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct
|
|||
Evas_Object *bx;
|
||||
} Widget_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS ELW_BOX_CLASS
|
||||
|
||||
static void
|
||||
_pack_end(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
|
@ -51,17 +51,12 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
elw_box_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Elw Box",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
|
||||
|
@ -71,8 +66,7 @@ elw_box_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(elw_box_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct
|
|||
// Evas_Object *bx;
|
||||
} Widget_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS ELW_BOXEDBUTTON_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
|
@ -29,12 +29,7 @@ _constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
|||
eobj_unref(bt);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
elw_boxedbutton_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Elw BoxedButton",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -44,9 +39,7 @@ elw_boxedbutton_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, ELW_BOX_CLASS,
|
||||
ELW_BUTTON_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(elw_boxedbutton_class_get, &class_desc, ELW_BOX_CLASS, ELW_BUTTON_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ typedef struct
|
|||
Evas_Object *bt;
|
||||
} Widget_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS ELW_BUTTON_CLASS
|
||||
|
||||
static void
|
||||
_position_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
|
@ -86,22 +86,17 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
elw_button_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(ELW_BUTTON_SUB_ID_TEXT_SET, "s", "Text of a text supporting evas object."), // FIXME: This ID sholudn't really be defined here...
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
SIG_CLICKED,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Elw Button",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BUTTON_BASE_ID, op_desc, ELW_BUTTON_SUB_ID_LAST),
|
||||
|
@ -111,8 +106,7 @@ elw_button_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(elw_button_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ typedef struct
|
|||
Evas_Object *bg;
|
||||
} Widget_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS ELW_WIN_CLASS
|
||||
|
||||
static void
|
||||
my_win_del(void *data, Evas_Object *obj, void *event_info)
|
||||
|
@ -43,12 +43,7 @@ _constructor(Eobj *obj, void *class_data)
|
|||
eobj_evas_object_set(obj, wd->win);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
elw_win_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Elw Win",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -58,8 +53,8 @@ elw_win_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||
}
|
||||
|
||||
EOBJ_DEFINE_CLASS(elw_win_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS EVAS_OBJ_CLASS
|
||||
|
||||
EAPI Eobj_Op EVAS_OBJ_BASE_ID = 0;
|
||||
|
||||
|
@ -118,12 +118,7 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
evas_object_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_POSITION_SET, "ii", "Position of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_SIZE_SET, "ii", "Size of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_COLOR_SET, "iiii", "Color of an evas object."),
|
||||
|
@ -131,9 +126,9 @@ evas_object_class_get(void)
|
|||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_VISIBILITY_SET, "b", "Visibility of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CHILD_ADD, "o", "Add a child eobj."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Evas Object",
|
||||
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&EVAS_OBJ_BASE_ID, op_desc, EVAS_OBJ_SUB_ID_LAST),
|
||||
|
@ -143,7 +138,6 @@ evas_object_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(evas_object_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
|
||||
#include "inherit.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS INHERIT_CLASS
|
||||
|
||||
const Eobj_Class *
|
||||
inherit_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Inherit",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -20,7 +15,6 @@ inherit_class_get(void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL);
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
|
||||
EAPI Eobj_Op INHERIT2_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS INHERIT2_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
eobj_do(obj, SIMPLE_A_PRINT());
|
||||
eobj_do_super(obj, SIMPLE_A_SET(a + 1));
|
||||
|
||||
|
@ -50,18 +50,13 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
inherit2_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "", "Print hey"),
|
||||
EOBJ_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "", "Print hey2"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Inherit2",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
|
||||
|
@ -71,7 +66,7 @@ inherit2_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit2_class_get, &class_desc, INHERIT_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, INHERIT_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS INHERIT3_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
eobj_do_super(obj, SIMPLE_A_SET(a + 1));
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,7 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
inherit3_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Inherit3",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -43,7 +38,7 @@ inherit3_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit3_class_get, &class_desc, INHERIT2_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, INHERIT2_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
|
@ -13,7 +13,7 @@ _a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
|||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ _a_print(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
|||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
|
||||
printf("Print %s %d\n", eobj_class_name_get(MY_CLASS), pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -37,18 +37,13 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "", "Print property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -58,7 +53,7 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS MIXIN_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
|
@ -16,7 +16,7 @@ _ab_sum_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
|||
int *sum = va_arg(*list, int *);
|
||||
if (sum)
|
||||
*sum = a + b;
|
||||
printf("%s %s\n", eobj_class_name_get(_my_class), __func__);
|
||||
printf("%s %s\n", eobj_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -42,17 +42,13 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
mixin_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(MIXIN_SUB_ID_AB_SUM_GET, "i", "Get the sum of a and b."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
|
@ -62,9 +58,7 @@ mixin_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, NULL, NULL);
|
||||
EOBJ_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
|
||||
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
#include "../eunit_tests.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS MIXIN2_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(Eobj *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Mixin2_Public_Data *pd = class_data;
|
||||
int *sum = va_arg(*list, int *);
|
||||
printf("%s %s\n", eobj_class_name_get(_my_class), __func__);
|
||||
printf("%s %s\n", eobj_class_name_get(MY_CLASS), __func__);
|
||||
eobj_do_super(obj, MIXIN_AB_SUM_GET(sum));
|
||||
|
||||
++*sum;
|
||||
|
@ -50,12 +50,7 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
mixin2_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Mixin2",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -65,9 +60,7 @@ mixin2_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, MIXIN_CLASS, NULL);
|
||||
EOBJ_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
#include "../eunit_tests.h"
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS MIXIN3_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Mixin3_Public_Data *pd = class_data;
|
||||
int *sum = va_arg(*list, int *);
|
||||
printf("%s %s\n", eobj_class_name_get(_my_class), __func__);
|
||||
printf("%s %s\n", eobj_class_name_get(MY_CLASS), __func__);
|
||||
eobj_do_super(obj, MIXIN_AB_SUM_GET(sum));
|
||||
|
||||
++*sum;
|
||||
|
@ -50,12 +50,7 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
mixin3_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Mixin3",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -65,9 +60,7 @@ mixin3_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
_my_class = eobj_class_new(&class_desc, MIXIN_CLASS, NULL);
|
||||
EOBJ_DEFINE_CLASS(mixin3_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
|
||||
return _my_class;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ typedef struct
|
|||
int b;
|
||||
} Private_Data;
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
#define _GET_SET_FUNC(name) \
|
||||
static void \
|
||||
|
@ -53,20 +53,15 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -76,7 +71,6 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);
|
||||
|
|
|
@ -14,7 +14,7 @@ typedef struct
|
|||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
|
@ -31,7 +31,7 @@ _a_set(Eobj *obj, void *class_data, va_list *list)
|
|||
Eina_Bool
|
||||
_cb_added(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, MY_CLASS);
|
||||
const Eobj_Event_Description *cb_desc = event_info;
|
||||
(void) data;
|
||||
(void) desc;
|
||||
|
@ -48,7 +48,7 @@ _cb_added(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event
|
|||
Eina_Bool
|
||||
_cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, MY_CLASS);
|
||||
const Eobj_Event_Description *cb_desc = event_info;
|
||||
(void) data;
|
||||
(void) desc;
|
||||
|
@ -84,22 +84,17 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -109,7 +104,7 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,17 @@
|
|||
#include <stdarg.h>
|
||||
#include <Eina.h>
|
||||
|
||||
/**
|
||||
* @var _eobj_class_creation_lock
|
||||
* This variable is used for locking purposes in the class_get function
|
||||
* defined in #EOBJ_DEFINE_CLASS.
|
||||
* This is just to work around the fact that we need to init locks before
|
||||
* using them.
|
||||
* Don't touch it if you don't know what you are doing.
|
||||
* @internal
|
||||
*/
|
||||
EAPI extern Eina_Lock _eobj_class_creation_lock;
|
||||
|
||||
/**
|
||||
* @defgroup Eobj Eobj Generic Object System
|
||||
*
|
||||
|
@ -99,6 +110,51 @@ typedef struct _Eobj_Event_Description Eobj_Event_Description;
|
|||
*/
|
||||
typedef struct _Eobj_Class Eobj_Class;
|
||||
|
||||
/**
|
||||
* @def EOBJ_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
|
||||
* A convenience macro to be used for creating the class_get function. This
|
||||
* macro is fairly simple but should still be used as it'll let us improve
|
||||
* things easily.
|
||||
* @param class_get_func_name the name of the wanted class_get function name.
|
||||
* @param class_desc the class description.
|
||||
* @param parent_class The parent class for the function. Look at eobj_class_new() for more information.
|
||||
* @param ... List of etxensions. Look at eobj_class_new() for more information.
|
||||
*
|
||||
* You must use this macro if you want thread safety in class creation.
|
||||
*/
|
||||
#define EOBJ_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
|
||||
EAPI const Eobj_Class * \
|
||||
class_get_func_name(void) \
|
||||
{ \
|
||||
static volatile char lk_init = 0; \
|
||||
static Eina_Lock _my_lock; \
|
||||
static const Eobj_Class * volatile _my_class = NULL; \
|
||||
if (EINA_LIKELY(!!_my_class)) return _my_class; \
|
||||
\
|
||||
eina_lock_take(&_eobj_class_creation_lock); \
|
||||
if (!lk_init) \
|
||||
eina_lock_new(&_my_lock); \
|
||||
if (lk_init < 2) eina_lock_take(&_my_lock); \
|
||||
if (!lk_init) \
|
||||
lk_init = 1; \
|
||||
else \
|
||||
{ \
|
||||
if (lk_init < 2) eina_lock_release(&_my_lock); \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
return _my_class; \
|
||||
} \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
_my_class = eobj_class_new(class_desc, parent_class, __VA_ARGS__); \
|
||||
eina_lock_release(&_my_lock); \
|
||||
\
|
||||
eina_lock_take(&_eobj_class_creation_lock); \
|
||||
eina_lock_free(&_my_lock); \
|
||||
lk_init = 2; \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
return _my_class; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enum representing the possible types of an Eobj class.
|
||||
*/
|
||||
|
@ -139,6 +195,7 @@ typedef struct _Eobj_Op_Func_Description Eobj_Op_Func_Description;
|
|||
* array.
|
||||
*/
|
||||
#define EOBJ_OP_FUNC(op, func) { op, func }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_FUNC_SENTINEL
|
||||
* A convenience macro to be used when populating the #Eobj_Op_Func_Description
|
||||
|
@ -227,6 +284,11 @@ typedef struct _Eobj_Class_Description Eobj_Class_Description;
|
|||
* @param parent the class to inherit from.
|
||||
* @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
|
||||
* @return The new class's handle on success, or NULL otherwise.
|
||||
*
|
||||
* You should use #EOBJ_DEFINE_CLASS. It'll provide thread safety and other
|
||||
* features easily.
|
||||
*
|
||||
* @see #EOBJ_DEFINE_CLASS
|
||||
*/
|
||||
EAPI const Eobj_Class *eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...);
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
typedef int Eobj_Class_Id;
|
||||
|
||||
/* Used inside the class_get functions of classes, see #EOBJ_DEFINE_CLASS */
|
||||
EAPI Eina_Lock _eobj_class_creation_lock;
|
||||
int _eobj_log_dom = -1;
|
||||
|
||||
static Eobj_Class **_eobj_classes;
|
||||
|
@ -815,6 +817,7 @@ eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...
|
|||
klass->extn_data_size = extn_data_off;
|
||||
}
|
||||
|
||||
eina_lock_take(&_eobj_class_creation_lock);
|
||||
klass->class_id = ++_eobj_classes_last_id;
|
||||
{
|
||||
/* FIXME: Handle errors. */
|
||||
|
@ -823,6 +826,7 @@ eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...
|
|||
_eobj_classes = tmp;
|
||||
_eobj_classes[klass->class_id - 1] = klass;
|
||||
}
|
||||
eina_lock_release(&_eobj_class_creation_lock);
|
||||
|
||||
_eobj_class_base_op_init(klass);
|
||||
|
||||
|
@ -1188,6 +1192,12 @@ eobj_init(void)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!eina_lock_new(&_eobj_class_creation_lock))
|
||||
{
|
||||
EINA_LOG_ERR("Could not init lock.");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1209,6 +1219,8 @@ eobj_shutdown(void)
|
|||
if (_eobj_classes)
|
||||
free(_eobj_classes);
|
||||
|
||||
eina_lock_free(&_eobj_class_creation_lock);
|
||||
|
||||
eina_log_domain_unregister(_eobj_log_dom);
|
||||
_eobj_log_dom = -1;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ _data_del(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
|||
}
|
||||
|
||||
/* EOBJ_BASE_CLASS stuff */
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
#define MY_CLASS EOBJ_BASE_CLASS
|
||||
|
||||
/* FIXME: Set proper type descriptions. */
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_CALLBACK_ADD =
|
||||
|
@ -129,13 +129,13 @@ EAPI const Eobj_Event_Description _EOBJ_EV_DEL =
|
|||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(_my_class));
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(MY_CLASS));
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data)
|
||||
{
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(_my_class));
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(MY_CLASS));
|
||||
|
||||
_eobj_generic_data_del_all(class_data);
|
||||
}
|
||||
|
@ -153,27 +153,22 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
EAPI const Eobj_Class *
|
||||
eobj_base_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(EOBJ_BASE_SUB_ID_DATA_SET, "?", "Set data for key."),
|
||||
EOBJ_OP_DESCRIPTION(EOBJ_BASE_SUB_ID_DATA_GET, "?", "Get data for key."),
|
||||
EOBJ_OP_DESCRIPTION(EOBJ_BASE_SUB_ID_DATA_DEL, "?", "Del key."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
EOBJ_EV_CALLBACK_ADD,
|
||||
EOBJ_EV_CALLBACK_DEL,
|
||||
EOBJ_EV_FREE,
|
||||
EOBJ_EV_DEL,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Eobj Base",
|
||||
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&EOBJ_BASE_BASE_ID, op_desc, EOBJ_BASE_SUB_ID_LAST),
|
||||
|
@ -183,8 +178,7 @@ eobj_base_class_get(void)
|
|||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, NULL, NULL);
|
||||
}
|
||||
EOBJ_DEFINE_CLASS(eobj_base_class_get, &class_desc, NULL, NULL)
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static const Eobj_Class *_my_class = NULL;
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
|
@ -13,7 +13,7 @@ _a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
|||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ _a_print(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
|||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
|
||||
printf("Print %s %d\n", eobj_class_name_get(MY_CLASS), pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -37,18 +37,13 @@ _class_constructor(Eobj_Class *klass)
|
|||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "", "Print property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
|
@ -58,7 +53,7 @@ simple_class_get(void)
|
|||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue