diff --git a/src/bindings/eo_cxx/eo_ops.hh b/src/bindings/eo_cxx/eo_ops.hh index 3629e77fcf..9006e848e3 100644 --- a/src/bindings/eo_cxx/eo_ops.hh +++ b/src/bindings/eo_cxx/eo_ops.hh @@ -87,7 +87,7 @@ base_data_get(const Eo *obj, const char *key) inline void base_data_del(Eo *obj, const char *key) { - eo_key_del(obj, key); + eo_key_data_set(obj, key, NULL); } inline void diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua index 0419f829e6..bebe733853 100644 --- a/src/bindings/luajit/eo.lua +++ b/src/bindings/luajit/eo.lua @@ -101,7 +101,6 @@ ffi.cdef [[ void eo_key_data_set(const char *key, const void *data, eo_key_data_free_func free_func); void *eo_key_data_get(const char *key); - void eo_key_del(const char *key); Eina_Iterator *eo_children_iterator_new(void); diff --git a/src/lib/ecore_audio/ecore_audio_in_tone.eo b/src/lib/ecore_audio/ecore_audio_in_tone.eo index ec2da4abf3..768b491644 100644 --- a/src/lib/ecore_audio/ecore_audio_in_tone.eo +++ b/src/lib/ecore_audio/ecore_audio_in_tone.eo @@ -4,8 +4,7 @@ class Ecore.Audio.In.Tone (Ecore.Audio.In) eo_prefix: ecore_audio_obj_in_tone; implements { Eo.Base.constructor; - Eo.Base.key_data_set; - Eo.Base.key_data_get; + Eo.Base.key_data; Ecore.Audio.In.length.set; Ecore.Audio.In.seek; Ecore.Audio.In.read_internal; diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c index 04747dcc3e..0ec1573084 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c @@ -95,8 +95,8 @@ _ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data * } -EOLIAN static void* -_ecore_audio_in_tone_eo_base_key_data_get(const Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) +EOLIAN static void * +_ecore_audio_in_tone_eo_base_key_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) { if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { return (void *) (intptr_t) obj->freq; diff --git a/src/lib/elementary/efl_ui_grid.c b/src/lib/elementary/efl_ui_grid.c index d7c3fbbd28..3c3c2a6a2b 100644 --- a/src/lib/elementary/efl_ui_grid.c +++ b/src/lib/elementary/efl_ui_grid.c @@ -575,7 +575,7 @@ end: pd->items = (Grid_Item *) eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi)); pd->count--; - eo_key_del(subobj, GRID_ITEM_KEY); + eo_key_data_set(subobj, GRID_ITEM_KEY, NULL); free(gi); } diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c index 8a7e834631..6f626ab16e 100644 --- a/src/lib/elementary/elm_cnp.c +++ b/src/lib/elementary/elm_cnp.c @@ -4382,7 +4382,7 @@ _local_elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format, if (!dropable->cbs_list) { drops = eina_list_remove(drops, dropable); - eo_key_del(obj, "__elm_dropable"); + eo_key_data_set(obj, "__elm_dropable", NULL); free(dropable); dropable = NULL; evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, diff --git a/src/lib/elementary/elm_layout_pack.c b/src/lib/elementary/elm_layout_pack.c index bbab226635..b8efa896f6 100644 --- a/src/lib/elementary/elm_layout_pack.c +++ b/src/lib/elementary/elm_layout_pack.c @@ -91,7 +91,7 @@ _efl_ui_layout_internal_box_eo_base_finalize(Eo *obj, Efl_Ui_Layout_Box_Data *pd EOLIAN static void _efl_ui_layout_internal_box_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd) { - eo_key_del(pd->pack, DATA_KEY); + eo_key_data_set(pd->pack, DATA_KEY, NULL); eo_destructor(eo_super(obj, BOX_CLASS)); } @@ -291,7 +291,7 @@ _efl_ui_layout_internal_table_eo_base_finalize(Eo *obj EINA_UNUSED, Efl_Ui_Layou EOLIAN static void _efl_ui_layout_internal_table_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd) { - eo_key_del(pd->pack, DATA_KEY); + eo_key_data_set(pd->pack, DATA_KEY, NULL); eina_stringshare_del(pd->part); eo_destructor(eo_super(obj, TABLE_CLASS)); } diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo index 6a22b2a3ba..c728186260 100644 --- a/src/lib/eo/eo_base.eo +++ b/src/lib/eo/eo_base.eo @@ -200,73 +200,66 @@ abstract Eo.Base () @in wref: Eo.Base **; } } - key_data_set { - [[Set generic data to object. + @property key_data { + [[Generic data with string key on an object. - The user is in change to free the data. + The user is in charge of freeing the data. ]] - params { - @in key: const(char)*; [[the key associated with the data]] - @in data: const(void)*; [[the data to set]] + keys { + key: const(char) *; [[the key associated with the data]] + } + set { + values { + data: const(void) *; [[the data to set]] + } + } + get { + values { + data: void *; [[the data to set]] + } } } - key_data_get @const { - [[Get generic data from object.]] - params { - @in key: const(char)*; [[the key associated with the data]] - } - return: void *; [[the data for the key]] - } - key_del { - [[Del generic data from object.]] - params { - @in key: const(char)*; [[the key associated with the data]] - } - } - key_obj_set { - [[Set generic object reference to object. + @property key_obj { + [[Generic object reference with string key to object. The object will be automatically ref'd when set and unref'd when replaced or deleted or referring object is deleted. If the referenced object is deleted then the key is deleted automatically. - This is the same key store used by key_data_set etc. so keys + This is the same key store used by key_data and key_value so keys are shared and can store only one thing ]] - params { - @in key: const(char)*; [[the key associated with the object ref]] - @in objdata: Eo.Base *; [[the object to set]] + keys { + key: const(char) *; [[the key associated with the object ref]] + } + set { + values { + objdata: const(Eo.Base) *; [[the object to set]] + } + } + get { + values { + objdata: Eo.Base *; [[the object to set]] + } } } - key_obj_get @const { - [[Get generic object reference from object.]] - params { - @in key: const(char)*; [[the key associated with the object ref]] - } - return: Eo.Base *; [[the object reference for the key]] - } - key_value_set { - [[Set value on the object. + @property key_value { + [[Value on with string key on the object. This stores the value with the given string key on the object and it will be freed when replaced or deleted or the referring object is deleted. - This is the same key store used by key_data_set and key_obj_set - etc. so keys are shared and can store only one thing + This is the same key store used by key_data and key_obj so keys + are shared and can store only one thing ]] - params { - @in key: const(char)*; [[the key associated with the value]] - @in value: Eina.Value *; [[the value to set]] + keys { + key: const(char)*; [[the key associated with the value]] } - } - key_value_get @const { - [[Get generic value from object.]] - params { - @in key: const(char)*; [[the key associated with the value]] + values { + value: Eina.Value *; [[the value to set]] } - return: Eina.Value *; [[the value for the key]] } event_thaw { [[thaw events of object. diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index f8785c3b54..fe60cc0e21 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -126,14 +126,12 @@ _eo_generic_data_del_all(Eo *obj EINA_UNUSED, Eo_Base_Data *pd) } } -EOLIAN static void -_eo_base_key_del(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key) +static void +_eo_key_generic_del(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key) { Eo_Generic_Data_Node *node; Eo_Base_Extension *ext = pd->ext; - if (!key) return; - if (!ext) return; EINA_INLIST_FOREACH(ext->generic_data, node) { if (!strcmp(node->key, key)) @@ -148,7 +146,7 @@ _eo_base_key_del(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key) /* Return TRUE if the object was newly added. */ static Eina_Bool -_key_generic_set(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, const void *data, Eo_Generic_Data_Node_Type d_type) +_key_generic_set(const Eo *obj, Eo_Base_Data *pd, const char *key, const void *data, Eo_Generic_Data_Node_Type d_type) { Eo_Generic_Data_Node *node; Eo_Base_Extension *ext = pd->ext; @@ -156,6 +154,11 @@ _key_generic_set(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, c if (!key) return EINA_FALSE; if (ext) { + if (!data) + { + _eo_key_generic_del(obj, pd, key); + return EINA_TRUE; + } EINA_INLIST_FOREACH(ext->generic_data, node) { if (!strcmp(node->key, key)) @@ -223,20 +226,20 @@ _eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd, const char *key, const void *da } EOLIAN static void * -_eo_base_key_data_get(const Eo *obj, Eo_Base_Data *pd, const char *key) +_eo_base_key_data_get(Eo *obj, Eo_Base_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_PTR); } EOLIAN static void -_eo_base_key_obj_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, Eo *objdata) +_eo_base_key_obj_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, const Eo *objdata) { if (_key_generic_set(obj, pd, key, objdata, DATA_OBJ)) eo_ref(objdata); } EOLIAN static Eo * -_eo_base_key_obj_get(const Eo *obj, Eo_Base_Data *pd, const char *key) +_eo_base_key_obj_get(Eo *obj, Eo_Base_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_OBJ); } @@ -248,7 +251,7 @@ _eo_base_key_value_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, E } EOLIAN static Eina_Value * -_eo_base_key_value_get(const Eo *obj, Eo_Base_Data *pd, const char *key) +_eo_base_key_value_get(Eo *obj, Eo_Base_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_VAL); } diff --git a/src/lib/evas/canvas/evas_data.c b/src/lib/evas/canvas/evas_data.c index ba4e113f66..b332e1669b 100644 --- a/src/lib/evas/canvas/evas_data.c +++ b/src/lib/evas/canvas/evas_data.c @@ -30,6 +30,6 @@ evas_object_data_del(Evas_Object *obj, const char *key) MAGIC_CHECK_END(); void *data = NULL; data = eo_key_data_get(obj, key); - eo_key_del(obj, key); + eo_key_data_set(obj, key, NULL); return data; } diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index b2de49d2be..b43e510e30 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -620,7 +620,7 @@ START_TEST(eo_generic_data) eo_key_data_set(obj, "test1", (void *) 1); data = eo_key_data_get(obj, "test1"); fail_if(1 != (intptr_t) data); - eo_key_del(obj, "test1"); + eo_key_data_set(obj, "test1", NULL); data = eo_key_data_get(obj, "test1"); fail_if(data); @@ -633,13 +633,13 @@ START_TEST(eo_generic_data) data = eo_key_data_get(obj, "test2"); fail_if(2 != (intptr_t) data); - eo_key_del(obj, "test2"); + eo_key_data_set(obj, "test2", NULL); data = eo_key_data_get(obj, "test2"); fail_if(data); data = eo_key_data_get(obj, "test1"); fail_if(1 != (intptr_t) data); - eo_key_del(obj, "test1"); + eo_key_data_set(obj, "test1", NULL); data = eo_key_data_get(obj, "test1"); fail_if(data); @@ -648,7 +648,7 @@ START_TEST(eo_generic_data) eo_key_obj_set(obj, "test1", obj2); objtmp = eo_key_obj_get(obj, "test1"); fail_if(obj2 != objtmp); - eo_key_del(obj, "test1"); + eo_key_obj_set(obj, "test1", NULL); objtmp = eo_key_obj_get(obj, "test1"); fail_if(objtmp); @@ -661,13 +661,13 @@ START_TEST(eo_generic_data) data = eo_key_obj_get(obj, "test2"); fail_if(obj3 != objtmp); - eo_key_del(obj, "test2"); + eo_key_obj_set(obj, "test2", NULL); objtmp = eo_key_obj_get(obj, "test2"); fail_if(objtmp); objtmp = eo_key_obj_get(obj, "test1"); fail_if(obj2 != objtmp); - eo_key_del(obj, "test1"); + eo_key_obj_set(obj, "test1", NULL); objtmp = eo_key_obj_get(obj, "test1"); fail_if(objtmp); @@ -680,10 +680,10 @@ START_TEST(eo_generic_data) value2 = eo_key_value_get(obj, "value1"); fail_if(value != value2); - eo_key_del(obj, "value1"); + eo_key_value_set(obj, "value1", NULL); value2 = eo_key_value_get(obj, "value1"); fail_if(value2 != NULL); - eo_key_del(obj, "value1"); + eo_key_value_set(obj, "value1", NULL); eo_unref(obj); eo_unref(obj2);