Eo: eo_base's data_*->key_data_*.

This commit is contained in:
Tom Hacohen 2014-04-02 11:42:00 +01:00
parent 1866909ba1
commit 374af9b9ca
14 changed files with 68 additions and 68 deletions

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_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
} else if (!strncmp(val, "duration=", 9)) {
eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9])));
}

View File

@ -76,7 +76,7 @@ static inline Evas_Object *
eo_evas_object_get(const Eo *obj)
{
void *data;
eo_do((Eo *) obj, eo_base_data_get(EXEVAS_OBJ_STR, &data));
eo_do((Eo *) obj, eo_key_data_get(EXEVAS_OBJ_STR, &data));
return data;
}
@ -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_base_data_set(EXEVAS_OBJ_STR, evas_obj, NULL));
eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj, NULL));
}
#endif

View File

@ -110,7 +110,7 @@ class Ecore_Audio (Eo_Base)
params {
Ecore_Audio_Vio *vio; /*The @ref Ecore_Audio_Vio struct with the function callbacks*/
void *data; /*User data to pass to the VIO functions*/
eo_base_data_free_func free_func; /*This function takes care to clean up @ref data when he VIO is destroyed. NULL means do nothing.*/
eo_key_data_free_func free_func; /*This function takes care to clean up @ref data when he VIO is destroyed. NULL means do nothing.*/
}
}
}

View File

@ -3,10 +3,10 @@ class Ecore_Audio_In_Tone (Ecore_Audio_In)
eo_prefix: ecore_audio_obj_in_tone;
implements {
Eo_Base::constructor;
Eo_Base::data_set;
Eo_Base::data_get;
Eo_Base::key_data_set;
Eo_Base::key_data_get;
Ecore_Audio_In::length::set;
Ecore_Audio_In::seek;
Ecore_Audio_In::read_internal;
}
}
}

View File

@ -264,7 +264,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
{
in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
eo_do(in, ecore_audio_obj_name_set("tone"));
eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL));
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

@ -942,10 +942,10 @@ EAPI const Eo_Class *eo_class_class_get(void);
EAPI const Eo_Class *eo_base_class_get(void);
/**
* @typedef eo_base_data_free_func
* @typedef eo_key_data_free_func
* Data free func prototype.
*/
typedef void (*eo_base_data_free_func)(void *);
typedef void (*eo_key_data_free_func)(void *);
/**
* @brief Set generic data to object.
@ -953,20 +953,20 @@ typedef void (*eo_base_data_free_func)(void *);
* @param[in] data the data to set.
* @param[in] free_func the func to free data with (NULL means "do nothing").
*
* @see #eo_base_data_get
* @see #eo_base_data_del
* @see #eo_key_data_get
* @see #eo_key_data_del
*/
EAPI void eo_base_data_set(const char *key, const void *data, eo_base_data_free_func free_func);
EAPI void eo_key_data_set(const char *key, const void *data, eo_key_data_free_func free_func);
/**
* @brief Get generic data from object.
* @param[in] key the key associated with the data
* @param[out] data the data for the key
*
* @see #eo_base_data_set
* @see #eo_base_data_del
* @see #eo_key_data_set
* @see #eo_key_data_del
*/
EAPI void *eo_base_data_get(const char *key);
EAPI void *eo_key_data_get(const char *key);
/**
* @brief Get dbg information from the object.
@ -978,10 +978,10 @@ EAPI void eo_dbg_info_get(Eo_Dbg_Info *root_node);
* @brief Del generic data from object.
* @param[in] key the key associated with the data
*
* @see #eo_base_data_set
* @see #eo_base_data_get
* @see #eo_key_data_set
* @see #eo_key_data_get
*/
EAPI void eo_base_data_del(const char *key);
EAPI void eo_key_data_del(const char *key);
/**
* @brief Set the parent of an object

View File

@ -31,7 +31,7 @@ typedef struct
EINA_INLIST;
Eina_Stringshare *key;
void *data;
eo_base_data_free_func free_func;
eo_key_data_free_func free_func;
} Eo_Generic_Data_Node;
static void
@ -60,7 +60,7 @@ _eo_generic_data_del_all(Private_Data *pd)
static void
_data_set(Eo *obj, void *class_data,
const char *key, const void *data, eo_base_data_free_func free_func)
const char *key, const void *data, eo_key_data_free_func free_func)
{
Private_Data *pd = class_data;
@ -68,7 +68,7 @@ _data_set(Eo *obj, void *class_data,
if (!key) return;
eo_do(obj, eo_base_data_del(key); );
eo_do(obj, eo_key_data_del(key); );
node = malloc(sizeof(Eo_Generic_Data_Node));
if (!node) return;
@ -78,8 +78,8 @@ _data_set(Eo *obj, void *class_data,
pd->generic_data = eina_inlist_prepend(pd->generic_data,
EINA_INLIST_GET(node));
}
EAPI EO_VOID_FUNC_BODYV(eo_base_data_set, EO_FUNC_CALL(key, data, free_func),
const char *key, const void *data, eo_base_data_free_func free_func);
EAPI EO_VOID_FUNC_BODYV(eo_key_data_set, EO_FUNC_CALL(key, data, free_func),
const char *key, const void *data, eo_key_data_free_func free_func);
static void *
_data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key)
@ -102,7 +102,7 @@ _data_get(Eo *obj EINA_UNUSED, void *class_data, const char *key)
return NULL;
}
EAPI EO_FUNC_BODYV(eo_base_data_get, void*, NULL, EO_FUNC_CALL(key), const char *key);
EAPI EO_FUNC_BODYV(eo_key_data_get, void*, NULL, EO_FUNC_CALL(key), const char *key);
static void
_parent_set(Eo *obj, void *class_data, Eo *parent_id)
@ -289,7 +289,7 @@ _data_del(Eo *obj EINA_UNUSED, void *class_data, const char *key)
}
}
}
EAPI EO_VOID_FUNC_BODYV(eo_base_data_del, EO_FUNC_CALL(key), const char *key);
EAPI EO_VOID_FUNC_BODYV(eo_key_data_del, EO_FUNC_CALL(key), const char *key);
/* Weak reference. */
@ -961,9 +961,9 @@ static Eo_Op_Description op_descs [] = {
EO_OP_FUNC(eo_parent_set, _parent_set, "Set parent."),
EO_OP_FUNC(eo_parent_get, _parent_get, "Get parent."),
EO_OP_FUNC(eo_children_iterator_new, _children_iterator_new, "Get Children Iterator."),
EO_OP_FUNC(eo_base_data_set, _data_set, "Set data for key."),
EO_OP_FUNC(eo_base_data_get, _data_get, "Get data for key."),
EO_OP_FUNC(eo_base_data_del, _data_del, "Del key."),
EO_OP_FUNC(eo_key_data_set, _data_set, "Set data for key."),
EO_OP_FUNC(eo_key_data_get, _data_get, "Get data for key."),
EO_OP_FUNC(eo_key_data_del, _data_del, "Del key."),
EO_OP_FUNC(eo_wref_add, _wref_add, "Add a weak ref to the object."),
EO_OP_FUNC(eo_wref_del, _wref_del, "Delete the weak ref."),
EO_OP_FUNC(eo_event_callback_priority_add, _ev_cb_priority_add, "Add an event callback with a priority."),

View File

@ -82,7 +82,7 @@ Should not be used with #eo_do. Only use it with #eo_do_super. */
params {
@in const char* key; /*@ the key associated with the data */
@in const void* data; /*@ the data to set */
@in eo_base_data_free_func free_func; /*@ the func to free data with (NULL means */
@in eo_key_data_free_func free_func; /*@ the func to free data with (NULL means */
}
}
key_data_get {

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_base_data_set(key, data, NULL));
eo_do(obj, eo_key_data_set(key, data, NULL));
}
EAPI void *
@ -18,7 +18,7 @@ evas_object_data_get(const Evas_Object *obj, const char *key)
return NULL;
MAGIC_CHECK_END();
void *data = NULL;
eo_do((Evas_Object *)obj, data = eo_base_data_get(key));
eo_do((Evas_Object *)obj, data = eo_key_data_get(key));
return data;
}
@ -29,6 +29,6 @@ evas_object_data_del(Evas_Object *obj, const char *key)
return NULL;
MAGIC_CHECK_END();
void *data = NULL;
eo_do(obj, data = eo_base_data_get(key), eo_base_data_del(key));
eo_do(obj, data = eo_key_data_get(key), eo_key_data_del(key));
return data;
}

View File

@ -116,7 +116,7 @@ START_TEST(ecore_test_ecore_audio_cleanup)
in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
fail_if(!in);
eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, ecore_audio_obj_in_length_set(2));
out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
@ -166,17 +166,17 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
eo_do(in, ecore_audio_obj_in_remaining_get(&len));
fail_if(len != 2.5);
eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq));
eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq));
fail_if(freq != 1000);
freq = 2000;
eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq));
eo_do(in, eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq));
fail_if(freq != 2000);
eo_do(in, eo_base_data_set("foo", "bar", NULL));
eo_do(in, eo_base_data_get("foo", (void **)&tmp));
eo_do(in, eo_key_data_set("foo", "bar", NULL));
eo_do(in, eo_key_data_get("foo", (void **)&tmp));
ck_assert_str_eq(tmp, "bar");
eo_do(in, ecore_audio_obj_in_seek(5.0, SEEK_SET, &len));

View File

@ -31,7 +31,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
fail_if(eo_composite_is(obj));
fail_if(!eo_composite_is(simple));
eo_do(obj, eo_base_data_set("simple-obj", simple, NULL));
eo_do(obj, eo_key_data_set("simple-obj", simple, NULL));
eo_unref(simple);
}

View File

@ -45,7 +45,7 @@ main(int argc, char *argv[])
/* disable the callback forwarder, and fail if it's still called. */
Eo *simple = NULL;
eo_do(obj, simple = eo_base_data_get("simple-obj"));
eo_do(obj, simple = eo_key_data_get("simple-obj"));
eo_ref(simple);
eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, 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_base_data_set("cb_count", (intptr_t) 0, NULL));
eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0, NULL));
}
EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a);

View File

@ -519,56 +519,56 @@ START_TEST(eo_generic_data)
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
void *data = NULL;
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
eo_do(obj, data = eo_base_data_get("test1"));
eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(1 != (intptr_t) data);
eo_do(obj, eo_base_data_del("test1"));
eo_do(obj, data = eo_base_data_get("test1"));
eo_do(obj, eo_key_data_del("test1"));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(data);
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL));
eo_do(obj, data = eo_base_data_get("test1"));
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, data = eo_key_data_get("test1"));
fail_if(1 != (intptr_t) data);
eo_do(obj, data = eo_base_data_get("test2"));
eo_do(obj, data = eo_key_data_get("test2"));
fail_if(2 != (intptr_t) data);
eo_do(obj, data = eo_base_data_get("test2"));
eo_do(obj, data = eo_key_data_get("test2"));
fail_if(2 != (intptr_t) data);
eo_do(obj, eo_base_data_del("test2"));
eo_do(obj, data = eo_base_data_get("test2"));
eo_do(obj, eo_key_data_del("test2"));
eo_do(obj, data = eo_key_data_get("test2"));
fail_if(data);
eo_do(obj, data = eo_base_data_get("test1"));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(1 != (intptr_t) data);
eo_do(obj, eo_base_data_del("test1"));
eo_do(obj, data = eo_base_data_get("test1"));
eo_do(obj, eo_key_data_del("test1"));
eo_do(obj, data = eo_key_data_get("test1"));
fail_if(data);
int a = 0;
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
eo_do(obj, data = eo_base_data_get("test3"));
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_base_data_get("test3"));
eo_do(obj, eo_base_data_del("test3"));
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_base_data_set("test3", &a, _fake_free_func));
eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func));
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_base_data_set(NULL, &a, _fake_free_func));
eo_do(obj, data = eo_base_data_get(NULL));
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_base_data_del(NULL));
eo_do(obj, eo_key_data_del(NULL));
a = 0;
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
eo_do(obj, eo_base_data_set("test3", NULL, NULL));
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_base_data_set("test3", &a, _fake_free_func));
eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
eo_unref(obj);
fail_if(a != 2);