summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-05-28 17:47:33 +0100
committerTom Hacohen <tom@stosb.com>2015-05-28 17:47:59 +0100
commit52d998f475afd1a8cb18e5990aafd7f1c2b5c41e (patch)
treea392364afb9663810e94776ebde6dc99a52cf2f2
parentd0b58aab54131eb71be6d3289fd11a78b8c9adf5 (diff)
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
-rw-r--r--src/bindings/eo_cxx/eo_ops.hh2
-rw-r--r--src/examples/ecore/ecore_audio_playback.c2
-rw-r--r--src/examples/eo/evas/evas_evas_obj.h2
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in_tone.c4
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_core_audio.c2
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_pulse.c2
-rw-r--r--src/lib/edje/edje_multisense.c2
-rw-r--r--src/lib/eo/Eo.h1
-rw-r--r--src/lib/eo/eo_base.eo4
-rw-r--r--src/lib/eo/eo_base_class.c6
-rw-r--r--src/lib/evas/canvas/evas_data.c2
-rw-r--r--src/tests/ecore/ecore_test_ecore_audio.c6
-rw-r--r--src/tests/eo/composite_objects/composite_objects_comp.c2
-rw-r--r--src/tests/eo/signals/signals_simple.c2
-rw-r--r--src/tests/eo/suite/eo_test_general.c42
15 files changed, 21 insertions, 60 deletions
diff --git a/src/bindings/eo_cxx/eo_ops.hh b/src/bindings/eo_cxx/eo_ops.hh
index 94ae7fd..89ed72d 100644
--- a/src/bindings/eo_cxx/eo_ops.hh
+++ b/src/bindings/eo_cxx/eo_ops.hh
@@ -68,7 +68,7 @@ inline void
68base_data_set(const Eo *obj, const char *key, const void *data, 68base_data_set(const Eo *obj, const char *key, const void *data,
69 eo_key_data_free_func free_func = NULL) 69 eo_key_data_free_func free_func = NULL)
70{ 70{
71 eo_do(obj, eo_key_data_set(key, data, free_func)); 71 eo_do(obj, eo_key_data_set(key, data));
72} 72}
73 73
74inline void* 74inline void*
diff --git a/src/examples/ecore/ecore_audio_playback.c b/src/examples/ecore/ecore_audio_playback.c
index efd3036..78c98a3 100644
--- a/src/examples/ecore/ecore_audio_playback.c
+++ b/src/examples/ecore/ecore_audio_playback.c
@@ -266,7 +266,7 @@ main(int argc, const char *argv[])
266 { 266 {
267 if (!strncmp(val, "freq=", 5)) { 267 if (!strncmp(val, "freq=", 5)) {
268 freq = atoi(&val[5]); 268 freq = atoi(&val[5]);
269 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); 269 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
270 } else if (!strncmp(val, "duration=", 9)) { 270 } else if (!strncmp(val, "duration=", 9)) {
271 eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9]))); 271 eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9])));
272 } 272 }
diff --git a/src/examples/eo/evas/evas_evas_obj.h b/src/examples/eo/evas/evas_evas_obj.h
index cda7960..61cf720 100644
--- a/src/examples/eo/evas/evas_evas_obj.h
+++ b/src/examples/eo/evas/evas_evas_obj.h
@@ -84,7 +84,7 @@ eo_evas_object_get(const Eo *obj)
84static inline void 84static inline void
85eo_evas_object_set(Eo *obj, Evas_Object *evas_obj) 85eo_evas_object_set(Eo *obj, Evas_Object *evas_obj)
86{ 86{
87 eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj, NULL)); 87 eo_do(obj, eo_key_data_set(EXEVAS_OBJ_STR, evas_obj));
88} 88}
89 89
90#endif 90#endif
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 ac83b85..2b097f6 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c
@@ -83,14 +83,14 @@ _ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_D
83} 83}
84 84
85EOLIAN static void 85EOLIAN static void
86_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) 86_ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val)
87{ 87{
88 if (!key) return; 88 if (!key) return;
89 89
90 if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { 90 if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
91 obj->freq = *(int *)val; 91 obj->freq = *(int *)val;
92 } else { 92 } else {
93 eo_do_super(eo_obj, MY_CLASS, eo_key_data_set(key, val, func)); 93 eo_do_super(eo_obj, MY_CLASS, eo_key_data_set(key, val));
94 } 94 }
95 95
96} 96}
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_core_audio.c b/src/lib/ecore_audio/ecore_audio_obj_out_core_audio.c
index 7370f18..1d2ead4 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_core_audio.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_core_audio.c
@@ -303,7 +303,7 @@ _ecore_audio_out_core_audio_ecore_audio_out_input_attach(Eo *obj, Ecore_Audio_Ou
303 } 303 }
304 304
305 /* Keep track of data for deallocation */ 305 /* Keep track of data for deallocation */
306 eo_do(input, eo_key_data_set("coreaudio_data", helper, NULL)); 306 eo_do(input, eo_key_data_set("coreaudio_data", helper));
307 307
308 /* Start playing */ 308 /* Start playing */
309 helper->is_playing = EINA_TRUE; 309 helper->is_playing = EINA_TRUE;
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
index fffe4c4..901d9f6 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
@@ -136,7 +136,7 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
136 136
137 eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, _update_samplerate_cb, eo_obj)); 137 eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_SAMPLERATE_CHANGED, _update_samplerate_cb, eo_obj));
138 138
139 eo_do(in, eo_key_data_set("pulse_data", stream, NULL)); 139 eo_do(in, eo_key_data_set("pulse_data", stream));
140 140
141 141
142 pa_stream_set_write_callback(stream, _write_cb, in); 142 pa_stream_set_write_callback(stream, _write_cb, in);
diff --git a/src/lib/edje/edje_multisense.c b/src/lib/edje/edje_multisense.c
index 913c1f9..8d40b0c 100644
--- a/src/lib/edje/edje_multisense.c
+++ b/src/lib/edje/edje_multisense.c
@@ -271,7 +271,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
271 { 271 {
272 in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL); 272 in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL);
273 eo_do(in, ecore_audio_obj_name_set("tone")); 273 eo_do(in, ecore_audio_obj_name_set("tone"));
274 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL)); 274 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value));
275 eo_do(in, ecore_audio_obj_in_length_set(duration)); 275 eo_do(in, ecore_audio_obj_in_length_set(duration));
276 eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL)); 276 eo_do(in, eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL));
277 277
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 6c985c4..e2229d9 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -891,6 +891,7 @@ EAPI Eina_Bool eo_destructed_is(const Eo *obj);
891/** 891/**
892 * @typedef eo_key_data_free_func 892 * @typedef eo_key_data_free_func
893 * Data free func prototype. 893 * Data free func prototype.
894 * XXX: DO NOT USE, only here for legacy.
894 */ 895 */
895typedef void (*eo_key_data_free_func)(void *); 896typedef void (*eo_key_data_free_func)(void *);
896 897
diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo
index de44698..97bc6bf 100644
--- a/src/lib/eo/eo_base.eo
+++ b/src/lib/eo/eo_base.eo
@@ -69,11 +69,11 @@ This function registers the object handle pointed by wref to obj so when obj is
69 } 69 }
70 } 70 }
71 key_data_set { 71 key_data_set {
72 /*@ Set generic data to object. */ 72 /*@ Set generic data to object.
73 The user is in change to free the data. */
73 params { 74 params {
74 @in key: const(char)*; /*@ the key associated with the data */ 75 @in key: const(char)*; /*@ the key associated with the data */
75 @in data: const(void)*; /*@ the data to set */ 76 @in data: const(void)*; /*@ the data to set */
76 @in free_func: eo_key_data_free_func; /*@ the func to free data with (NULL means */
77 } 77 }
78 } 78 }
79 key_data_get { 79 key_data_get {
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 1dbd6f0..93d5715 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -34,15 +34,12 @@ typedef struct
34 EINA_INLIST; 34 EINA_INLIST;
35 Eina_Stringshare *key; 35 Eina_Stringshare *key;
36 void *data; 36 void *data;
37 eo_key_data_free_func free_func;
38} Eo_Generic_Data_Node; 37} Eo_Generic_Data_Node;
39 38
40static void 39static void
41_eo_generic_data_node_free(Eo_Generic_Data_Node *node) 40_eo_generic_data_node_free(Eo_Generic_Data_Node *node)
42{ 41{
43 eina_stringshare_del(node->key); 42 eina_stringshare_del(node->key);
44 if (node->free_func)
45 node->free_func(node->data);
46 free(node); 43 free(node);
47} 44}
48 45
@@ -63,7 +60,7 @@ _eo_generic_data_del_all(Eo_Base_Data *pd)
63 60
64EOLIAN static void 61EOLIAN static void
65_eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd, 62_eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd,
66 const char *key, const void *data, eo_key_data_free_func free_func) 63 const char *key, const void *data)
67{ 64{
68 Eo_Generic_Data_Node *node; 65 Eo_Generic_Data_Node *node;
69 66
@@ -75,7 +72,6 @@ _eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd,
75 if (!node) return; 72 if (!node) return;
76 node->key = eina_stringshare_add(key); 73 node->key = eina_stringshare_add(key);
77 node->data = (void *) data; 74 node->data = (void *) data;
78 node->free_func = free_func;
79 pd->generic_data = eina_inlist_prepend(pd->generic_data, 75 pd->generic_data = eina_inlist_prepend(pd->generic_data,
80 EINA_INLIST_GET(node)); 76 EINA_INLIST_GET(node));
81} 77}
diff --git a/src/lib/evas/canvas/evas_data.c b/src/lib/evas/canvas/evas_data.c
index 4686595..38bc537 100644
--- a/src/lib/evas/canvas/evas_data.c
+++ b/src/lib/evas/canvas/evas_data.c
@@ -8,7 +8,7 @@ evas_object_data_set(Evas_Object *obj, const char *key, const void *data)
8 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); 8 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
9 return; 9 return;
10 MAGIC_CHECK_END(); 10 MAGIC_CHECK_END();
11 eo_do(obj, eo_key_data_set(key, data, NULL)); 11 eo_do(obj, eo_key_data_set(key, data));
12} 12}
13 13
14EAPI void * 14EAPI void *
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c
index aeea55f..4be231c 100644
--- a/src/tests/ecore/ecore_test_ecore_audio.c
+++ b/src/tests/ecore/ecore_test_ecore_audio.c
@@ -116,7 +116,7 @@ START_TEST(ecore_test_ecore_audio_cleanup)
116 116
117 in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL); 117 in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL);
118 fail_if(!in); 118 fail_if(!in);
119 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); 119 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
120 eo_do(in, ecore_audio_obj_in_length_set(2)); 120 eo_do(in, ecore_audio_obj_in_length_set(2));
121 121
122 out = eo_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL); 122 out = eo_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
@@ -170,12 +170,12 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
170 fail_if(freq != 1000); 170 fail_if(freq != 1000);
171 171
172 freq = 2000; 172 freq = 2000;
173 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL)); 173 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq));
174 174
175 eo_do(in, freq = (intptr_t) eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ)); 175 eo_do(in, freq = (intptr_t) eo_key_data_get(ECORE_AUDIO_ATTR_TONE_FREQ));
176 fail_if(freq != 2000); 176 fail_if(freq != 2000);
177 177
178 eo_do(in, eo_key_data_set("foo", "bar", NULL)); 178 eo_do(in, eo_key_data_set("foo", "bar"));
179 eo_do(in, tmp = eo_key_data_get("foo")); 179 eo_do(in, tmp = eo_key_data_get("foo"));
180 ck_assert_str_eq(tmp, "bar"); 180 ck_assert_str_eq(tmp, "bar");
181 181
diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c
index b933e19..1e59b4d 100644
--- a/src/tests/eo/composite_objects/composite_objects_comp.c
+++ b/src/tests/eo/composite_objects/composite_objects_comp.c
@@ -34,7 +34,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
34 fail_if(eo_do_ret(obj, tmp, eo_composite_part_is())); 34 fail_if(eo_do_ret(obj, tmp, eo_composite_part_is()));
35 fail_if(!eo_do_ret(simple, tmp, eo_composite_part_is())); 35 fail_if(!eo_do_ret(simple, tmp, eo_composite_part_is()));
36 36
37 eo_do(obj, eo_key_data_set("simple-obj", simple, NULL)); 37 eo_do(obj, eo_key_data_set("simple-obj", simple));
38 38
39 return obj; 39 return obj;
40} 40}
diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c
index f113e51..67e5f68 100644
--- a/src/tests/eo/signals/signals_simple.c
+++ b/src/tests/eo/signals/signals_simple.c
@@ -68,7 +68,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
68 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL)); 68 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
69 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL)); 69 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
70 70
71 eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0, NULL)); 71 eo_do(obj, eo_key_data_set("cb_count", (intptr_t) 0));
72 72
73 return obj; 73 return obj;
74} 74}
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 59cb4db..47064cf 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -547,31 +547,21 @@ START_TEST(eo_weak_reference)
547} 547}
548END_TEST 548END_TEST
549 549
550static void
551_fake_free_func(void *data)
552{
553 if (!data)
554 return;
555
556 int *a = data;
557 ++*a;
558}
559
560START_TEST(eo_generic_data) 550START_TEST(eo_generic_data)
561{ 551{
562 eo_init(); 552 eo_init();
563 Eo *obj = eo_add(SIMPLE_CLASS, NULL); 553 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
564 void *data = NULL; 554 void *data = NULL;
565 555
566 eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL)); 556 eo_do(obj, eo_key_data_set("test1", (void *) 1));
567 eo_do(obj, data = eo_key_data_get("test1")); 557 eo_do(obj, data = eo_key_data_get("test1"));
568 fail_if(1 != (intptr_t) data); 558 fail_if(1 != (intptr_t) data);
569 eo_do(obj, eo_key_data_del("test1")); 559 eo_do(obj, eo_key_data_del("test1"));
570 eo_do(obj, data = eo_key_data_get("test1")); 560 eo_do(obj, data = eo_key_data_get("test1"));
571 fail_if(data); 561 fail_if(data);
572 562
573 eo_do(obj, eo_key_data_set("test1", (void *) 1, NULL)); 563 eo_do(obj, eo_key_data_set("test1", (void *) 1));
574 eo_do(obj, eo_key_data_set("test2", (void *) 2, NULL)); 564 eo_do(obj, eo_key_data_set("test2", (void *) 2));
575 eo_do(obj, data = eo_key_data_get("test1")); 565 eo_do(obj, data = eo_key_data_get("test1"));
576 fail_if(1 != (intptr_t) data); 566 fail_if(1 != (intptr_t) data);
577 eo_do(obj, data = eo_key_data_get("test2")); 567 eo_do(obj, data = eo_key_data_get("test2"));
@@ -589,33 +579,7 @@ START_TEST(eo_generic_data)
589 eo_do(obj, data = eo_key_data_get("test1")); 579 eo_do(obj, data = eo_key_data_get("test1"));
590 fail_if(data); 580 fail_if(data);
591 581
592 int a = 0;
593 eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
594 eo_do(obj, data = eo_key_data_get("test3"));
595 fail_if(&a != data);
596 eo_do(obj, eo_key_data_get("test3"));
597 eo_do(obj, eo_key_data_del("test3"));
598 fail_if(a != 1);
599
600 a = 0;
601 eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
602 eo_do(obj, eo_key_data_set("test3", NULL, _fake_free_func));
603 fail_if(a != 1);
604 a = 0;
605 data = (void *) 123;
606 eo_do(obj, eo_key_data_set(NULL, &a, _fake_free_func));
607 eo_do(obj, data = eo_key_data_get(NULL));
608 fail_if(data);
609 eo_do(obj, eo_key_data_del(NULL));
610
611 a = 0;
612 eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
613 eo_do(obj, eo_key_data_set("test3", NULL, NULL));
614 fail_if(a != 1);
615 eo_do(obj, eo_key_data_set("test3", &a, _fake_free_func));
616
617 eo_unref(obj); 582 eo_unref(obj);
618 fail_if(a != 2);
619 583
620 eo_shutdown(); 584 eo_shutdown();
621} 585}