summaryrefslogtreecommitdiff
path: root/src/lib/eo
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-07-21 15:24:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-04 10:24:03 +0900
commit999dbd9764426890c0e11841358f9219082b89b2 (patch)
tree2d43a51df243061ee5e7f506c0dbc38410cc304f /src/lib/eo
parent569ad0bac4590e8a18800741ea2345174c3683f3 (diff)
eo debug name: Use strbuf instead of slstr
This should be a little bit more efficient, even if more "risky" in terms of leaks. The final API still looks exactly the same.
Diffstat (limited to 'src/lib/eo')
-rw-r--r--src/lib/eo/efl_object.eo21
-rw-r--r--src/lib/eo/eina_types.eot1
-rw-r--r--src/lib/eo/eo.c33
-rw-r--r--src/lib/eo/eo_base_class.c6
4 files changed, 36 insertions, 25 deletions
diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo
index 31861a61c9..f31606f293 100644
--- a/src/lib/eo/efl_object.eo
+++ b/src/lib/eo/efl_object.eo
@@ -81,15 +81,26 @@ abstract Efl.Object ()
81 comment: string @nullable; [[The comment]] 81 comment: string @nullable; [[The comment]]
82 } 82 }
83 } 83 }
84 @property debug_name_override { 84 debug_name_override {
85 [[ A read-only name for this object used for debugging. 85 [[ Build a read-only name for this object used for debugging.
86
87 Multiple calls using efl_super() can be chained in order to build
88 the entire debug name, from parent to child classes. In C the usual
89 way to build the string is as follows:
90
91 sb = efl_debug_name_override(efl_super(obj, MY_CLASS), sb);
92 eina_strbuf_append_printf(sb, "new_information");
93 return sb;
94
95 The receiving function should always either free the strbuf or
96 returning it back to the caller, as ownership is transferred.
86 97
87 @since 1.21 98 @since 1.21
88 ]] 99 ]]
89 get {} 100 params {
90 values { 101 @in sb: own(ptr(Eina.Strbuf)); [[A string buffer, must not be $null.]]
91 name: string; [[A name including class name and object name.]]
92 } 102 }
103 return: own(ptr(Eina.Strbuf)); [[Should not be $null, may be $sb.]]
93 } 104 }
94 @property event_global_freeze_count @class { 105 @property event_global_freeze_count @class {
95 get { 106 get {
diff --git a/src/lib/eo/eina_types.eot b/src/lib/eo/eina_types.eot
index dce0e65884..40fbbf2df8 100644
--- a/src/lib/eo/eina_types.eot
+++ b/src/lib/eo/eina_types.eot
@@ -47,6 +47,7 @@ enum @extern Eina.Xattr.Flags {
47type @extern Eina.Error: int; [[Eina error type]] 47type @extern Eina.Error: int; [[Eina error type]]
48 48
49struct @extern @free(eina_binbuf_free) Eina.Binbuf; [[Eina binbuf data structure]] 49struct @extern @free(eina_binbuf_free) Eina.Binbuf; [[Eina binbuf data structure]]
50struct @extern @free(eina_strbuf_free) Eina.Strbuf; [[Eina strbuf data structure]]
50 51
51struct @extern Eina.Slice { 52struct @extern Eina.Slice {
52 [[A linear, read-only, memory segment]] 53 [[A linear, read-only, memory segment]]
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 72db1dd0a9..a567a00d44 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -2480,7 +2480,8 @@ EAPI const char *
2480efl_debug_name_get(const Eo *obj_id) 2480efl_debug_name_get(const Eo *obj_id)
2481{ 2481{
2482 const char *override = ""; 2482 const char *override = "";
2483 const char *name, *clsname, *ret; 2483 const char *name, *clsname;
2484 Eina_Strbuf *sb;
2484 2485
2485 if (!obj_id) return "(null)"; 2486 if (!obj_id) return "(null)";
2486 2487
@@ -2507,34 +2508,32 @@ efl_debug_name_get(const Eo *obj_id)
2507 EO_OBJ_POINTER(obj_id, obj); 2508 EO_OBJ_POINTER(obj_id, obj);
2508 if (!obj) return eina_slstr_printf("Invalid_Object_ID@%p", obj_id); 2509 if (!obj) return eina_slstr_printf("Invalid_Object_ID@%p", obj_id);
2509 2510
2511 sb = eina_strbuf_new();
2512 name = efl_name_get(obj_id);
2513 clsname = obj->klass->desc->name;
2514 if (_obj_is_override(obj)) override = "(override)";
2515
2516 if (name)
2517 eina_strbuf_append_printf(sb, "%s%s@%p[%d]:'%s'", clsname, override, obj_id, (int) obj->refcount, name);
2518 else
2519 eina_strbuf_append_printf(sb, "%s%s@%p[%d]", clsname, override, obj_id, (int) obj->refcount);
2520
2510 if (!obj->cur_klass) 2521 if (!obj->cur_klass)
2511 { 2522 {
2512 ret = efl_debug_name_override_get(obj_id); 2523 sb = efl_debug_name_override((Eo *) obj_id, sb);
2513 if (ret) goto end;
2514 } 2524 }
2515 else 2525 else
2516 { 2526 {
2517 if (obj->super) 2527 if (obj->super)
2518 ret = efl_debug_name_override_get(efl_super(obj_id, (Efl_Class *) obj->cur_klass->header.id)); 2528 sb = efl_debug_name_override(efl_super(obj_id, (Efl_Class *) obj->cur_klass->header.id), sb);
2519 else 2529 else
2520 ret = efl_debug_name_override_get(efl_cast(obj_id, (Efl_Class *) obj->cur_klass->header.id)); 2530 sb = efl_debug_name_override(efl_cast(obj_id, (Efl_Class *) obj->cur_klass->header.id), sb);
2521 obj->super = EINA_FALSE; 2531 obj->super = EINA_FALSE;
2522 obj->cur_klass = NULL; 2532 obj->cur_klass = NULL;
2523 if (ret) goto end;
2524 } 2533 }
2525 2534
2526 name = efl_name_get(obj_id);
2527 clsname = obj->klass->desc->name;
2528 if (_obj_is_override(obj)) override = "(override)";
2529
2530 if (name)
2531 ret = eina_slstr_printf("%s%s@%p[%d]:'%s'", clsname, override, obj_id, (int) obj->refcount, name);
2532 else
2533 ret = eina_slstr_printf("%s%s@%p[%d]", clsname, override, obj_id, (int) obj->refcount);
2534
2535end:
2536 EO_OBJ_DONE(obj_id); 2535 EO_OBJ_DONE(obj_id);
2537 return ret; 2536 return eina_slstr_strbuf_new(sb);
2538} 2537}
2539 2538
2540EAPI int 2539EAPI int
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index ceea2261bb..5b3801abb2 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -572,10 +572,10 @@ _efl_object_comment_get(Eo *obj EINA_UNUSED, Efl_Object_Data *pd)
572 return pd->ext->comment; 572 return pd->ext->comment;
573} 573}
574 574
575EOLIAN static const char * 575EOLIAN static Eina_Strbuf *
576_efl_object_debug_name_override_get(Eo *obj_id EINA_UNUSED, Efl_Object_Data *pd EINA_UNUSED) 576_efl_object_debug_name_override(Eo *obj_id EINA_UNUSED, Efl_Object_Data *pd EINA_UNUSED, Eina_Strbuf *sb)
577{ 577{
578 return NULL; 578 return sb;
579} 579}
580 580
581EOLIAN static void 581EOLIAN static void