forked from enlightenment/efl
Eo: Add reference functions for objects data
We want to introduce a new mechanism concerning the data of the Eo objects. The goal is to improve the memory management by defragmenting the memory banks used by the Eo objects. The first phase has been done by raster and consists in allocating the objects into a separate memory region that the one used by malloc. So now, we know where our objects are located. Now, moving objects means moving data of objects. The issue we have here is that a lot of data pointers are stored into data of other objects, e.g Evas Object data into lists for rendering... We need a way to reference the data and eo_data_get doesn't provide us that. So we need to improve the API for data extraction by requesting from the developer if the data will be stored or not. Five functions are supplied: - eo_data_scope_get: no referencing, the data pointer is no more used after exiting the function. - eo_data_ref: reference the data of the object. It means that while the data is referenced, the object cannot be moved. - eo_data_xref: reference the data of the object but for debug purpose, we associate the objects that references. Same behavior as eo_data_ref for non-debug. - eo_data_unref: unreference the data of an object. - eo_data_xunref: unreference the data of an object previously referenced by another object. I deprecated the eo_data_get function. Most of the time, eo_data_scope_get needs to be used. In the next patches, I changed the eo_data_get to the corresponding functions, according to the usage of the data pointer. The next step is to find all the places in the code where the data is stored but not yet referenced. This will be done by: - requesting from every object to unreference all data to other objects. - moving all the objects from one region to another - requesting from every object to rerefenrence the data. - debugging by hunting the segmentation faults and other weird creatures.
This commit is contained in:
parent
dee2262214
commit
f6a37f88d2
|
@ -55,10 +55,19 @@
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* - Eo way:
|
* - Eo way:
|
||||||
|
* Two functions can be used to extract object data. The use depends if you want to store the data or not. If you just need to access data in the function (most of the time), just use eo_data_scope_get. If you need to store the data (for example in a list of objects data), you have to use eo_data_ref. This function references the data. If you don't need the referenced data anymore, call eo_data_unref.
|
||||||
|
* This reference mechanism will be used in the future to detect bad usage of objects, defragment the memory space used by the objects...
|
||||||
* @code
|
* @code
|
||||||
* Evas_Object_Line *o = eo_data_get(obj, EVAS_OBJ_LINE_CLASS);
|
* Evas_Object_Line *o = eo_data_scope_get(obj, EVAS_OBJ_LINE_CLASS);
|
||||||
* if (!o) return;
|
* if (!o) return;
|
||||||
* @endcode
|
* @endcode
|
||||||
|
* or
|
||||||
|
* @code
|
||||||
|
* Evas_Object_Line *o = eo_data_ref(obj, EVAS_OBJ_LINE_CLASS);
|
||||||
|
* if (!o) return;
|
||||||
|
* ...
|
||||||
|
* eo_data_unref(obj, o);
|
||||||
|
* @endcode
|
||||||
*
|
*
|
||||||
* - Call function of parent
|
* - Call function of parent
|
||||||
* - Old way:
|
* - Old way:
|
||||||
|
@ -74,7 +83,9 @@
|
||||||
* @section Important to know
|
* @section Important to know
|
||||||
* - eo_do() is the function used to invoke functions of a specific class on an object.
|
* - eo_do() is the function used to invoke functions of a specific class on an object.
|
||||||
*
|
*
|
||||||
* - eo_data_get() receives an object and a class and returns the data of the given class for the object. The class must belong to the object class hierarchy.
|
* - eo_data_scope_get() and eo_data_ref() receives an object and a class and returns the data of the given class for the object. The class must belong to the object class hierarchy.
|
||||||
|
*
|
||||||
|
* - eo_data_unref() receives an object and the data to unreference. The data MUST belong to this object.
|
||||||
*
|
*
|
||||||
* - eo_isa() indicates if a given object is of a given type.
|
* - eo_isa() indicates if a given object is of a given type.
|
||||||
*
|
*
|
||||||
|
@ -242,7 +253,7 @@
|
||||||
* Evas_Coord *x2 = va_arg(*list, Evas_Coord *);
|
* Evas_Coord *x2 = va_arg(*list, Evas_Coord *);
|
||||||
* Evas_Coord *y2 = va_arg(*list, Evas_Coord *);
|
* Evas_Coord *y2 = va_arg(*list, Evas_Coord *);
|
||||||
*
|
*
|
||||||
* Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
|
* Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
|
||||||
* if (x1) *x1 = obj->cur.geometry.x + o->cur.x1;
|
* if (x1) *x1 = obj->cur.geometry.x + o->cur.x1;
|
||||||
* if (y1) *y1 = obj->cur.geometry.y + o->cur.y1;
|
* if (y1) *y1 = obj->cur.geometry.y + o->cur.y1;
|
||||||
* if (x2) *x2 = obj->cur.geometry.x + o->cur.x2;
|
* if (x2) *x2 = obj->cur.geometry.x + o->cur.x2;
|
||||||
|
@ -254,7 +265,7 @@
|
||||||
* {
|
* {
|
||||||
* eo_do_super(eo_obj, eo_constructor());
|
* eo_do_super(eo_obj, eo_constructor());
|
||||||
*
|
*
|
||||||
* Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
|
* Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
|
||||||
* evas_object_line_init(eo_obj);
|
* evas_object_line_init(eo_obj);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
|
|
|
@ -775,8 +775,77 @@ EAPI Eina_Bool eo_parent_set(Eo *obj, const Eo *parent);
|
||||||
* @param obj the object to work on.
|
* @param obj the object to work on.
|
||||||
* @param klass the klass associated with the data.
|
* @param klass the klass associated with the data.
|
||||||
* @return a pointer to the data.
|
* @return a pointer to the data.
|
||||||
|
* @deprecated use eo_data_scope_get or eo_data_ref instead.
|
||||||
*/
|
*/
|
||||||
EAPI void *eo_data_get(const Eo *obj, const Eo_Class *klass);
|
EAPI void *eo_data_get(const Eo *obj, const Eo_Class *klass) EINA_DEPRECATED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a pointer to the data of an object for a specific class.
|
||||||
|
* The data reference count is not incremented. The pointer must be used only
|
||||||
|
* in the scope of the function and its callees.
|
||||||
|
* @param obj the object to work on.
|
||||||
|
* @param klass the klass associated with the data.
|
||||||
|
* @return a pointer to the data.
|
||||||
|
*
|
||||||
|
* @see eo_data_ref()
|
||||||
|
* @see eo_data_unref()
|
||||||
|
*/
|
||||||
|
EAPI void *eo_data_scope_get(const Eo *obj, const Eo_Class *klass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def eo_data_xref(obj, klass, ref_obj)
|
||||||
|
* Use this macro if you want to associate a referencer object.
|
||||||
|
* Convenience macro around eo_data_xref_internal()
|
||||||
|
*/
|
||||||
|
#define eo_data_xref(obj, klass, ref_obj) eo_data_xref_internal(__FILE__, __LINE__, obj, klass, ref_obj)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def eo_data_ref(obj, klass)
|
||||||
|
* Use this macro if you don't want to associate a referencer object.
|
||||||
|
* Convenience macro around eo_data_xref_internal()
|
||||||
|
*/
|
||||||
|
#define eo_data_ref(obj, klass) eo_data_xref_internal(__FILE__, __LINE__, obj, klass, (const Eo *)obj)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a pointer to the data of an object for a specific class and
|
||||||
|
* increment the data reference count.
|
||||||
|
* @param obj the object to work on.
|
||||||
|
* @param klass the klass associated with the data.
|
||||||
|
* @param ref_obj the object that references the data.
|
||||||
|
* @param file the call's filename.
|
||||||
|
* @param line the call's line number.
|
||||||
|
* @return a pointer to the data.
|
||||||
|
*
|
||||||
|
* @see eo_data_xunref_internal()
|
||||||
|
*/
|
||||||
|
EAPI void *eo_data_xref_internal(const char *file, int line, const Eo *obj, const Eo_Class *klass, const Eo *ref_obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def eo_data_xunref(obj, data, ref_obj)
|
||||||
|
* Use this function if you used eo_data_xref to reference the data.
|
||||||
|
* Convenience macro around eo_data_xunref_internal()
|
||||||
|
* @see eo_data_xref()
|
||||||
|
*/
|
||||||
|
#define eo_data_xunref(obj, data, ref_obj) eo_data_xunref_internal(obj, data, ref_obj)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def eo_data_unref(obj, data)
|
||||||
|
* Use this function if you used eo_data_ref to reference the data.
|
||||||
|
* Convenience macro around eo_data_unref_internal()
|
||||||
|
* @see eo_data_ref()
|
||||||
|
*/
|
||||||
|
#define eo_data_unref(obj, data) eo_data_xunref_internal(obj, data, obj)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decrement the object data reference count by 1.
|
||||||
|
* @param obj the object to work on.
|
||||||
|
* @param data a pointer to the data to unreference
|
||||||
|
* @param file the call's filename.
|
||||||
|
* @param line the call's line number.
|
||||||
|
*
|
||||||
|
* @see eo_data_xref_internal()
|
||||||
|
*/
|
||||||
|
EAPI void eo_data_xunref_internal(const Eo *obj, void *data, const Eo *ref_obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Increment the object's reference count by 1.
|
* @brief Increment the object's reference count by 1.
|
||||||
|
|
149
src/lib/eo/eo.c
149
src/lib/eo/eo.c
|
@ -33,7 +33,9 @@ static Eo_Op _eo_ops_last_id = 0;
|
||||||
static size_t _eo_sz = 0;
|
static size_t _eo_sz = 0;
|
||||||
|
|
||||||
static void _eo_condtor_reset(_Eo *obj);
|
static void _eo_condtor_reset(_Eo *obj);
|
||||||
static inline void *_eo_data_get(const _Eo *obj, const _Eo_Class *klass);
|
static inline void *_eo_data_scope_get(const _Eo *obj, const _Eo_Class *klass);
|
||||||
|
static inline void *_eo_data_xref_internal(const char *file, int line, _Eo *obj, const _Eo_Class *klass, const _Eo *ref_obj);
|
||||||
|
static inline void _eo_data_xunref_internal(_Eo *obj, void *data, const _Eo *ref_obj);
|
||||||
static inline _Eo *_eo_ref(_Eo *obj);
|
static inline _Eo *_eo_ref(_Eo *obj);
|
||||||
static inline void _eo_unref(_Eo *obj);
|
static inline void _eo_unref(_Eo *obj);
|
||||||
static const _Eo_Class *_eo_op_class_get(Eo_Op op);
|
static const _Eo_Class *_eo_op_class_get(Eo_Op op);
|
||||||
|
@ -48,6 +50,7 @@ struct _Eo_Internal {
|
||||||
const _Eo_Class *klass;
|
const _Eo_Class *klass;
|
||||||
#ifdef EO_DEBUG
|
#ifdef EO_DEBUG
|
||||||
Eina_Inlist *xrefs;
|
Eina_Inlist *xrefs;
|
||||||
|
Eina_Inlist *data_xrefs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Eina_List *composite_objects;
|
Eina_List *composite_objects;
|
||||||
|
@ -55,6 +58,7 @@ struct _Eo_Internal {
|
||||||
Eo_Id obj_id;
|
Eo_Id obj_id;
|
||||||
|
|
||||||
int refcount;
|
int refcount;
|
||||||
|
int datarefcount;
|
||||||
|
|
||||||
Eina_Bool do_error:1;
|
Eina_Bool do_error:1;
|
||||||
Eina_Bool condtor_done:1;
|
Eina_Bool condtor_done:1;
|
||||||
|
@ -357,7 +361,7 @@ _eo_op_internal(const char *file, int line, _Eo *obj, const _Eo_Class *cur_klass
|
||||||
const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
|
const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
|
||||||
if (EINA_LIKELY(func != NULL))
|
if (EINA_LIKELY(func != NULL))
|
||||||
{
|
{
|
||||||
void *func_data =_eo_data_get(obj, func->src);
|
void *func_data = _eo_data_scope_get(obj, func->src);
|
||||||
func->func((Eo *)obj->obj_id, func_data, p_list);
|
func->func((Eo *)obj->obj_id, func_data, p_list);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1244,7 @@ eo_xunref(Eo *obj_id, const Eo *ref_obj_id)
|
||||||
Eo_Xref_Node *xref = NULL;
|
Eo_Xref_Node *xref = NULL;
|
||||||
EINA_INLIST_FOREACH(obj->xrefs, xref)
|
EINA_INLIST_FOREACH(obj->xrefs, xref)
|
||||||
{
|
{
|
||||||
if (xref->ref_obj == ref_obj)
|
if (xref->ref_obj == ref_obj_id)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,7 +1255,7 @@ eo_xunref(Eo *obj_id, const Eo *ref_obj_id)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERR("ref_obj (%p) does not reference obj (%p). Aborting unref.", ref_obj, obj);
|
ERR("ref_obj (%p) does not reference obj (%p). Aborting unref.", ref_obj_id, obj_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1324,6 +1328,12 @@ _eo_del_internal(const char *file, int line, _Eo *obj)
|
||||||
static inline void
|
static inline void
|
||||||
_eo_free(_Eo *obj)
|
_eo_free(_Eo *obj)
|
||||||
{
|
{
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
if (obj->datarefcount)
|
||||||
|
{
|
||||||
|
ERR("Object %p data still referenced %d time(s).", obj, obj->datarefcount);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
_eo_id_release(obj->obj_id);
|
_eo_id_release(obj->obj_id);
|
||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
|
@ -1351,6 +1361,15 @@ _eo_unref(_Eo *obj)
|
||||||
free(EINA_INLIST_CONTAINER_GET(obj->xrefs, Eo_Xref_Node));
|
free(EINA_INLIST_CONTAINER_GET(obj->xrefs, Eo_Xref_Node));
|
||||||
obj->xrefs = nitr;
|
obj->xrefs = nitr;
|
||||||
}
|
}
|
||||||
|
while (obj->data_xrefs)
|
||||||
|
{
|
||||||
|
Eina_Inlist *nitr = obj->data_xrefs->next;
|
||||||
|
Eo_Xref_Node *xref = EINA_INLIST_CONTAINER_GET(obj->data_xrefs, Eo_Xref_Node);
|
||||||
|
ERR("Data of object 0x%p is still referenced by object 0x%X", obj->obj_id, xref->ref_obj);
|
||||||
|
|
||||||
|
free(xref);
|
||||||
|
obj->data_xrefs = nitr;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!obj->manual_free)
|
if (!obj->manual_free)
|
||||||
|
@ -1426,7 +1445,7 @@ _eo_condtor_reset(_Eo *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
_eo_data_get(const _Eo *obj, const _Eo_Class *klass)
|
_eo_data_scope_get(const _Eo *obj, const _Eo_Class *klass)
|
||||||
{
|
{
|
||||||
if (EINA_LIKELY(klass->desc->data_size > 0))
|
if (EINA_LIKELY(klass->desc->data_size > 0))
|
||||||
{
|
{
|
||||||
|
@ -1453,8 +1472,85 @@ _eo_data_get(const _Eo *obj, const _Eo_Class *klass)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
_eo_data_xref_internal(const char *file, int line, _Eo *obj, const _Eo_Class *klass, const _Eo *ref_obj)
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
if (klass != NULL)
|
||||||
|
{
|
||||||
|
data = _eo_data_scope_get(obj, klass);
|
||||||
|
if (data == NULL) return NULL;
|
||||||
|
}
|
||||||
|
(obj->datarefcount)++;
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
Eo_Xref_Node *xref = calloc(1, sizeof(*xref));
|
||||||
|
xref->ref_obj = (Eo *)ref_obj->obj_id;
|
||||||
|
xref->file = file;
|
||||||
|
xref->line = line;
|
||||||
|
|
||||||
|
obj->data_xrefs = eina_inlist_prepend(obj->data_xrefs, EINA_INLIST_GET(xref));
|
||||||
|
#else
|
||||||
|
(void) ref_obj;
|
||||||
|
(void) file;
|
||||||
|
(void) line;
|
||||||
|
#endif
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
_eo_data_xunref_internal(_Eo *obj, void *data, const _Eo *ref_obj)
|
||||||
|
{
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
const _Eo_Class *klass = obj->klass;
|
||||||
|
char *data_base = ((char *) obj) + EO_ALIGN_SIZE(sizeof(*obj));
|
||||||
|
Eina_Bool in_range = ((char *)data >= data_base &&
|
||||||
|
(char *)data < (data_base + (klass->data_offset +
|
||||||
|
EO_ALIGN_SIZE(klass->desc->data_size) + klass->extn_data_size)));
|
||||||
|
if (!in_range)
|
||||||
|
{
|
||||||
|
ERR("Data %p is not in the data range of the object 0x%X (%s).", data, obj->obj_id, obj->klass->desc->name);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void) data;
|
||||||
|
#endif
|
||||||
|
if (obj->datarefcount == 0)
|
||||||
|
{
|
||||||
|
ERR("Data for object 0x%X (%s) is already not referenced.", obj->obj_id, obj->klass->desc->name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(obj->datarefcount)--;
|
||||||
|
}
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
Eo_Xref_Node *xref = NULL;
|
||||||
|
EINA_INLIST_FOREACH(obj->data_xrefs, xref)
|
||||||
|
{
|
||||||
|
if (xref->ref_obj == (Eo *)ref_obj->obj_id)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xref)
|
||||||
|
{
|
||||||
|
obj->data_xrefs = eina_inlist_remove(obj->data_xrefs, EINA_INLIST_GET(xref));
|
||||||
|
free(xref);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERR("ref_obj (0x%X) does not reference data (%p) of obj (0x%X).", ref_obj->obj_id, data, obj->obj_id);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void) ref_obj;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
eo_data_get(const Eo *obj_id, const Eo_Class *klass_id)
|
eo_data_get(const Eo *obj_id, const Eo_Class *klass_id)
|
||||||
|
{
|
||||||
|
return eo_data_scope_get(obj_id, klass_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void *
|
||||||
|
eo_data_scope_get(const Eo *obj_id, const Eo_Class *klass_id)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL);
|
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL);
|
||||||
|
@ -1469,7 +1565,7 @@ eo_data_get(const Eo *obj_id, const Eo_Class *klass_id)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = _eo_data_get(obj, klass);
|
ret = _eo_data_scope_get(obj, klass);
|
||||||
|
|
||||||
#ifdef EO_DEBUG
|
#ifdef EO_DEBUG
|
||||||
if (!ret && (klass->desc->data_size == 0))
|
if (!ret && (klass->desc->data_size == 0))
|
||||||
|
@ -1481,6 +1577,47 @@ eo_data_get(const Eo *obj_id, const Eo_Class *klass_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void *
|
||||||
|
eo_data_xref_internal(const char *file, int line, const Eo *obj_id, const Eo_Class *klass_id, const Eo *ref_obj_id)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL);
|
||||||
|
EO_OBJ_POINTER_RETURN_VAL(ref_obj_id, ref_obj, NULL);
|
||||||
|
_Eo_Class *klass = NULL;
|
||||||
|
if (klass_id)
|
||||||
|
{
|
||||||
|
klass = _eo_class_pointer_get(klass_id);
|
||||||
|
EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, NULL);
|
||||||
|
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
if (!_eo_class_mro_has(obj->klass, klass))
|
||||||
|
{
|
||||||
|
ERR("Tried getting data of class '%s' from object of class '%s', but the former is not a direct inheritance of the latter.", klass->desc->name, obj->klass->desc->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = _eo_data_xref_internal(file, line, obj, klass, ref_obj);
|
||||||
|
|
||||||
|
#ifdef EO_DEBUG
|
||||||
|
if (klass && !ret && (klass->desc->data_size == 0))
|
||||||
|
{
|
||||||
|
ERR("Tried getting data of class '%s', but it has none..", klass->desc->name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
eo_data_xunref_internal(const Eo *obj_id, void *data, const Eo *ref_obj_id)
|
||||||
|
{
|
||||||
|
EO_OBJ_POINTER_RETURN(obj_id, obj);
|
||||||
|
EO_OBJ_POINTER_RETURN(ref_obj_id, ref_obj);
|
||||||
|
_eo_data_xunref_internal(obj, data, ref_obj);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eo_init(void)
|
eo_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ EAPI Eo_Op INHERIT_BASE_ID = 0;
|
||||||
static void
|
static void
|
||||||
_prot_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
_prot_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||||
{
|
{
|
||||||
Simple_Protected_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
Simple_Protected_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
(void) list;
|
(void) list;
|
||||||
printf("%s %d\n", __func__, pd->protected_x1);
|
printf("%s %d\n", __func__, pd->protected_x1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
eo_do(obj, simple_a_set(1), inherit_prot_print());
|
eo_do(obj, simple_a_set(1), inherit_prot_print());
|
||||||
|
|
||||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
printf("Pub: %d\n", pd->public_x2);
|
printf("Pub: %d\n", pd->public_x2);
|
||||||
|
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
|
@ -20,7 +20,7 @@ main(int argc, char *argv[])
|
||||||
Eo *obj = eo_add(INHERIT2_CLASS, NULL);
|
Eo *obj = eo_add(INHERIT2_CLASS, NULL);
|
||||||
|
|
||||||
eo_do(obj, simple_a_set(1));
|
eo_do(obj, simple_a_set(1));
|
||||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
fail_if(pd->a != 2);
|
fail_if(pd->a != 2);
|
||||||
|
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
@ -28,7 +28,7 @@ main(int argc, char *argv[])
|
||||||
obj = eo_add(INHERIT3_CLASS, NULL);
|
obj = eo_add(INHERIT3_CLASS, NULL);
|
||||||
|
|
||||||
eo_do(obj, simple_a_set(1));
|
eo_do(obj, simple_a_set(1));
|
||||||
pd = eo_data_get(obj, SIMPLE_CLASS);
|
pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
fail_if(pd->a != 3);
|
fail_if(pd->a != 3);
|
||||||
|
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
|
@ -28,10 +28,10 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));
|
eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));
|
||||||
|
|
||||||
Mixin2_Public_Data *pd2 = eo_data_get(obj, MIXIN2_CLASS);
|
Mixin2_Public_Data *pd2 = eo_data_scope_get(obj, MIXIN2_CLASS);
|
||||||
fail_if(pd2->count != 6);
|
fail_if(pd2->count != 6);
|
||||||
|
|
||||||
Mixin3_Public_Data *pd3 = eo_data_get(obj, MIXIN3_CLASS);
|
Mixin3_Public_Data *pd3 = eo_data_scope_get(obj, MIXIN3_CLASS);
|
||||||
fail_if(pd3->count != 9);
|
fail_if(pd3->count != 9);
|
||||||
|
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
|
@ -44,7 +44,7 @@ main(int argc, char *argv[])
|
||||||
eo_init();
|
eo_init();
|
||||||
|
|
||||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
|
|
||||||
/* The order of these two is undetermined. */
|
/* The order of these two is undetermined. */
|
||||||
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
|
||||||
|
|
|
@ -33,7 +33,7 @@ _a_set(Eo *obj, void *class_data, va_list *list)
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
_cb_added(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
_cb_added(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||||
{
|
{
|
||||||
Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
|
Simple_Public_Data *pd = eo_data_scope_get(obj, MY_CLASS);
|
||||||
const Eo_Callback_Array_Item *callback_array = event_info;
|
const Eo_Callback_Array_Item *callback_array = event_info;
|
||||||
(void) data;
|
(void) data;
|
||||||
(void) desc;
|
(void) desc;
|
||||||
|
@ -50,7 +50,7 @@ _cb_added(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_inf
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
_cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
_cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||||
{
|
{
|
||||||
Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
|
Simple_Public_Data *pd = eo_data_scope_get(obj, MY_CLASS);
|
||||||
const Eo_Callback_Array_Item *callback_array = event_info;
|
const Eo_Callback_Array_Item *callback_array = event_info;
|
||||||
(void) data;
|
(void) data;
|
||||||
(void) desc;
|
(void) desc;
|
||||||
|
|
|
@ -127,7 +127,7 @@ START_TEST(eo_data_fetch)
|
||||||
Eo *obj = eo_add(klass, NULL);
|
Eo *obj = eo_add(klass, NULL);
|
||||||
fail_if(!obj);
|
fail_if(!obj);
|
||||||
#ifdef EO_DEBUG
|
#ifdef EO_DEBUG
|
||||||
fail_if(eo_data_get(obj, SIMPLE_CLASS));
|
fail_if(eo_data_scope_get(obj, SIMPLE_CLASS));
|
||||||
#endif
|
#endif
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ START_TEST(eo_data_fetch)
|
||||||
|
|
||||||
obj = eo_add(klass, NULL);
|
obj = eo_add(klass, NULL);
|
||||||
fail_if(!obj);
|
fail_if(!obj);
|
||||||
fail_if(eo_data_get(obj, klass));
|
fail_if(eo_data_scope_get(obj, klass));
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
||||||
eo_shutdown();
|
eo_shutdown();
|
||||||
|
@ -695,7 +695,7 @@ START_TEST(eo_magic_checks)
|
||||||
|
|
||||||
eo_error_set((Eo *) buf);
|
eo_error_set((Eo *) buf);
|
||||||
|
|
||||||
fail_if(eo_data_get((Eo *) buf, SIMPLE_CLASS));
|
fail_if(eo_data_scope_get((Eo *) buf, SIMPLE_CLASS));
|
||||||
|
|
||||||
eo_composite_attach((Eo *) buf, obj);
|
eo_composite_attach((Eo *) buf, obj);
|
||||||
eo_composite_attach(obj, (Eo *) buf);
|
eo_composite_attach(obj, (Eo *) buf);
|
||||||
|
@ -808,13 +808,13 @@ START_TEST(eo_add_do_and_custom)
|
||||||
|
|
||||||
obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7));
|
obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7));
|
||||||
fail_if(!obj);
|
fail_if(!obj);
|
||||||
pd = eo_data_get(obj, SIMPLE_CLASS);
|
pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
fail_if(pd->a != 7);
|
fail_if(pd->a != 7);
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
||||||
obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7));
|
obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7));
|
||||||
fail_if(!obj);
|
fail_if(!obj);
|
||||||
pd = eo_data_get(obj, SIMPLE_CLASS);
|
pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||||
fail_if(pd->a != 7);
|
fail_if(pd->a != 7);
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue