summaryrefslogtreecommitdiff
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
parent35acfebee44e78b33f52a9a126edec70c1888a49 (diff)
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
-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);
918 918
919/** 919/**
920 * @brief Gets the name of the passed class. 920 * @brief Gets the name of the passed class.
921 * @param klass the class to work on. 921 * @param[in] klass The class (or object) to work on.
922 * @return The class' name. 922 * @return The class' name.
923 * 923 *
924 * @see efl_class_get() 924 * @see efl_class_get()
@@ -926,6 +926,15 @@ EAPI Eina_Bool efl_isa(const Eo *obj, const Efl_Class *klass);
926EAPI const char *efl_class_name_get(const Efl_Class *klass); 926EAPI const char *efl_class_name_get(const Efl_Class *klass);
927 927
928/** 928/**
929 * @brief Gets the amount of memory this class object would use.
930 * @param[in] klass The class (or object) to work on.
931 * @return The amount of memory in Bytes.
932 *
933 * @see efl_class_get()
934 */
935EAPI size_t efl_class_memory_size_get(const Efl_Class *klass);
936
937/**
929 * @brief Gets a debug name for this object 938 * @brief Gets a debug name for this object
930 * @param obj_id The object (or class) 939 * @param obj_id The object (or class)
931 * @return A name to use in logs and for other debugging purposes 940 * @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:
1150 return NULL; 1150 return NULL;
1151} 1151}
1152 1152
1153EAPI const size_t
1154efl_class_memory_size_get(const Efl_Class *eo_id)
1155{
1156 const _Efl_Class *klass;
1157
1158 if (_eo_is_a_class(eo_id))
1159 {
1160 EO_CLASS_POINTER_GOTO(eo_id, _klass, err_klass);
1161 klass = _klass;
1162 }
1163 else
1164 {
1165 EO_OBJ_POINTER_GOTO(eo_id, obj, err_obj);
1166 klass = obj->klass;
1167 EO_OBJ_DONE(eo_id);
1168 }
1169 return klass->obj_size;
1170
1171err_klass:
1172 _EO_POINTER_ERR(eo_id, "Class (%p) is an invalid ref.", eo_id);
1173err_obj:
1174 return 0;
1175}
1176
1177
1153static void 1178static void
1154_vtable_init(Eo_Vtable *vtable, size_t size) 1179_vtable_init(Eo_Vtable *vtable, size_t size)
1155{ 1180{