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
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*
{
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])));
}
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
}
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));
}
}
}
/* 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;
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);
{
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));
/**
* @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 *);
}
}
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 {
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);
}
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;
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));
}
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 *
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);
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");
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;
}
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;
}
}
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"));
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();
}