Hi, Here's a new feature: efl_debug_name_get(obj);
This returns a temporary string (eina_slstr) that you can use in debug logs. Don't abuse it, but I find it extremely useful when debugging stuff in EFL. You can improve the debug string by overriding "debug_name_override" in subclasses. Follow the examples & the doc. Hope you guys like it! 2017-08-04 11:02 GMT+09:00 Jean-Philippe ANDRÉ <j...@videolan.org>: > jpeg pushed a commit to branch master. > > http://git.enlightenment.org/core/efl.git/commit/?id= > c4769ff8989bab2b745017b843f073e5737e91e0 > > commit c4769ff8989bab2b745017b843f073e5737e91e0 > Author: Jean-Philippe Andre <jp.an...@samsung.com> > Date: Fri Jul 14 15:57:36 2017 +0900 > > eo: Add debug_name read-only property to ease debugging > > This will include the following information, by default: > - class name > - whether the class is an override > - eo id (pointer) > - refcount > - name if one was set (Efl.Object property) > > This also supports classes, which is why it's an EAPI in eo.c > and not only a method of Efl.Object > > This can be overriden by subclasses using the empty method > Efl.Object.debug_name_override.get > > If the function is overriden, then the returned string is used > as is and so it is left to the subclass to include all the > necessary information (as above). This can easily be achieved > by calling efl_debug_name_get(efl_super()) and then concatenating > the strings. > > Think of this function as something like Java's toString(), but > only for debugging (i.e. a string class should not just return > its string value). > > @feature > --- > src/lib/eo/Eo.h | 17 ++++++++++++ > src/lib/eo/efl_object.eo | 10 +++++++ > src/lib/eo/eo.c | 61 ++++++++++++++++++++++++++++++ > +++++++++++ > src/lib/eo/eo_base_class.c | 6 ++++ > src/lib/eo/eo_ptr_indirection.h | 2 +- > 5 files changed, 95 insertions(+), 1 deletion(-) > > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h > index 44610e410c..16617e9dfd 100644 > --- a/src/lib/eo/Eo.h > +++ b/src/lib/eo/Eo.h > @@ -691,6 +691,23 @@ 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 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 > + * > + * Note that subclasses can override Efl.Object "debug_name_override" to > + * provide more meaningful debug strings. The standard format includes the > + * class name, the object ID (this @p obj_id), the reference count and > + * optionally the object name (as defined by Efl.Object.name). > + * > + * This might return a temporary string, as created by eina_slstr, which > means > + * that a main loop should probably be running. > + * > + * @since 1.21 > + */ > +EAPI const char *efl_debug_name_get(const Eo *obj_id); > + > +/** > * @} > */ > > diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo > index 33188756f5..31861a61c9 100644 > --- a/src/lib/eo/efl_object.eo > +++ b/src/lib/eo/efl_object.eo > @@ -81,6 +81,16 @@ abstract Efl.Object () > comment: string @nullable; [[The comment]] > } > } > + @property debug_name_override { > + [[ A read-only name for this object used for debugging. > + > + @since 1.21 > + ]] > + get {} > + values { > + name: string; [[A name including class name and object name.]] > + } > + } > @property event_global_freeze_count @class { > get { > [[Return freeze events of object. > diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c > index 50ddddd8de..72db1dd0a9 100644 > --- a/src/lib/eo/eo.c > +++ b/src/lib/eo/eo.c > @@ -2476,6 +2476,67 @@ err: > return EINA_FALSE; > } > > +EAPI const char * > +efl_debug_name_get(const Eo *obj_id) > +{ > + const char *override = ""; > + const char *name, *clsname, *ret; > + > + if (!obj_id) return "(null)"; > + > + if (_eo_is_a_class(obj_id)) > + { > + const char *clstype; > + > + EO_CLASS_POINTER(obj_id, klass); > + if (!klass || !klass->desc) > + return eina_slstr_printf("Invalid_Class_ID(invalid)@%p", > obj_id); > + > + switch (klass->desc->type) > + { > + case EFL_CLASS_TYPE_REGULAR: clstype = "regular"; break; > + case EFL_CLASS_TYPE_REGULAR_NO_INSTANT: clstype = "abstract"; > break; > + case EFL_CLASS_TYPE_INTERFACE: clstype = "interface"; break; > + case EFL_CLASS_TYPE_MIXIN: clstype = "mixin"; break; > + default: clstype = "invalid"; break; > + } > + > + return eina_slstr_printf("%s(%s)@%p", klass->desc->name, clstype, > obj_id); > + } > + > + EO_OBJ_POINTER(obj_id, obj); > + if (!obj) return eina_slstr_printf("Invalid_Object_ID@%p", obj_id); > + > + if (!obj->cur_klass) > + { > + ret = efl_debug_name_override_get(obj_id); > + if (ret) goto end; > + } > + else > + { > + if (obj->super) > + ret = efl_debug_name_override_get(efl_super(obj_id, (Efl_Class > *) obj->cur_klass->header.id)); > + else > + ret = efl_debug_name_override_get(efl_cast(obj_id, (Efl_Class > *) obj->cur_klass->header.id)); > + obj->super = EINA_FALSE; > + obj->cur_klass = NULL; > + if (ret) goto end; > + } > + > + name = efl_name_get(obj_id); > + clsname = obj->klass->desc->name; > + if (_obj_is_override(obj)) override = "(override)"; > + > + if (name) > + ret = eina_slstr_printf("%s%s@%p[%d]:'%s'", clsname, override, > obj_id, (int) obj->refcount, name); > + else > + ret = eina_slstr_printf("%s%s@%p[%d]", clsname, override, obj_id, > (int) obj->refcount); > + > +end: > + EO_OBJ_DONE(obj_id); > + return ret; > +} > + > EAPI int > efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const > Efl_Callback_Array_Item *b) > { > diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c > index 6d05aed81d..ceea2261bb 100644 > --- a/src/lib/eo/eo_base_class.c > +++ b/src/lib/eo/eo_base_class.c > @@ -572,6 +572,12 @@ _efl_object_comment_get(Eo *obj EINA_UNUSED, > Efl_Object_Data *pd) > return pd->ext->comment; > } > > +EOLIAN static const char * > +_efl_object_debug_name_override_get(Eo *obj_id EINA_UNUSED, > Efl_Object_Data *pd EINA_UNUSED) > +{ > + return NULL; > +} > + > EOLIAN static void > _efl_object_del(const Eo *obj, Efl_Object_Data *pd EINA_UNUSED) > { > diff --git a/src/lib/eo/eo_ptr_indirection.h b/src/lib/eo/eo_ptr_ > indirection.h > index c0aaff8089..9cde5ba0c2 100644 > --- a/src/lib/eo/eo_ptr_indirection.h > +++ b/src/lib/eo/eo_ptr_indirection.h > @@ -69,7 +69,7 @@ void _eo_pointer_error(const Eo *obj_id, const char > *func_name, const char *file > #define EO_CLASS_POINTER(klass_id, klass) \ > _Efl_Class *klass; \ > do { \ > - klass = _eo_class_pointer_get(klass_id, __FUNCTION__, __FILE__, > __LINE__); \ > + klass = _eo_class_pointer_get(klass_id); \ > } while (0) > > #define EO_CLASS_POINTER_PROXY(klass_id, klass) \ > > -- > > > -- Jean-Philippe André ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel