aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2018-12-06 16:36:59 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-09 11:02:07 -0800
commite02dba3377a29051ffb5893cc6a117e5d9a1d682 (patch)
tree6cb6e94f3e30709001c0ba81500b340b093efcac /src/lib
parenteo: provider find actually is just accepting Efl.Class, maybe an hystoric lef... (diff)
downloadefl-e02dba3377a29051ffb5893cc6a117e5d9a1d682.tar.gz
eo: add the ability to get the size of object of a certain class.
Their was two different way to implement this, either like this with a simple function that work on Efl_Class, or by a function on Efl.Object. I leaned on the first one, but I could easily be convinced it should be done on Efl.Object actually. Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D7441
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eo/Eo.h11
-rw-r--r--src/lib/eo/eo.c25
2 files changed, 35 insertions, 1 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 62210443a1..a6aa5b97d5 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -918,7 +918,7 @@ EAPI Eina_Bool efl_isa(const Eo *obj, const Efl_Class *klass);
/**
* @brief Gets the name of the passed class.
- * @param klass the class to work on.
+ * @param[in] klass The class (or object) to work on.
* @return The class' name.
*
* @see efl_class_get()
@@ -926,6 +926,15 @@ EAPI Eina_Bool efl_isa(const Eo *obj, const Efl_Class *klass);
EAPI const char *efl_class_name_get(const Efl_Class *klass);
/**
+ * @brief Gets the amount of memory this class object would use.
+ * @param[in] klass The class (or object) to work on.
+ * @return The amount of memory in Bytes.
+ *
+ * @see efl_class_get()
+ */
+EAPI size_t efl_class_memory_size_get(const Efl_Class *klass);
+
+/**
* @brief Gets a debug name for this object
* @param obj_id The object (or class)
* @return A name to use in logs and for other debugging purposes
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 3fb7fd6639..ed0f371f53 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1150,6 +1150,31 @@ err_obj:
return NULL;
}
+EAPI const size_t
+efl_class_memory_size_get(const Efl_Class *eo_id)
+{
+ const _Efl_Class *klass;
+
+ if (_eo_is_a_class(eo_id))
+ {
+ EO_CLASS_POINTER_GOTO(eo_id, _klass, err_klass);
+ klass = _klass;
+ }
+ else
+ {
+ EO_OBJ_POINTER_GOTO(eo_id, obj, err_obj);
+ klass = obj->klass;
+ EO_OBJ_DONE(eo_id);
+ }
+ return klass->obj_size;
+
+err_klass:
+ _EO_POINTER_ERR(eo_id, "Class (%p) is an invalid ref.", eo_id);
+err_obj:
+ return 0;
+}
+
+
static void
_vtable_init(Eo_Vtable *vtable, size_t size)
{