Eo: Made constructor/destructor regular ops.

This lets us remove some unneeded code and makes everything nicer.

SVN revision: 71899
This commit is contained in:
Tom Hacohen 2012-06-10 14:04:53 +00:00
parent c712e0fc29
commit 9c929ba2ed
37 changed files with 193 additions and 250 deletions

View File

@ -39,7 +39,7 @@ configure_file (
include(EFLCheck)
add_subdirectory(lib)
add_subdirectory(examples/evas)
#add_subdirectory(examples/evas)
add_subdirectory(examples/mixin)
add_subdirectory(examples/signals)
add_subdirectory(examples/access)

View File

@ -40,8 +40,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
NULL,
0,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -57,8 +57,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -19,9 +19,9 @@ _a_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
Eo *simple = eo_add(SIMPLE_CLASS, obj);
eo_composite_object_attach(obj, simple);
@ -39,6 +39,7 @@ static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
EO_OP_FUNC_SENTINEL
};
@ -52,8 +53,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
_constructor,
NULL,
_class_constructor,
NULL
};

View File

@ -60,8 +60,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Simple_Public_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -20,17 +20,17 @@ _add_and_print_set(const Eo *obj, const void *class_data EINA_UNUSED, va_list *l
extern int my_init_count;
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
my_init_count++;
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
my_init_count--;
}
@ -39,6 +39,8 @@ static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
EO_OP_FUNC_SENTINEL
};
@ -57,8 +59,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
NULL,
0,
_constructor,
_destructor,
_class_constructor,
NULL
};

View File

@ -42,17 +42,17 @@ _GET_SET_FUNC(b)
extern int my_init_count;
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
my_init_count++;
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
my_init_count--;
}
@ -61,6 +61,8 @@ static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
@ -93,8 +95,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
_constructor,
_destructor,
_class_constructor,
_class_destructor
};

View File

@ -7,22 +7,31 @@
#define MY_CLASS SIMPLE2_CLASS
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
eo_error_set(obj);
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
}
static const Eo_Class_Description class_desc = {
"Simple2",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
_constructor,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -7,20 +7,29 @@
#define MY_CLASS SIMPLE3_CLASS
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
(void) obj;
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
}
static const Eo_Class_Description class_desc = {
"Simple3",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
_constructor,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -12,8 +12,6 @@ static const Eo_Class_Description class_desc = {
NULL,
0,
NULL,
NULL,
NULL,
NULL
};

View File

@ -7,20 +7,29 @@
#define MY_CLASS SIMPLE5_CLASS
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
(void) obj;
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
}
static const Eo_Class_Description class_desc = {
"Simple5",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
NULL,
_destructor,
NULL,
_class_constructor,
NULL
};

View File

@ -7,22 +7,31 @@
#define MY_CLASS SIMPLE6_CLASS
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
eo_error_set(obj);
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
}
static const Eo_Class_Description class_desc = {
"Simple6",
EO_CLASS_TYPE_REGULAR,
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
NULL,
_destructor,
NULL,
_class_constructor,
NULL
};

View File

@ -28,7 +28,7 @@ _pack_end(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
static void
_constructor(Eo *obj, void *class_data)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
Widget_Data *wd = class_data;

View File

@ -16,9 +16,9 @@ typedef struct
#define MY_CLASS ELW_BOXEDBUTTON_CLASS
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
Eo *bt = eo_add(ELW_BUTTON_CLASS, obj);
eo_composite_object_attach(obj, bt);

View File

@ -50,7 +50,7 @@ _btn_clicked(void *data, Evas_Object *evas_obj, void *event_info)
static void
_constructor(Eo *obj, void *class_data)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
Widget_Data *wd = class_data;
@ -64,9 +64,9 @@ _constructor(Eo *obj, void *class_data)
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
//Widget_Data *wd = class_data;
/* FIXME: Commented out because it's automatically done because our tree

View File

@ -25,7 +25,7 @@ my_win_del(void *data, Evas_Object *obj, void *event_info)
static void
_constructor(Eo *obj, void *class_data)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
Widget_Data *wd = class_data;

View File

@ -78,9 +78,9 @@ _child_add(Eo *obj, void *class_data, va_list *list)
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
/* Add type check. */
Eo *parent = eo_parent_get(obj);
@ -91,7 +91,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
static void
_destructor(Eo *obj, void *class_data)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
Widget_Data *wd = class_data;

View File

@ -12,8 +12,6 @@ static const Eo_Class_Description class_desc = {
NULL,
0,
NULL,
NULL,
NULL,
NULL
};

View File

@ -72,8 +72,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
NULL,
0,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -34,8 +34,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -47,8 +47,8 @@ main(int argc, char *argv[])
fail_if(eo_class_do(SIMPLE_CLASS, simple_a_print()));
eo_constructor_super(obj);
eo_destructor_super(obj);
eo_do_super(obj, eo_constructor());
eo_do_super(obj, eo_destructor());
eo_unref(obj);

View File

@ -70,8 +70,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Simple_Public_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -20,8 +20,6 @@ static const Eo_Class_Description class_desc = {
NULL,
0,
NULL,
NULL,
NULL,
NULL
};

View File

@ -21,8 +21,6 @@ static const Eo_Class_Description class_desc = {
NULL,
0,
NULL,
NULL,
NULL,
NULL
};

View File

@ -90,8 +90,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -20,21 +20,23 @@ _ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
EO_OP_FUNC_SENTINEL
};
@ -54,8 +56,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
NULL,
0,
_constructor,
_destructor,
_class_constructor,
NULL
};

View File

@ -29,21 +29,23 @@ _ab_sum_get(const Eo *obj, const void *class_data, va_list *list)
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
EO_OP_FUNC_SENTINEL
};
@ -57,8 +59,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
sizeof(Mixin2_Public_Data),
_constructor,
_destructor,
_class_constructor,
NULL
};

View File

@ -29,21 +29,23 @@ _ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
}
static void
_destructor(Eo *obj, void *class_data EINA_UNUSED)
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_do_super(obj, eo_destructor());
}
static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
EO_OP_FUNC_SENTINEL
};
@ -57,8 +59,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
sizeof(Mixin3_Public_Data),
_constructor,
_destructor,
_class_constructor,
NULL
};

View File

@ -67,8 +67,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -63,9 +63,9 @@ _cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_inf
}
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_constructor_super(obj);
eo_do_super(obj, eo_constructor());
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
@ -77,6 +77,7 @@ static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
EO_OP_FUNC_SENTINEL
};
@ -100,8 +101,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
_constructor,
NULL,
_class_constructor,
NULL
};

View File

@ -252,6 +252,7 @@ class_get_func_name(void) \
return _my_class; \
} \
eina_lock_release(&_eo_class_creation_lock); \
(void) parent_class; \
_my_class = eo_class_new(class_desc, id, parent_class, __VA_ARGS__); \
eina_lock_release(&_my_lock); \
\
@ -369,8 +370,6 @@ struct _Eo_Class_Description
} ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */
const Eo_Event_Description **events; /**< The event descriptions for this class. */
size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */
void (*constructor)(Eo *obj, void *class_data); /**< The constructor of the object. */
void (*destructor)(Eo *obj, void *class_data); /**< The destructor of the object. */
void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */
void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */
};
@ -619,22 +618,6 @@ EAPI Eina_Bool eo_class_do_super_internal(const Eo_Class *klass, Eo_Op op, ...);
*/
EAPI const Eo_Class *eo_class_get(const Eo *obj);
/**
* @brief Calls the super constructor of the object passed.
* @param obj the object to work on.
*
* @see eo_destructor_super()
*/
EAPI void eo_constructor_super(Eo *obj);
/**
* @brief Calls the super destructor of the object passed.
* @param obj the object to work on.
*
* @see eo_constructor_super()
*/
EAPI void eo_destructor_super(Eo *obj);
/**
* @def eo_error_set
* @brief Notify eo that there was an error when constructing, destructing or calling a function of the object.
@ -853,7 +836,7 @@ EAPI void eo_manual_free(Eo *obj);
* @brief Use #EO_BASE_CLASS
* @internal
* */
EAPI const Eo_Class *eo_base_class_get(void) EINA_CONST;
EAPI const Eo_Class *eo_base_class_get(void);
/**
* @typedef eo_base_data_free_func
@ -874,6 +857,8 @@ typedef void (*eo_base_data_free_func)(void *);
#define EO_BASE_BASE_ID EO_CLASS_ID_TO_BASE_ID(EO_BASE_CLASS_ID)
enum {
EO_BASE_SUB_ID_CONSTRUCTOR,
EO_BASE_SUB_ID_DESTRUCTOR,
EO_BASE_SUB_ID_DATA_SET,
EO_BASE_SUB_ID_DATA_GET,
EO_BASE_SUB_ID_DATA_DEL,
@ -971,6 +956,26 @@ enum {
if (*wref) eo_do(*wref, eo_wref_del(wref)); \
} while (0)
/**
* @def eo_constructor
* @brief Call the object's constructor.
*
* Should not be used with #eo_do. Only use it with #eo_do_super.
*
* @see #eo_destructor
*/
#define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR)
/**
* @def eo_destructor
* @brief Call the object's destructor.
*
* Should not be used with #eo_do. Only use it with #eo_do_super.
*
* @see #eo_constructor
*/
#define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR)
/**
* @addtogroup Eo_Events Eo's Event Handling
* @{

View File

@ -16,8 +16,7 @@ static Eo_Class **_eo_classes;
static Eo_Class_Id _eo_classes_last_id;
static Eina_Bool _eo_init_count = 0;
static void _eo_constructor(Eo *obj, const Eo_Class *klass);
static void _eo_destructor(Eo *obj, const Eo_Class *klass);
static void _eo_condtor_reset(Eo *obj);
static inline Eina_Bool _eo_error_get(const Eo *obj);
static inline void _eo_error_unset(Eo *obj);
static inline void *_eo_data_get(const Eo *obj, const Eo_Class *klass);
@ -45,9 +44,11 @@ struct _Eo {
Eo_Kls_Itr mro_itr;
Eina_Bool construct_error:1;
Eina_Bool condtor_done:1;
Eina_Bool composite:1;
Eina_Bool del:1;
Eina_Bool construct_error:1;
Eina_Bool manual_free:1;
};
@ -279,7 +280,7 @@ _eo_kls_itr_init(const Eo_Class *obj_klass, Eo_Kls_Itr *cur, Eo_Op op, Eo_Kls_It
prev_state->kls_itr = cur->kls_itr;
/* If we are in a constructor/destructor or we changed an op - init. */
if ((op == EO_NOOP) || (cur->op != op))
if ((cur->op == EO_NOOP) || (cur->op != op))
{
cur->op = op;
cur->kls_itr = obj_klass->mro;
@ -317,17 +318,10 @@ _eo_kls_itr_next(Eo_Kls_Itr *cur, Eo_Op op)
const Eo_Class **kls_itr = cur->kls_itr;
if (*kls_itr)
{
if (op != EO_NOOP)
{
const op_type_funcs *fsrc = _dich_func_get(*kls_itr, op);
const op_type_funcs *fsrc = _dich_func_get(*kls_itr, op);
while (*kls_itr && (*(kls_itr++) != fsrc->src))
;
}
else
{
kls_itr++;
}
while (*kls_itr && (*(kls_itr++) != fsrc->src))
;
cur->kls_itr = kls_itr;
return *kls_itr;
@ -338,13 +332,6 @@ _eo_kls_itr_next(Eo_Kls_Itr *cur, Eo_Op op)
}
}
static inline Eina_Bool
_eo_kls_itr_reached_end(const Eo_Kls_Itr *cur)
{
const Eo_Class **kls_itr = cur->kls_itr;
return !(*kls_itr && *(kls_itr + 1));
}
static inline const op_type_funcs *
_eo_kls_itr_func_get(const Eo_Class *klass, Eo_Kls_Itr *mro_itr, Eo_Op op, Eo_Kls_Itr *prev_state)
{
@ -883,8 +870,6 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
/* Check restrictions on Interface types. */
if (desc->type == EO_CLASS_TYPE_INTERFACE)
{
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->constructor, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->destructor, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->class_constructor, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->class_destructor, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->data_size, NULL);
@ -1135,9 +1120,10 @@ eo_add(const Eo_Class *klass, Eo *parent)
_eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state);
_eo_error_unset(obj);
_eo_condtor_reset(obj);
_eo_ref(obj);
_eo_constructor(obj, klass);
eo_do(obj, eo_constructor());
if (EINA_UNLIKELY(_eo_error_get(obj)))
{
@ -1145,7 +1131,7 @@ eo_add(const Eo_Class *klass, Eo *parent)
goto fail;
}
if (EINA_UNLIKELY(!_eo_kls_itr_reached_end(&obj->mro_itr)))
if (!obj->condtor_done)
{
const Eo_Class *cur_klass = _eo_kls_itr_get(&obj->mro_itr);
ERR("Object of class '%s' - Not all of the object constructors have been executed, last destructor was of class: '%s'", klass->desc->name, cur_klass->desc->name);
@ -1252,13 +1238,15 @@ _eo_del_internal(Eo *obj)
_eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state);
_eo_error_unset(obj);
_eo_destructor(obj, klass);
_eo_condtor_reset(obj);
eo_do(obj, eo_destructor());
if (_eo_error_get(obj))
{
ERR("Object of class '%s' - One of the object destructors have failed.", klass->desc->name);
}
if (!_eo_kls_itr_reached_end(&obj->mro_itr))
if (!obj->condtor_done)
{
const Eo_Class *cur_klass = _eo_kls_itr_get(&obj->mro_itr);
ERR("Object of class '%s' - Not all of the object destructors have been executed, last destructor was of class: '%s'", klass->desc->name, cur_klass->desc->name);
@ -1370,6 +1358,18 @@ _eo_error_unset(Eo *obj)
obj->construct_error = EINA_FALSE;
}
void
_eo_condtor_done(Eo *obj)
{
obj->condtor_done = EINA_TRUE;
}
static void
_eo_condtor_reset(Eo *obj)
{
obj->condtor_done = EINA_FALSE;
}
/**
* @internal
* @brief Check if there was an error when constructing, destructing or calling a function of the object.
@ -1382,58 +1382,6 @@ _eo_error_get(const Eo *obj)
return obj->construct_error;
}
static inline void
_eo_constructor_default(Eo *obj)
{
eo_constructor_super(obj);
}
static inline void
_eo_destructor_default(Eo *obj)
{
eo_destructor_super(obj);
}
static void
_eo_constructor(Eo *obj, const Eo_Class *klass)
{
if (!klass)
return;
if (klass->desc->constructor)
klass->desc->constructor(obj, _eo_data_get(obj, klass));
else
_eo_constructor_default(obj);
}
static void
_eo_destructor(Eo *obj, const Eo_Class *klass)
{
if (!klass)
return;
if (klass->desc->destructor)
klass->desc->destructor(obj, _eo_data_get(obj, klass));
else
_eo_destructor_default(obj);
}
EAPI void
eo_constructor_super(Eo *obj)
{
EO_MAGIC_RETURN(obj, EO_EINA_MAGIC);
_eo_constructor(obj, _eo_kls_itr_next(&obj->mro_itr, EO_NOOP));
}
EAPI void
eo_destructor_super(Eo *obj)
{
EO_MAGIC_RETURN(obj, EO_EINA_MAGIC);
_eo_destructor(obj, _eo_kls_itr_next(&obj->mro_itr, EO_NOOP));
}
static inline void *
_eo_data_get(const Eo *obj, const Eo_Class *klass)
{

View File

@ -484,19 +484,23 @@ EAPI const Eo_Event_Description _EO_EV_DEL =
EO_EVENT_DESCRIPTION("del", "Obj is being deleted.");
static void
_constructor(Eo *obj, void *class_data EINA_UNUSED)
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
_eo_condtor_done(obj);
}
static void
_destructor(Eo *obj, void *class_data)
_destructor(Eo *obj, void *class_data, va_list *list EINA_UNUSED)
{
DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
_eo_generic_data_del_all(class_data);
_wref_destruct(class_data);
_eo_callback_remove_all(class_data);
_eo_condtor_done(obj);
}
static void
@ -505,6 +509,8 @@ _class_constructor(Eo_Class *klass)
event_freeze_count = 0;
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set),
EO_OP_FUNC_CONST(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), _data_del),
@ -528,6 +534,8 @@ _class_constructor(Eo_Class *klass)
}
static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_CONSTRUCTOR, "Constructor"),
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DESTRUCTOR, "Destructor"),
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_SET, "Set data for key."),
EO_OP_DESCRIPTION_CONST(EO_BASE_SUB_ID_DATA_GET, "Get data for key."),
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_DEL, "Del key."),
@ -560,8 +568,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, EO_BASE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
_constructor,
_destructor,
_class_constructor,
NULL
};

View File

@ -54,5 +54,7 @@ extern int _eo_log_dom;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eo_log_dom, __VA_ARGS__)
void _eo_condtor_done(Eo *obj);
#endif

View File

@ -58,8 +58,6 @@ static const Eo_Class_Description class_desc = {
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Simple_Public_Data),
NULL,
NULL,
_class_constructor,
NULL
};

View File

@ -40,8 +40,6 @@ START_TEST(eo_incomplete_desc)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -108,8 +106,6 @@ START_TEST(eo_inherit_errors)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -120,8 +116,6 @@ START_TEST(eo_inherit_errors)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -132,8 +126,6 @@ START_TEST(eo_inherit_errors)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -173,8 +165,6 @@ START_TEST(eo_inconsistent_mro)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -185,8 +175,6 @@ START_TEST(eo_inconsistent_mro)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -197,8 +185,6 @@ START_TEST(eo_inconsistent_mro)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -209,8 +195,6 @@ START_TEST(eo_inconsistent_mro)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -236,7 +220,6 @@ START_TEST(eo_inconsistent_mro)
}
END_TEST
static void _stub_constructor(Eo *obj EINA_UNUSED, void *data EINA_UNUSED) {}
static void _stub_class_constructor(Eo_Class *klass EINA_UNUSED) {}
START_TEST(eo_bad_interface)
@ -252,8 +235,6 @@ START_TEST(eo_bad_interface)
NULL,
10,
NULL,
NULL,
NULL,
NULL
};
@ -261,18 +242,6 @@ START_TEST(eo_bad_interface)
fail_if(klass);
class_desc.data_size = 0;
class_desc.constructor = _stub_constructor;
klass = eo_class_new(&class_desc, 0, NULL, NULL);
fail_if(klass);
class_desc.constructor = NULL;
class_desc.destructor = _stub_constructor;
klass = eo_class_new(&class_desc, 0, NULL, NULL);
fail_if(klass);
class_desc.destructor = NULL;
class_desc.class_constructor = _stub_class_constructor;
klass = eo_class_new(&class_desc, 0, NULL, NULL);
@ -343,8 +312,6 @@ START_TEST(eo_op_types)
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
NULL,
NULL,
_const_ops_class_constructor,
NULL
};

View File

@ -31,8 +31,6 @@ START_TEST(eo_data_fetch)
NULL,
10,
NULL,
NULL,
NULL,
NULL
};
@ -96,8 +94,6 @@ START_TEST(eo_static_classes)
NULL,
0,
NULL,
NULL,
NULL,
NULL
};
@ -114,18 +110,36 @@ START_TEST(eo_static_classes)
}
END_TEST
static Eina_Bool _man_should_con = EINA_TRUE;
static Eina_Bool _man_should_des = EINA_TRUE;
static void
_man_con(Eo *obj, void *data EINA_UNUSED)
_man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_manual_free_set(obj, EINA_TRUE);
eo_constructor_super(obj);
if (_man_should_con)
eo_manual_free_set(obj, EINA_TRUE);
eo_do_super(obj, eo_constructor());
}
static void
_man_des(Eo *obj, void *data EINA_UNUSED)
_man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_destructor_super(obj);
eo_manual_free_set(obj, EINA_FALSE);
eo_do_super(obj, eo_destructor());
if (_man_should_des)
eo_manual_free_set(obj, EINA_FALSE);
}
static void
_man_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
}
START_TEST(eo_man_free)
@ -139,9 +153,7 @@ START_TEST(eo_man_free)
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
10,
_man_con,
_man_des,
NULL,
_man_class_constructor,
NULL
};
@ -157,7 +169,7 @@ START_TEST(eo_man_free)
eo_manual_free(obj);
eo_unref(obj);
class_desc.destructor = NULL;
_man_should_des = EINA_FALSE;
klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
fail_if(!klass);
@ -172,7 +184,7 @@ START_TEST(eo_man_free)
eo_unref(obj);
eo_manual_free(obj);
class_desc.constructor = NULL;
_man_should_con = EINA_FALSE;
klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
fail_if(!klass);
@ -360,8 +372,6 @@ START_TEST(eo_op_errors)
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
NULL,
NULL,
_op_errors_class_constructor,
NULL
};
@ -525,9 +535,6 @@ START_TEST(eo_magic_checks)
eo_error_set((Eo *) buf);
eo_constructor_super((Eo *) buf);
eo_destructor_super((Eo *) buf);
fail_if(eo_data_get((Eo *) buf, SIMPLE_CLASS));
eo_composite_object_attach((Eo *) buf, obj);