Eo base: Remove the free_func parameter from key_data_set.

This was not really useful and against the Eolian guidelines.
While I promised I won't break things until the 27th, I was ill
(still am), so I'm giving myself a 1 day pass. :P
This commit is contained in:
Tom Hacohen 2015-05-28 17:47:33 +01:00
parent d0b58aab54
commit 52d998f475
15 changed files with 21 additions and 60 deletions

View File

@ -68,7 +68,7 @@ inline void
base_data_set(const Eo *obj, const char *key, const void *data,
eo_key_data_free_func free_func = NULL)
{
eo_do(obj, eo_key_data_set(key, data, free_func));
eo_do(obj, eo_key_data_set(key, data));
}
inline void*

View File

@ -266,7 +266,7 @@ main(int argc, const char *argv[])
{
if (!strncmp(val, "freq=", 5)) {
freq = atoi(&val[5]);
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
} else if (!strncmp(val, "duration=", 9)) {
eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9])));
}

View File

@ -84,7 +84,7 @@ eo_evas_object_get(const Eo *obj)
static inline void
eo_evas_object_set(Eo *obj, Evas_Object *evas_obj)
{
eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj, NULL));
eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj));
}
#endif

View File

@ -83,14 +83,14 @@ _ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_D
}
EOLIAN static void
_ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_key_data_free_func func)
_ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val)
{
if (!key) return;
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
obj->freq = *(int *)val;
} else {
eo_do_super(eo_obj, MY_CLASS, eo_key_data_set(key, val, func));
eo_do_super(eo_obj, MY_CLASS, eo_key_data_set(key, val));
}
}

View File

@ -303,7 +303,7 @@ _ecore_audio_out_core_audio_ecore_audio_out_input_attach(Eo *obj, Ecore_Audio_Ou
}
/* Keep track of data for deallocation */
eo_do(input, eo_key_data_set("coreaudio_data", helper, NULL));
eo_do(input, eo_key_data_set("coreaudio_data", helper));
/* Start playing */
helper->is_playing = EINA_TRUE;

View File

@ -136,7 +136,7 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, _update_samplerate_cb, eo_obj));
eo_do(in, eo_key_data_set("pulse_data", stream, NULL));
eo_do(in, eo_key_data_set("pulse_data", stream));
pa_stream_set_write_callback(stream, _write_cb, in);

View File

@ -271,7 +271,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
{
in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL);
eo_do(in, ecore_audio_obj_name_set("tone"));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value));
eo_do(in, ecore_audio_obj_in_length_set(duration));
eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL));

View File

@ -891,6 +891,7 @@ EAPI Eina_Bool eo_destructed_is(const Eo *obj);
/**
* @typedef eo_key_data_free_func
* Data free func prototype.
* XXX: DO NOT USE, only here for legacy.
*/
typedef void (*eo_key_data_free_func)(void *);

View File

@ -69,11 +69,11 @@ This function registers the object handle pointed by wref to obj so when obj is
}
}
key_data_set {
/*@ Set generic data to object. */
/*@ Set generic data to object.
The user is in change to free the data. */
params {
@in key: const(char)*; /*@ the key associated with the data */
@in data: const(void)*; /*@ the data to set */
@in free_func: eo_key_data_free_func; /*@ the func to free data with (NULL means */
}
}
key_data_get {

View File

@ -34,15 +34,12 @@ typedef struct
EINA_INLIST;
Eina_Stringshare *key;
void *data;
eo_key_data_free_func free_func;
} Eo_Generic_Data_Node;
static void
_eo_generic_data_node_free(Eo_Generic_Data_Node *node)
{
eina_stringshare_del(node->key);
if (node->free_func)
node->free_func(node->data);
free(node);
}
@ -63,7 +60,7 @@ _eo_generic_data_del_all(Eo_Base_Data *pd)
EOLIAN static void
_eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd,
const char *key, const void *data, eo_key_data_free_func free_func)
const char *key, const void *data)
{
Eo_Generic_Data_Node *node;
@ -75,7 +72,6 @@ _eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd,
if (!node) return;
node->key = eina_stringshare_add(key);
node->data = (void *) data;
node->free_func = free_func;
pd->generic_data = eina_inlist_prepend(pd->generic_data,
EINA_INLIST_GET(node));
}

View File

@ -8,7 +8,7 @@ evas_object_data_set(Evas_Object *obj, const char *key, const void *data)
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
eo_do(obj, eo_key_data_set(key, data, NULL));
eo_do(obj, eo_key_data_set(key, data));
}
EAPI void *

View File

@ -116,7 +116,7 @@ START_TEST(ecore_test_ecore_audio_cleanup)
in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL);
fail_if(!in);
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
eo_do(in, ecore_audio_obj_in_length_set(2));
out = eo_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
@ -170,12 +170,12 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
fail_if(freq != 1000);
freq = 2000;
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
eo_do(in, freq = (intptr_t) eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ));
fail_if(freq != 2000);
eo_do(in, eo_key_data_set("foo", "bar", NULL));
eo_do(in, eo_key_data_set("foo", "bar"));
eo_do(in, tmp = eo_key_data_get("foo"));
ck_assert_str_eq(tmp, "bar");

View File

@ -34,7 +34,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
fail_if(eo_do_ret(obj, tmp, eo_composite_part_is()));
fail_if(!eo_do_ret(simple, tmp, eo_composite_part_is()));
eo_do(obj, eo_key_data_set("simple-obj", simple, NULL));
eo_do(obj, eo_key_data_set("simple-obj", simple));
return obj;
}

View File

@ -68,7 +68,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0, NULL));
eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0));
return obj;
}

View File

@ -547,31 +547,21 @@ START_TEST(eo_weak_reference)
}
END_TEST
static void
_fake_free_func(void *data)
{
if (!data)
return;
int *a = data;
++*a;
}
START_TEST(eo_generic_data)
{
eo_init();
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
void *data = NULL;
eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL));
eo_do(obj, eo_key_data_set("test1", (void *) 1));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(1 != (intptr_t) data);
eo_do(obj, eo_key_data_del("test1"));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(data);
eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL));
eo_do(obj, eo_key_data_set("test2", (void *) 2, NULL));
eo_do(obj, eo_key_data_set("test1", (void *) 1));
eo_do(obj, eo_key_data_set("test2", (void *) 2));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(1 != (intptr_t) data);
eo_do(obj, data = eo_key_data_get("test2"));
@ -589,33 +579,7 @@ START_TEST(eo_generic_data)
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(data);
int a = 0;
eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
eo_do(obj, data = eo_key_data_get("test3"));
fail_if(&a != data);
eo_do(obj, eo_key_data_get("test3"));
eo_do(obj, eo_key_data_del("test3"));
fail_if(a != 1);
a = 0;
eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
eo_do(obj, eo_key_data_set("test3", NULL, _fake_free_func));
fail_if(a != 1);
a = 0;
data = (void *) 123;
eo_do(obj, eo_key_data_set(NULL, &a, _fake_free_func));
eo_do(obj, data = eo_key_data_get(NULL));
fail_if(data);
eo_do(obj, eo_key_data_del(NULL));
a = 0;
eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
eo_do(obj, eo_key_data_set("test3", NULL, NULL));
fail_if(a != 1);
eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
eo_unref(obj);
fail_if(a != 2);
eo_shutdown();
}