summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2018-11-23 16:25:19 +0000
committerCedric BAIL <cedric@osg.samsung.com>2018-11-23 10:13:58 -0800
commitd4d44d76f3efef4d61edb4cce7152284915a12d2 (patch)
tree502779c9047c6a8e02c8466f81ddc8616887fa50
parentaac7d099a17d69f5989481f8999a43d4173005bd (diff)
efl: make Efl.Model.properties_get return an Iterator<string>.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D7289
-rw-r--r--src/examples/eldbus/dbusmodel.c13
-rw-r--r--src/lib/ecore/efl_model_composite.c2
-rw-r--r--src/lib/ecore/efl_model_composite_boolean.c19
-rw-r--r--src/lib/ecore/efl_model_container.c14
-rw-r--r--src/lib/ecore/efl_model_container_item.c2
-rw-r--r--src/lib/ecore/efl_model_item.c8
-rw-r--r--src/lib/efl/interfaces/efl_model.eo2
-rw-r--r--src/lib/eio/eio_model.c11
-rw-r--r--src/lib/eldbus/eldbus_model.c9
-rw-r--r--src/lib/eldbus/eldbus_model_arguments.c71
-rw-r--r--src/lib/eldbus/eldbus_model_arguments_private.h5
-rw-r--r--src/lib/eldbus/eldbus_model_method.c7
-rw-r--r--src/lib/eldbus/eldbus_model_proxy.c15
-rw-r--r--src/lib/elementary/efl_ui_list_view.c14
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_connection.c10
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_method.c9
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_object.c9
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_proxy.c3
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_signal.c9
-rw-r--r--src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c9
20 files changed, 104 insertions, 137 deletions
diff --git a/src/examples/eldbus/dbusmodel.c b/src/examples/eldbus/dbusmodel.c
index 10150c4..cc09d79 100644
--- a/src/examples/eldbus/dbusmodel.c
+++ b/src/examples/eldbus/dbusmodel.c
@@ -64,17 +64,16 @@ EFL_CALLBACKS_ARRAY_DEFINE(child_cbs,
64static void 64static void
65process(Eo *child, unsigned int index) 65process(Eo *child, unsigned int index)
66{ 66{
67 Eina_Array *properties = efl_model_properties_get(child); 67 Eina_Iterator *properties = efl_model_properties_get(child);
68 const char *property; 68 const char *property;
69 Eina_Array_Iterator it;
70 Eina_Strbuf *buf; 69 Eina_Strbuf *buf;
71 unsigned int i; 70 Eina_Bool noproperties = EINA_TRUE;
72 71
73 buf = eina_strbuf_new(); 72 buf = eina_strbuf_new();
74 73
75 const char *name = eldbus_model_proxy_name_get(child); 74 const char *name = eldbus_model_proxy_name_get(child);
76 75
77 EINA_ARRAY_ITER_NEXT(properties, i, property, it) 76 EINA_ITERATOR_FOREACH(properties, property)
78 { 77 {
79 Eina_Value *v = efl_model_property_get(child, property); 78 Eina_Value *v = efl_model_property_get(child, property);
80 char *str; 79 char *str;
@@ -90,16 +89,18 @@ process(Eo *child, unsigned int index)
90 free(str); 89 free(str);
91 90
92 eina_value_free(v); 91 eina_value_free(v);
92
93 noproperties = EINA_FALSE;
93 } 94 }
95 eina_iterator_free(properties);
94 96
95 if (eina_array_count(properties) <= 0) 97 if (noproperties)
96 eina_strbuf_append_printf(buf, " %2d: %s (no properties yet)\n", index, name); 98 eina_strbuf_append_printf(buf, " %2d: %s (no properties yet)\n", index, name);
97 else 99 else
98 eina_strbuf_prepend_printf(buf, " -> %s\n Properties:\n", name); 100 eina_strbuf_prepend_printf(buf, " -> %s\n Properties:\n", name);
99 101
100 printf("%s", eina_strbuf_string_get(buf)); 102 printf("%s", eina_strbuf_string_get(buf));
101 103
102 eina_array_free(properties);
103 eina_strbuf_free(buf); 104 eina_strbuf_free(buf);
104 105
105 efl_ref(child); 106 efl_ref(child);
diff --git a/src/lib/ecore/efl_model_composite.c b/src/lib/ecore/efl_model_composite.c
index 90cd8ad..dfb3019 100644
--- a/src/lib/ecore/efl_model_composite.c
+++ b/src/lib/ecore/efl_model_composite.c
@@ -69,7 +69,7 @@ _efl_model_composite_efl_model_property_get(const Eo *obj EINA_UNUSED, Efl_Model
69 return efl_model_property_get(pd->source, property); 69 return efl_model_property_get(pd->source, property);
70} 70}
71 71
72static Eina_Array * 72static Eina_Iterator *
73_efl_model_composite_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd) 73_efl_model_composite_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd)
74{ 74{
75 return efl_model_properties_get(pd->source); 75 return efl_model_properties_get(pd->source);
diff --git a/src/lib/ecore/efl_model_composite_boolean.c b/src/lib/ecore/efl_model_composite_boolean.c
index 98dbbe5..ef9ec43 100644
--- a/src/lib/ecore/efl_model_composite_boolean.c
+++ b/src/lib/ecore/efl_model_composite_boolean.c
@@ -67,23 +67,20 @@ _efl_model_composite_boolean_children_efl_object_finalize(Eo *obj,
67 return obj; 67 return obj;
68} 68}
69 69
70static Eina_Array * 70static Eina_Iterator *
71_efl_model_composite_boolean_children_efl_model_properties_get(const Eo *obj, 71_efl_model_composite_boolean_children_efl_model_properties_get(const Eo *obj,
72 Efl_Model_Composite_Boolean_Children_Data *pd) 72 Efl_Model_Composite_Boolean_Children_Data *pd)
73{ 73{
74 Eina_Iterator *it; 74 Eina_Iterator *its;
75 Eina_Stringshare *s; 75 Eina_Iterator *itr;
76 Eina_Array *r;
77 76
78 r = efl_model_properties_get(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS)); 77 its = efl_model_properties_get(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS));
79 if (!r) r = eina_array_new(1); 78 itr = eina_hash_iterator_key_new(pd->parent->values);
80 79
81 it = eina_hash_iterator_key_new(pd->parent->values); 80 if (!its) return itr;
82 EINA_ITERATOR_FOREACH(it, s) 81 if (!itr) return its;
83 eina_array_push(r, s);
84 eina_array_push(r, "child.index");
85 82
86 return r; 83 return eina_multi_iterator_new(its, itr);
87} 84}
88 85
89static Eina_Value * 86static Eina_Value *
diff --git a/src/lib/ecore/efl_model_container.c b/src/lib/ecore/efl_model_container.c
index 0832a2f..5449ae4 100644
--- a/src/lib/ecore/efl_model_container.c
+++ b/src/lib/ecore/efl_model_container.c
@@ -225,20 +225,10 @@ _efl_model_container_child_property_add(Eo *obj,
225 return EINA_FALSE; 225 return EINA_FALSE;
226} 226}
227 227
228static Eina_Array * 228static Eina_Iterator *
229_efl_model_container_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Container_Data *sd) 229_efl_model_container_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Container_Data *sd)
230{ 230{
231 Eina_Iterator *it; 231 return eina_hash_iterator_key_new(sd->properties);
232 Eina_Array *r;
233 Eina_Stringshare *s;
234
235 r = eina_array_new(1);
236 it = eina_hash_iterator_key_new(sd->properties);
237 EINA_ITERATOR_FOREACH(it, s)
238 eina_array_push(r, eina_stringshare_ref(s));
239 eina_iterator_free(it);
240
241 return r;
242} 232}
243 233
244static Eina_Future * 234static Eina_Future *
diff --git a/src/lib/ecore/efl_model_container_item.c b/src/lib/ecore/efl_model_container_item.c
index b87558a..c3fa8d0 100644
--- a/src/lib/ecore/efl_model_container_item.c
+++ b/src/lib/ecore/efl_model_container_item.c
@@ -25,7 +25,7 @@ _efl_model_container_item_efl_object_invalidate(Eo *obj, Efl_Model_Container_Ite
25 sd->index = 0; 25 sd->index = 0;
26} 26}
27 27
28static Eina_Array * 28static Eina_Iterator *
29_efl_model_container_item_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Container_Item_Data *sd) 29_efl_model_container_item_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Container_Item_Data *sd)
30{ 30{
31 // FIXME: Not to sure here, shouldn't we extend a child of the parent actually ? 31 // FIXME: Not to sure here, shouldn't we extend a child of the parent actually ?
diff --git a/src/lib/ecore/efl_model_item.c b/src/lib/ecore/efl_model_item.c
index e5058c1..104125a 100644
--- a/src/lib/ecore/efl_model_item.c
+++ b/src/lib/ecore/efl_model_item.c
@@ -13,7 +13,6 @@ typedef struct _Efl_Model_Item_Data Efl_Model_Item_Data;
13struct _Efl_Model_Item_Data 13struct _Efl_Model_Item_Data
14{ 14{
15 Eina_Hash *properties; 15 Eina_Hash *properties;
16 Eina_Array *defined_properties;
17 Eina_List *childrens; 16 Eina_List *childrens;
18}; 17};
19 18
@@ -38,7 +37,6 @@ _efl_model_item_efl_object_constructor(Eo *obj, Efl_Model_Item_Data *sd)
38 return NULL; 37 return NULL;
39 38
40 sd->properties = eina_hash_stringshared_new(_item_value_free_cb); 39 sd->properties = eina_hash_stringshared_new(_item_value_free_cb);
41 sd->defined_properties = eina_array_new(8);
42 40
43 return obj; 41 return obj;
44} 42}
@@ -57,15 +55,13 @@ _efl_model_item_efl_object_destructor(Eo *obj, Efl_Model_Item_Data *sd)
57 eina_hash_foreach(sd->properties, _stringshared_keys_free, NULL); 55 eina_hash_foreach(sd->properties, _stringshared_keys_free, NULL);
58 eina_hash_free(sd->properties); 56 eina_hash_free(sd->properties);
59 57
60 eina_array_free(sd->defined_properties);
61
62 efl_destructor(efl_super(obj, MY_CLASS)); 58 efl_destructor(efl_super(obj, MY_CLASS));
63} 59}
64 60
65static Eina_Array * 61static Eina_Iterator *
66_efl_model_item_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Item_Data *pd) 62_efl_model_item_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Item_Data *pd)
67{ 63{
68 return pd->defined_properties; 64 return eina_hash_iterator_key_new(pd->properties);
69} 65}
70 66
71static Eina_Future * 67static Eina_Future *
diff --git a/src/lib/efl/interfaces/efl_model.eo b/src/lib/efl/interfaces/efl_model.eo
index 88260db..ffe8bf4 100644
--- a/src/lib/efl/interfaces/efl_model.eo
+++ b/src/lib/efl/interfaces/efl_model.eo
@@ -33,7 +33,7 @@ interface Efl.Model ()
33 ]] 33 ]]
34 } 34 }
35 values { 35 values {
36 properties: array<string>; [[Array of current properties]] 36 properties: iterator<string> @owned; [[Array of current properties]]
37 } 37 }
38 } 38 }
39 @property property { 39 @property property {
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index 62e52f4..ee8296a 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -631,18 +631,11 @@ static struct {
631/** 631/**
632 * Interfaces impl. 632 * Interfaces impl.
633 */ 633 */
634static Eina_Array * 634static Eina_Iterator *
635_eio_model_efl_model_properties_get(const Eo *obj EINA_UNUSED, 635_eio_model_efl_model_properties_get(const Eo *obj EINA_UNUSED,
636 Eio_Model_Data *pd EINA_UNUSED) 636 Eio_Model_Data *pd EINA_UNUSED)
637{ 637{
638 Eina_Array *r; 638 return EINA_C_ARRAY_ITERATOR_NEW(properties);
639 unsigned int i;
640
641 r = eina_array_new(4);
642 for (i = 0; i < EINA_C_ARRAY_LENGTH(properties); ++i)
643 eina_array_push(r, properties[i].name);
644
645 return r;
646} 639}
647 640
648static Eina_Value * 641static Eina_Value *
diff --git a/src/lib/eldbus/eldbus_model.c b/src/lib/eldbus/eldbus_model.c
index 28faa0f..3a2115e 100644
--- a/src/lib/eldbus/eldbus_model.c
+++ b/src/lib/eldbus/eldbus_model.c
@@ -152,16 +152,13 @@ _eldbus_model_efl_model_property_get(const Eo *obj,
152 return eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND); 152 return eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND);
153} 153}
154 154
155static Eina_Array * 155static Eina_Iterator *
156_eldbus_model_efl_model_properties_get(const Eo *obj EINA_UNUSED, 156_eldbus_model_efl_model_properties_get(const Eo *obj EINA_UNUSED,
157 Eldbus_Model_Data *pd EINA_UNUSED) 157 Eldbus_Model_Data *pd EINA_UNUSED)
158{ 158{
159 Eina_Array *r; 159 char *unique[] = { UNIQUE_NAME_PROPERTY };
160 160
161 r = eina_array_new(1); 161 return EINA_C_ARRAY_ITERATOR_NEW(unique);
162 eina_array_push(r, eina_stringshare_add(UNIQUE_NAME_PROPERTY));
163
164 return r;
165} 162}
166 163
167static Efl_Object * 164static Efl_Object *
diff --git a/src/lib/eldbus/eldbus_model_arguments.c b/src/lib/eldbus/eldbus_model_arguments.c
index 1d22903..4c60930 100644
--- a/src/lib/eldbus/eldbus_model_arguments.c
+++ b/src/lib/eldbus/eldbus_model_arguments.c
@@ -12,8 +12,6 @@
12#define MY_CLASS ELDBUS_MODEL_ARGUMENTS_CLASS 12#define MY_CLASS ELDBUS_MODEL_ARGUMENTS_CLASS
13#define MY_CLASS_NAME "Eldbus_Model_Arguments" 13#define MY_CLASS_NAME "Eldbus_Model_Arguments"
14 14
15#define ARGUMENT_FORMAT "arg%u"
16
17static void _eldbus_model_arguments_properties_load(Eldbus_Model_Arguments_Data *); 15static void _eldbus_model_arguments_properties_load(Eldbus_Model_Arguments_Data *);
18static void _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *); 16static void _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *);
19static Eina_Bool _eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *, const char *); 17static Eina_Bool _eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *, const char *);
@@ -31,8 +29,8 @@ static Efl_Object*
31_eldbus_model_arguments_efl_object_constructor(Eo *obj, Eldbus_Model_Arguments_Data *pd) 29_eldbus_model_arguments_efl_object_constructor(Eo *obj, Eldbus_Model_Arguments_Data *pd)
32{ 30{
33 pd->obj = obj; 31 pd->obj = obj;
34 pd->properties_array = NULL; 32 // We do keep strings here as some of our API are looking for arg%u as a key instead of just indexes.
35 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_arguments_hash_free)); 33 pd->properties = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_arguments_hash_free));
36 pd->pending_list = NULL; 34 pd->pending_list = NULL;
37 pd->proxy = NULL; 35 pd->proxy = NULL;
38 pd->arguments = NULL; 36 pd->arguments = NULL;
@@ -72,7 +70,7 @@ _eldbus_model_arguments_efl_object_destructor(Eo *obj, Eldbus_Model_Arguments_Da
72{ 70{
73 _eldbus_model_arguments_unload(pd); 71 _eldbus_model_arguments_unload(pd);
74 72
75 eina_hash_free(pd->properties_hash); 73 eina_hash_free(pd->properties);
76 74
77 eina_stringshare_del(pd->name); 75 eina_stringshare_del(pd->name);
78 eldbus_proxy_unref(pd->proxy); 76 eldbus_proxy_unref(pd->proxy);
@@ -80,14 +78,14 @@ _eldbus_model_arguments_efl_object_destructor(Eo *obj, Eldbus_Model_Arguments_Da
80 efl_destructor(efl_super(obj, MY_CLASS)); 78 efl_destructor(efl_super(obj, MY_CLASS));
81} 79}
82 80
83static Eina_Array * 81static Eina_Iterator *
84_eldbus_model_arguments_efl_model_properties_get(const Eo *obj EINA_UNUSED, 82_eldbus_model_arguments_efl_model_properties_get(const Eo *obj EINA_UNUSED,
85 Eldbus_Model_Arguments_Data *pd) 83 Eldbus_Model_Arguments_Data *pd)
86{ 84{
87 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL); 85 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
88 86
89 _eldbus_model_arguments_properties_load(pd); 87 _eldbus_model_arguments_properties_load(pd);
90 return pd->properties_array; 88 return eina_hash_iterator_key_new(pd->properties);
91} 89}
92 90
93static void 91static void
@@ -96,30 +94,25 @@ _eldbus_model_arguments_properties_load(Eldbus_Model_Arguments_Data *pd)
96 unsigned int arguments_count; 94 unsigned int arguments_count;
97 unsigned int i; 95 unsigned int i;
98 96
99 if (pd->properties_array) 97 if (eina_hash_population(pd->properties) > 0)
100 return; 98 return ;
101 99
102 arguments_count = eina_list_count(pd->arguments); 100 arguments_count = eina_list_count(pd->arguments);
103 101
104 pd->properties_array = eina_array_new(arguments_count);
105 EINA_SAFETY_ON_NULL_RETURN(pd->properties_array);
106
107 for (i = 0; i < arguments_count; ++i) 102 for (i = 0; i < arguments_count; ++i)
108 { 103 {
109 Eldbus_Introspection_Argument *arg; 104 Eldbus_Introspection_Argument *arg;
110 const Eina_Value_Type *type; 105 const Eina_Value_Type *type;
111 Eina_Stringshare *name; 106 Eina_Slstr *name;
112 Eina_Value *value; 107 Eina_Value *value;
113 108
114 name = eina_stringshare_printf(ARGUMENT_FORMAT, i); 109 name = eina_slstr_printf(ARGUMENT_FORMAT, i);
115 if (!name) continue; 110 if (!name) continue;
116 111
117 eina_array_push(pd->properties_array, name);
118
119 arg = eina_list_nth(pd->arguments, i); 112 arg = eina_list_nth(pd->arguments, i);
120 type = _dbus_type_to_eina_value_type(arg->type[0]); 113 type = _dbus_type_to_eina_value_type(arg->type[0]);
121 value = eina_value_new(type); 114 value = eina_value_new(type);
122 eina_hash_add(pd->properties_hash, name, value); 115 eina_hash_add(pd->properties, name, value);
123 } 116 }
124} 117}
125 118
@@ -144,7 +137,7 @@ _eldbus_model_arguments_efl_model_property_set(Eo *obj,
144 if (!ret) goto on_error; 137 if (!ret) goto on_error;
145 138
146 err = EFL_MODEL_ERROR_NOT_FOUND; 139 err = EFL_MODEL_ERROR_NOT_FOUND;
147 prop_value = eina_hash_find(pd->properties_hash, property); 140 prop_value = eina_hash_find(pd->properties, property);
148 if (!prop_value) goto on_error; 141 if (!prop_value) goto on_error;
149 142
150 eina_value_flush(prop_value); 143 eina_value_flush(prop_value);
@@ -168,7 +161,7 @@ _eldbus_model_arguments_efl_model_property_get(const Eo *obj, Eldbus_Model_Argum
168 161
169 _eldbus_model_arguments_properties_load(pd); 162 _eldbus_model_arguments_properties_load(pd);
170 163
171 value = eina_hash_find(pd->properties_hash, property); 164 value = eina_hash_find(pd->properties, property);
172 if (!value) return eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND); 165 if (!value) return eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND);
173 166
174 ret = _eldbus_model_arguments_is_output_argument(pd, property); 167 ret = _eldbus_model_arguments_is_output_argument(pd, property);
@@ -193,19 +186,7 @@ _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *pd)
193 EINA_LIST_FREE(pd->pending_list, pending) 186 EINA_LIST_FREE(pd->pending_list, pending)
194 eldbus_pending_cancel(pending); 187 eldbus_pending_cancel(pending);
195 188
196 if (pd->properties_array) 189 eina_hash_free_buckets(pd->properties);
197 {
198 Eina_Stringshare *property;
199 Eina_Array_Iterator it;
200 unsigned int i;
201
202 EINA_ARRAY_ITER_NEXT(pd->properties_array, i, property, it)
203 eina_stringshare_del(property);
204 eina_array_free(pd->properties_array);
205 pd->properties_array = NULL;
206 }
207
208 eina_hash_free_buckets(pd->properties_hash);
209} 190}
210 191
211Eina_Bool 192Eina_Bool
@@ -219,6 +200,7 @@ eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *pd,
219 Eina_Value *value_struct; 200 Eina_Value *value_struct;
220 Eina_Array *changed_properties; 201 Eina_Array *changed_properties;
221 unsigned int i = 0; 202 unsigned int i = 0;
203 Eina_Stringshare *property;
222 Eina_Bool result = EINA_FALSE; 204 Eina_Bool result = EINA_FALSE;
223 205
224 _eldbus_model_arguments_properties_load(pd); 206 _eldbus_model_arguments_properties_load(pd);
@@ -244,16 +226,14 @@ eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *pd,
244 { 226 {
245 if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction) 227 if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction)
246 { 228 {
247 Eina_Stringshare *property;
248 Eina_Bool ret; 229 Eina_Bool ret;
249 230
250 property = eina_array_data_get(pd->properties_array, i); 231 property = eina_stringshare_printf(ARGUMENT_FORMAT, i);
251 EINA_SAFETY_ON_NULL_GOTO(property, on_error);
252 232
253 ret = _eldbus_model_arguments_property_set(pd, value_struct, property); 233 ret = eina_array_push(changed_properties, property);
254 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); 234 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
255 235
256 ret = eina_array_push(changed_properties, property); 236 ret = _eldbus_model_arguments_property_set(pd, value_struct, property);
257 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); 237 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
258 } 238 }
259 239
@@ -269,6 +249,8 @@ eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *pd,
269 result = EINA_TRUE; 249 result = EINA_TRUE;
270 250
271on_error: 251on_error:
252 while (property = eina_array_pop(changed_properties))
253 eina_stringshare_del(property);
272 eina_array_free(changed_properties); 254 eina_array_free(changed_properties);
273 eina_value_free(value_struct); 255 eina_value_free(value_struct);
274 256
@@ -286,7 +268,7 @@ _eldbus_model_arguments_property_set(Eldbus_Model_Arguments_Data *pd,
286 268
287 _eldbus_model_arguments_properties_load(pd); 269 _eldbus_model_arguments_properties_load(pd);
288 270
289 prop_value = eina_hash_find(pd->properties_hash, property); 271 prop_value = eina_hash_find(pd->properties, property);
290 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EINA_FALSE); 272 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EINA_FALSE);
291 273
292 ret = eina_value_struct_value_get(value_struct, "arg0", &value); 274 ret = eina_value_struct_value_get(value_struct, "arg0", &value);
@@ -311,7 +293,7 @@ _eldbus_model_arguments_is(Eldbus_Model_Arguments_Data *pd,
311 _eldbus_model_arguments_properties_load(pd); 293 _eldbus_model_arguments_properties_load(pd);
312 294
313 i = _eldbus_model_arguments_argument_index_get(pd, argument); 295 i = _eldbus_model_arguments_argument_index_get(pd, argument);
314 if (i >= eina_array_count(pd->properties_array)) 296 if (i >= eina_hash_population(pd->properties))
315 { 297 {
316 WRN("Argument not found: %s", argument); 298 WRN("Argument not found: %s", argument);
317 return false; 299 return false;
@@ -342,15 +324,10 @@ _eldbus_model_arguments_argument_index_get(Eldbus_Model_Arguments_Data *pd, cons
342 Eina_Stringshare *name; 324 Eina_Stringshare *name;
343 Eina_Array_Iterator it; 325 Eina_Array_Iterator it;
344 unsigned int i = 0; 326 unsigned int i = 0;
345 _eldbus_model_arguments_properties_load(pd);
346
347 EINA_ARRAY_ITER_NEXT(pd->properties_array, i, name, it)
348 {
349 if (strcmp(name, argument) == 0)
350 return i;
351 }
352 327
353 return ++i; 328 if (sscanf(argument, ARGUMENT_FORMAT, &i) > 0)
329 return i;
330 return eina_hash_population(pd->properties);
354} 331}
355 332
356#include "eldbus_model_arguments.eo.c" 333#include "eldbus_model_arguments.eo.c"
diff --git a/src/lib/eldbus/eldbus_model_arguments_private.h b/src/lib/eldbus/eldbus_model_arguments_private.h
index 06aa1ae..83d55dd 100644
--- a/src/lib/eldbus/eldbus_model_arguments_private.h
+++ b/src/lib/eldbus/eldbus_model_arguments_private.h
@@ -14,8 +14,7 @@ struct _Eldbus_Model_Arguments_Data
14{ 14{
15 Eo *obj; 15 Eo *obj;
16 Eldbus_Proxy *proxy; 16 Eldbus_Proxy *proxy;
17 Eina_Array *properties_array; 17 Eina_Hash *properties;
18 Eina_Hash *properties_hash;
19 Eina_Stringshare *name; 18 Eina_Stringshare *name;
20 Eina_List *pending_list; 19 Eina_List *pending_list;
21 const Eina_List *arguments; 20 const Eina_List *arguments;
@@ -24,4 +23,6 @@ struct _Eldbus_Model_Arguments_Data
24 23
25Eina_Bool eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *, const Eldbus_Message *, Eldbus_Pending *); 24Eina_Bool eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *, const Eldbus_Message *, Eldbus_Pending *);
26 25
26#define ARGUMENT_FORMAT "arg%u"
27
27#endif 28#endif
diff --git a/src/lib/eldbus/eldbus_model_method.c b/src/lib/eldbus/eldbus_model_method.c
index 8e7e87b..dbdbdde 100644
--- a/src/lib/eldbus/eldbus_model_method.c
+++ b/src/lib/eldbus/eldbus_model_method.c
@@ -69,7 +69,7 @@ _eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA
69 69
70 EINA_LIST_FOREACH(data->arguments, it, argument) 70 EINA_LIST_FOREACH(data->arguments, it, argument)
71 { 71 {
72 Eina_Stringshare *name; 72 Eina_Slstr *name;
73 const Eina_Value *value; 73 const Eina_Value *value;
74 const char *signature; 74 const char *signature;
75 Eina_Bool ret; 75 Eina_Bool ret;
@@ -77,11 +77,10 @@ _eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA
77 if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction) 77 if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction)
78 continue; 78 continue;
79 79
80 name = eina_array_data_get(data->properties_array, i); 80 name = eina_slstr_printf(ARGUMENT_FORMAT, i);
81 if (!name) continue;
82 EINA_SAFETY_ON_NULL_GOTO(name, on_error); 81 EINA_SAFETY_ON_NULL_GOTO(name, on_error);
83 82
84 value = eina_hash_find(data->properties_hash, name); 83 value = eina_hash_find(data->properties, name);
85 EINA_SAFETY_ON_NULL_GOTO(value, on_error); 84 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
86 85
87 signature = argument->type; 86 signature = argument->type;
diff --git a/src/lib/eldbus/eldbus_model_proxy.c b/src/lib/eldbus/eldbus_model_proxy.c
index c1ab3b2..a159ecd 100644
--- a/src/lib/eldbus/eldbus_model_proxy.c
+++ b/src/lib/eldbus/eldbus_model_proxy.c
@@ -190,22 +190,11 @@ _eldbus_model_proxy_efl_object_destructor(Eo *obj, Eldbus_Model_Proxy_Data *pd)
190 efl_destructor(efl_super(obj, MY_CLASS)); 190 efl_destructor(efl_super(obj, MY_CLASS));
191} 191}
192 192
193static Eina_Array * 193static Eina_Iterator *
194_eldbus_model_proxy_efl_model_properties_get(const Eo *obj EINA_UNUSED, 194_eldbus_model_proxy_efl_model_properties_get(const Eo *obj EINA_UNUSED,
195 Eldbus_Model_Proxy_Data *pd) 195 Eldbus_Model_Proxy_Data *pd)
196{ 196{
197 Eina_Iterator *it; 197 return eina_hash_iterator_key_new(pd->properties);
198 Eina_Array *r;
199 Eina_Stringshare *property;
200
201 r = eina_array_new(4);
202
203 it = eina_hash_iterator_key_new(pd->properties);
204 EINA_ITERATOR_FOREACH(it, property)
205 eina_array_push(r, property);
206 eina_iterator_free(it);
207
208 return r;
209} 198}
210 199
211#define PROPERTY_EXIST 1 200#define PROPERTY_EXIST 1
diff --git a/src/lib/elementary/efl_ui_list_view.c b/src/lib/elementary/efl_ui_list_view.c
index e76ce05..e15081f 100644
--- a/src/lib/elementary/efl_ui_list_view.c
+++ b/src/lib/elementary/efl_ui_list_view.c
@@ -141,25 +141,25 @@ _efl_ui_list_view_efl_ui_scrollable_interactive_viewport_geometry_get(const Eo *
141static Eina_Bool 141static Eina_Bool
142_efl_model_properties_has(Efl_Model *model, Eina_Stringshare *propfind) 142_efl_model_properties_has(Efl_Model *model, Eina_Stringshare *propfind)
143{ 143{
144 const Eina_Array *properties; 144 Eina_Iterator *properties;
145 Eina_Array_Iterator iter_prop; 145 const char *property;
146 Eina_Stringshare *property;
147 Eina_Bool ret = EINA_FALSE; 146 Eina_Bool ret = EINA_FALSE;
148 unsigned i = 0;
149 147
150 EINA_SAFETY_ON_NULL_RETURN_VAL(model, EINA_FALSE); 148 EINA_SAFETY_ON_NULL_RETURN_VAL(model, EINA_FALSE);
151 EINA_SAFETY_ON_NULL_RETURN_VAL(propfind, EINA_FALSE); 149 EINA_SAFETY_ON_NULL_RETURN_VAL(propfind, EINA_FALSE);
152 150
153 properties = efl_model_properties_get(model); 151 properties = efl_model_properties_get(model);
154 152 EINA_ITERATOR_FOREACH(properties, property)
155 EINA_ARRAY_ITER_NEXT(properties, i, property, iter_prop)
156 { 153 {
157 if (property == propfind) 154 if (property == propfind ||
155 !strcmp(property, propfind))
158 { 156 {
159 ret = EINA_TRUE; 157 ret = EINA_TRUE;
160 break; 158 break;
161 } 159 }
162 } 160 }
161 eina_iterator_free(properties);
162
163 return ret; 163 return ret;
164} 164}
165 165
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
index aa3e710..4e57c75 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
@@ -29,12 +29,18 @@ _teardown(void)
29 29
30EFL_START_TEST(properties_get) 30EFL_START_TEST(properties_get)
31{ 31{
32 const Eina_Array *properties = NULL; 32 Eina_Iterator *properties = NULL;
33 properties = efl_model_properties_get(connection); 33 properties = efl_model_properties_get(connection);
34 ck_assert_ptr_ne(NULL, properties); 34 ck_assert_ptr_ne(NULL, properties);
35 35
36 const unsigned int expected_properties_count = 1; 36 const unsigned int expected_properties_count = 1;
37 unsigned int actual_properties_count = eina_array_count(properties); 37 unsigned int actual_properties_count = 0;
38 const char *prop;
39
40 EINA_ITERATOR_FOREACH(properties, prop)
41 actual_properties_count++;
42 eina_iterator_free(properties);
43
38 ck_assert_int_eq(expected_properties_count, actual_properties_count); 44 ck_assert_int_eq(expected_properties_count, actual_properties_count);
39} 45}
40EFL_END_TEST 46EFL_END_TEST
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_method.c b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
index f252fbc..1ac32f1 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_method.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
@@ -52,12 +52,17 @@ _teardown(void)
52 52
53EFL_START_TEST(properties_get) 53EFL_START_TEST(properties_get)
54{ 54{
55 const Eina_Array *properties = NULL; 55 Eina_Iterator *properties = NULL;
56 properties = efl_model_properties_get(method); 56 properties = efl_model_properties_get(method);
57 ck_assert_ptr_ne(NULL, properties); 57 ck_assert_ptr_ne(NULL, properties);
58 58
59 const unsigned int expected_properties_count = 3; // a, b and result arguments of 'sum' method 59 const unsigned int expected_properties_count = 3; // a, b and result arguments of 'sum' method
60 const unsigned int actual_properties_count = eina_array_count(properties); 60 unsigned int actual_properties_count = 0;
61 const char *prop;
62
63 EINA_ITERATOR_FOREACH(properties, prop)
64 actual_properties_count++;
65 eina_iterator_free(properties);
61 ck_assert_int_eq(expected_properties_count, actual_properties_count); 66 ck_assert_int_eq(expected_properties_count, actual_properties_count);
62} 67}
63EFL_END_TEST 68EFL_END_TEST
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_object.c b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
index 7959a2e..e7539eb 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_object.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
@@ -29,12 +29,17 @@ _teardown(void)
29 29
30EFL_START_TEST(properties_get) 30EFL_START_TEST(properties_get)
31{ 31{
32 const Eina_Array *properties = NULL; 32 Eina_Iterator *properties = NULL;
33 properties = efl_model_properties_get(object); 33 properties = efl_model_properties_get(object);
34 ck_assert_ptr_ne(NULL, properties); 34 ck_assert_ptr_ne(NULL, properties);
35 35
36 const unsigned int expected_properties_count = 1; 36 const unsigned int expected_properties_count = 1;
37 unsigned int actual_properties_count = eina_array_count(properties); 37 unsigned int actual_properties_count = 0;
38 const char *prop;
39
40 EINA_ITERATOR_FOREACH(properties, prop)
41 actual_properties_count++;
42 eina_iterator_free(properties);
38 ck_assert_int_eq(expected_properties_count, actual_properties_count); 43 ck_assert_int_eq(expected_properties_count, actual_properties_count);
39} 44}
40EFL_END_TEST 45EFL_END_TEST
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
index d966514..dabe81f 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
@@ -54,7 +54,7 @@ _teardown(void)
54 54
55EFL_START_TEST(properties_get) 55EFL_START_TEST(properties_get)
56{ 56{
57 const Eina_Array *properties = NULL; 57 Eina_Iterator *properties = NULL;
58 // ELDBUS_FDO_INTERFACE have no properties 58 // ELDBUS_FDO_INTERFACE have no properties
59 properties = efl_model_properties_get(dbus_proxy); 59 properties = efl_model_properties_get(dbus_proxy);
60 ck_assert_ptr_ne(NULL, properties); 60 ck_assert_ptr_ne(NULL, properties);
@@ -63,6 +63,7 @@ EFL_START_TEST(properties_get)
63 // due to an EFL change, but a change in the DBus interface: 63 // due to an EFL change, but a change in the DBus interface:
64 // properties contains 2 properties, "Interfaces" and "Features". 64 // properties contains 2 properties, "Interfaces" and "Features".
65 //ck_assert_int_eq(0, eina_array_count(properties)); 65 //ck_assert_int_eq(0, eina_array_count(properties));
66 eina_iterator_free(properties);
66} 67}
67EFL_END_TEST 68EFL_END_TEST
68 69
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
index f896792..7651e02 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
@@ -51,12 +51,17 @@ _teardown(void)
51 51
52EFL_START_TEST(properties_get) 52EFL_START_TEST(properties_get)
53{ 53{
54 const Eina_Array *properties = NULL; 54 Eina_Iterator *properties = NULL;
55 properties = efl_model_properties_get(pong_signal); 55 properties = efl_model_properties_get(pong_signal);
56 ck_assert_ptr_ne(NULL, properties); 56 ck_assert_ptr_ne(NULL, properties);
57 57
58 const unsigned int expected_properties_count = 1; // 'response' only 58 const unsigned int expected_properties_count = 1; // 'response' only
59 const unsigned int actual_properties_count = eina_array_count(properties); 59 unsigned int actual_properties_count = 0;
60 const char *prop;
61
62 EINA_ITERATOR_FOREACH(properties, prop)
63 actual_properties_count += 1;
64 eina_iterator_free(properties);
60 ck_assert_int_eq(expected_properties_count, actual_properties_count); 65 ck_assert_int_eq(expected_properties_count, actual_properties_count);
61} 66}
62EFL_END_TEST 67EFL_END_TEST
diff --git a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
index 81d35df..69cf8ba 100644
--- a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
@@ -52,12 +52,17 @@ _teardown(void)
52 52
53EFL_START_TEST(properties_get) 53EFL_START_TEST(properties_get)
54{ 54{
55 const Eina_Array *properties = efl_model_properties_get(fake_server_proxy); 55 Eina_Iterator *properties = efl_model_properties_get(fake_server_proxy);
56 ck_assert_ptr_ne(NULL, properties); 56 ck_assert_ptr_ne(NULL, properties);
57 57
58 // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties 58 // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
59 const unsigned int expected_properties_count = 3; 59 const unsigned int expected_properties_count = 3;
60 const unsigned int actual_properties_count = eina_array_count(properties); 60 unsigned int actual_properties_count = 0;
61 const char *prop;
62
63 EINA_ITERATOR_FOREACH(properties, prop)
64 actual_properties_count++;
65 eina_iterator_free(properties);
61 ck_assert_int_eq(expected_properties_count, actual_properties_count); 66 ck_assert_int_eq(expected_properties_count, actual_properties_count);
62 67
63 _teardown(); 68 _teardown();