static size_t _eo_sz = 0;
static size_t _eo_class_sz = 0;
-static size_t _eo_handle_sz = 0;
static void _eo_condtor_reset(_Eo_Object *obj);
static inline void *_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass);
static inline Eina_Bool
_eo_is_a_class(const Eo *obj_id)
{
+ Eo_Id oid;
#ifdef HAVE_EO_ID
- return (((((Eo_Id) obj_id) >> REF_TAG_SHIFT) & 0x1) == 0x0);
+ oid = (Eo_Id) obj_id;
#else
/* fortunately EO_OBJ_POINTER_RETURN* will handle NULL obj_id */
if (!obj_id) return EINA_FALSE;
- return (((_Eo_Handle *) obj_id)->is_a_class == 1);
+ oid = ((Eo_Header *) obj_id)->id;
#endif
+ return (((oid >> REF_TAG_SHIFT) & 0x1) == 0x0);
}
static inline _Eo_Class *
#ifdef HAVE_EO_ID
return ID_CLASS_GET((Eo_Id)klass_id);
#else
- return (_Eo_Class *) EO_FROM_HANDLE(klass_id);
-#endif
-}
-
-static inline
-Eo * _eo_class_id_get(const _Eo_Class *klass)
-{
-#ifdef HAVE_EO_ID
- return (Eo *) klass->header.id;
-#else
- return (Eo *) HANDLE_FROM_EO(klass);
+ return (_Eo_Class *) klass_id;
#endif
}
if (op_type == EO_OP_TYPE_REGULAR)
{
func_data = _eo_data_scope_get(eo_ptr.obj, func->src);
- calling_obj = (Eo *)eo_ptr.obj->header.id;
+ calling_obj = _eo_id_get((Eo *) eo_ptr.obj);
}
else
{
}
EINA_TRASH_CLEAN(&klass->objects.trash, data)
-#ifdef HAVE_EO_ID
- free(data);
-#else
- free((void *) HANDLE_FROM_EO(data));
-#endif
+ free(data);
EINA_TRASH_CLEAN(&klass->iterators.trash, data)
- free(data);
+ free(data);
eina_lock_free(&klass->objects.trash_lock);
eina_lock_free(&klass->iterators.trash_lock);
-#ifdef HAVE_EO_ID
free(klass);
-#else
- free((void *) HANDLE_FROM_EO(klass));
-#endif
}
/* DEVCHECK */
eo_class_new(const Eo_Class_Description *desc, const Eo *parent_id, ...)
{
_Eo_Class *klass;
- _Eo_Handle *hndl;
va_list p_list;
size_t extn_sz, mro_sz, mixins_sz;
Eina_List *extn_list, *mro, *mixins;
DBG("Finished building Mixins list for class '%s'", desc->name);
}
-#ifdef HAVE_EO_ID
- (void) hndl;
klass = calloc(1, _eo_class_sz + extn_sz + mro_sz + mixins_sz);
-#else
- hndl = calloc(1, _eo_handle_sz + _eo_class_sz + extn_sz + mro_sz + mixins_sz);
- hndl->is_a_class = 1;
- klass = (_Eo_Class *) EO_FROM_HANDLE(hndl);
+#ifndef HAVE_EO_ID
EINA_MAGIC_SET((Eo_Header *) klass, EO_CLASS_EINA_MAGIC);
#endif
eina_lock_new(&klass->objects.trash_lock);
extn_data_itr->offset = 0;
}
-#ifdef HAVE_EO_ID
klass->obj_size = _eo_sz + extn_data_off;
-#else
- klass->obj_size = _eo_handle_sz + _eo_sz + extn_data_off;
-#endif
if (getenv("EO_DEBUG"))
{
fprintf(stderr, "Eo class '%s' will take %u bytes per object.\n",
{
Eina_Bool do_err;
_Eo_Object *obj;
- _Eo_Handle *hndl;
EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, NULL);
if (parent_id)
}
else
{
-#ifdef HAVE_EO_ID
- (void) hndl;
obj = calloc(1, klass->obj_size);
-#else
- hndl = calloc(1, klass->obj_size);
- hndl->is_a_class = 0;
- obj = EO_FROM_HANDLE(hndl);
-#endif
}
eina_lock_release(&klass->objects.trash_lock);
_eo_unref(obj);
- return (Eo *)obj_id;
+ return _eo_id_get((Eo *) obj);
fail:
/* Unref twice, once for the ref above, and once for the basic object ref. */
(obj->datarefcount)++;
#ifdef EO_DEBUG
Eo_Xref_Node *xref = calloc(1, sizeof(*xref));
- xref->ref_obj = (Eo *)ref_obj->header.id;
+ xref->ref_obj = _eo_id_get(ref_obj);
xref->file = file;
xref->line = line;
#endif
if (obj->datarefcount == 0)
{
- ERR("Data for object %lx (%s) is already not referenced.", (unsigned long)obj->header.id, obj->klass->desc->name);
+ ERR("Data for object %lx (%s) is already not referenced.", (unsigned long) _eo_id_get((Eo *) obj), obj->klass->desc->name);
}
else
{
Eo_Xref_Node *xref = NULL;
EINA_INLIST_FOREACH(obj->data_xrefs, xref)
{
- if (xref->ref_obj == (Eo *)ref_obj->header.id)
+ if (xref->ref_obj == _eo_id_get(ref_obj))
break;
}
}
else
{
- ERR("ref_obj (0x%lx) does not reference data (%p) of obj (0x%lx).", (unsigned long)ref_obj->header.id, data, (unsigned long)obj->header.id);
+ ERR("ref_obj (0x%lx) does not reference data (%p) of obj (0x%lx).", (unsigned long) _eo_id_get(ref_obj), data, (unsigned long)_eo_id_get(obj));
}
#else
(void) ref_obj;
_eo_sz = EO_ALIGN_SIZE(sizeof(_Eo_Object));
_eo_class_sz = EO_ALIGN_SIZE(sizeof(_Eo_Class));
- _eo_handle_sz = EO_ALIGN_SIZE(sizeof(_Eo_Handle));
_eo_classes = NULL;
_eo_classes_last_id = EO_CLASS_IDS_FIRST - 1;
typedef struct _Eo_Class _Eo_Class;
typedef struct _Eo_Object _Eo_Object;
typedef struct _Eo_Header Eo_Header;
-typedef struct _Eo_Handle _Eo_Handle;
typedef union _Eo {
_Eo_Object *obj;
_Eo_Class *klass;
void _eo_condtor_done(Eo *obj);
-struct _Eo_Handle {
- Eina_Bool is_a_class:1;
-};
-
struct _Eo_Header
{
#ifndef HAVE_EO_ID
int line;
} Eo_Xref_Node;
+static inline
+Eo *_eo_header_id_get(const Eo_Header *header)
+{
+#ifdef HAVE_EO_ID
+ return (Eo *) header->id;
+#else
+ return (Eo *) header;
+#endif
+}
+
+static inline
+Eo *_eo_class_id_get(const _Eo_Class *klass)
+{
+ return _eo_header_id_get((Eo_Header *) klass);
+}
+
+static inline
+Eo *_eo_id_get(const Eo *obj)
+{
+ return _eo_header_id_get((Eo_Header *) obj);
+}
+
static inline void
_eo_condtor_reset(_Eo_Object *obj)
{
/* We need that for the event callbacks that may ref/unref. */
obj->refcount++;
- eo_do((Eo *) obj->header.id, eo_event_callback_call(EO_EV_DEL, NULL, NULL));
+ eo_do(_eo_id_get((Eo *) obj), eo_event_callback_call(EO_EV_DEL, NULL, NULL));
const _Eo_Class *klass = obj->klass;
_eo_condtor_reset(obj);
- do_err = eo_do((Eo *)obj->header.id, eo_destructor());
+ do_err = eo_do(_eo_id_get((Eo *) obj), eo_destructor());
if (EINA_UNLIKELY(!do_err))
{
ERR("in %s:%d: Object of class '%s' - One of the object destructors have failed.",
Eo *emb_obj;
EINA_LIST_FOREACH_SAFE(obj->composite_objects, itr, itr_n, emb_obj)
{
- eo_composite_detach(emb_obj, (Eo *)obj->header.id);
+ eo_composite_detach(emb_obj, _eo_id_get((Eo *) obj));
}
}
ERR("Object %p data still referenced %d time(s).", obj, obj->datarefcount);
}
#endif
- _eo_id_release(obj->header.id);
+ _eo_id_release((Eo_Id) _eo_id_get((Eo *) obj));
eina_lock_take(&klass->objects.trash_lock);
if (klass->objects.trash_count <= 8)
}
else
{
-#ifdef HAVE_EO_ID
free(obj);
-#else
- free(((char *) obj) - eina_mempool_alignof(sizeof (_Eo_Handle)));
-#endif
}
eina_lock_release(&klass->objects.trash_lock);
}
{
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%lx is still referenced by object %p", (unsigned long)obj->header.id, xref->ref_obj);
+ ERR("Data of object 0x%lx is still referenced by object %p", (unsigned long) _eo_id_get((Eo *) obj), xref->ref_obj);
free(xref);
obj->data_xrefs = nitr;