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)
EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
NULL,
0,
- NULL,
- NULL,
_class_constructor,
NULL
};
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
}
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);
_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
};
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
- _constructor,
- NULL,
_class_constructor,
NULL
};
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Simple_Public_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
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--;
}
_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
};
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
NULL,
0,
- _constructor,
- _destructor,
_class_constructor,
NULL
};
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--;
}
_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),
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
- _constructor,
- _destructor,
_class_constructor,
_class_destructor
};
#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
};
#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
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
#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
};
#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
};
static void
_constructor(Eo *obj, void *class_data)
{
- eo_constructor_super(obj);
+ eo_do_super(obj, eo_constructor());
Widget_Data *wd = class_data;
#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);
static void
_constructor(Eo *obj, void *class_data)
{
- eo_constructor_super(obj);
+ eo_do_super(obj, eo_constructor());
Widget_Data *wd = 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
static void
_constructor(Eo *obj, void *class_data)
{
- eo_constructor_super(obj);
+ eo_do_super(obj, eo_constructor());
Widget_Data *wd = class_data;
}
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);
static void
_destructor(Eo *obj, void *class_data)
{
- eo_destructor_super(obj);
+ eo_do_super(obj, eo_destructor());
Widget_Data *wd = class_data;
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
NULL,
0,
- NULL,
- NULL,
_class_constructor,
NULL
};
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
- NULL,
- NULL,
_class_constructor,
NULL
};
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);
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Simple_Public_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
}
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
};
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
NULL,
0,
- _constructor,
- _destructor,
_class_constructor,
NULL
};
}
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
};
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
sizeof(Mixin2_Public_Data),
- _constructor,
- _destructor,
_class_constructor,
NULL
};
}
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
};
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
sizeof(Mixin3_Public_Data),
- _constructor,
- _destructor,
_class_constructor,
NULL
};
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Private_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
}
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));
_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
};
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
- _constructor,
- NULL,
_class_constructor,
NULL
};
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); \
\
} 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. */
};
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.
* @param obj the object to work on.
* @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
#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,
} 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
* @{
*/
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);
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;
};
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;
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;
}
}
-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)
{
/* 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);
_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)))
{
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);
_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);
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.
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)
{
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
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),
}
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."),
EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, EO_BASE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
- _constructor,
- _destructor,
_class_constructor,
NULL
};
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eo_log_dom, __VA_ARGS__)
+void _eo_condtor_done(Eo *obj);
+
#endif
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
NULL,
sizeof(Simple_Public_Data),
- NULL,
- NULL,
_class_constructor,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
}
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)
NULL,
10,
NULL,
- NULL,
- NULL,
NULL
};
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);
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
- NULL,
- NULL,
_const_ops_class_constructor,
NULL
};
NULL,
10,
NULL,
- NULL,
- NULL,
NULL
};
NULL,
0,
NULL,
- NULL,
- NULL,
NULL
};
}
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, va_list *list EINA_UNUSED)
+{
+ eo_do_super(obj, eo_destructor());
+ if (_man_should_des)
+ eo_manual_free_set(obj, EINA_FALSE);
}
+
static void
-_man_des(Eo *obj, void *data EINA_UNUSED)
+_man_class_constructor(Eo_Class *klass)
{
- eo_destructor_super(obj);
- eo_manual_free_set(obj, EINA_FALSE);
+ 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)
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
10,
- _man_con,
- _man_des,
- NULL,
+ _man_class_constructor,
NULL
};
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);
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);
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
NULL,
0,
- NULL,
- NULL,
_op_errors_class_constructor,
NULL
};
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);