summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-11-22 17:15:29 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-11-30 14:58:26 -0800
commit2becd0feb38351d12e6df5884c143e80837dc916 (patch)
tree9ead0b7b105c50d4d08395f65c233e32a1a5dbaa /src/lib/ecore
parentf9958821e95952b7bb70ec9f716890a95f88e30d (diff)
ecore: simplify code by using helper that build future directly.
The new helper help replace call to eina_future_resolved and eina_future_rejected with a scheduler lookup to just one function call. Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D7341
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/efl_model_composite_boolean.c15
-rw-r--r--src/lib/ecore/efl_model_composite_selection.c19
-rw-r--r--src/lib/ecore/efl_model_container.c4
-rw-r--r--src/lib/ecore/efl_model_container_item.c10
-rw-r--r--src/lib/ecore/efl_model_item.c6
5 files changed, 25 insertions, 29 deletions
diff --git a/src/lib/ecore/efl_model_composite_boolean.c b/src/lib/ecore/efl_model_composite_boolean.c
index e710091288..222329eb3b 100644
--- a/src/lib/ecore/efl_model_composite_boolean.c
+++ b/src/lib/ecore/efl_model_composite_boolean.c
@@ -121,10 +121,10 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
121 Eina_Bool flag; 121 Eina_Bool flag;
122 122
123 if (!property) 123 if (!property)
124 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 124 return efl_loop_future_rejected(obj,
125 EFL_MODEL_ERROR_UNKNOWN); 125 EFL_MODEL_ERROR_UNKNOWN);
126 if (strcmp(property, "child.index") == 0) 126 if (strcmp(property, "child.index") == 0)
127 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 127 return efl_loop_future_rejected(obj,
128 EFL_MODEL_ERROR_READ_ONLY); 128 EFL_MODEL_ERROR_READ_ONLY);
129 129
130 s = eina_stringshare_add(property); 130 s = eina_stringshare_add(property);
@@ -137,10 +137,10 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
137 137
138 eina_value_setup(&b, EINA_VALUE_TYPE_BOOL); 138 eina_value_setup(&b, EINA_VALUE_TYPE_BOOL);
139 if (!eina_value_convert(value, &b)) 139 if (!eina_value_convert(value, &b))
140 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 140 return efl_loop_future_rejected(obj,
141 EFL_MODEL_ERROR_UNKNOWN); 141 EFL_MODEL_ERROR_UNKNOWN);
142 if (!eina_value_get(value, &flag)) 142 if (!eina_value_get(value, &flag))
143 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 143 return efl_loop_future_rejected(obj,
144 EFL_MODEL_ERROR_UNKNOWN); 144 EFL_MODEL_ERROR_UNKNOWN);
145 145
146 eina_value_flush(&b); 146 eina_value_flush(&b);
@@ -153,7 +153,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
153 unsigned char *tmp; 153 unsigned char *tmp;
154 154
155 tmp = realloc(v->buffer, rcount); 155 tmp = realloc(v->buffer, rcount);
156 if (!tmp) return eina_future_rejected(efl_loop_future_scheduler_get(obj), ENOMEM); 156 if (!tmp) return efl_loop_future_rejected(obj, ENOMEM);
157 v->buffer = tmp; 157 v->buffer = tmp;
158 memset(v->buffer + v->buffer_count, 0, rcount - v->buffer_count); 158 memset(v->buffer + v->buffer_count, 0, rcount - v->buffer_count);
159 v->buffer_count = rcount; 159 v->buffer_count = rcount;
@@ -169,8 +169,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
169 efl_model_properties_changed(obj, property); 169 efl_model_properties_changed(obj, property);
170 170
171 // Return fulfilled future 171 // Return fulfilled future
172 return eina_future_resolved(efl_loop_future_scheduler_get(obj), 172 return efl_loop_future_resolved(obj, eina_value_bool_init(!!flag));
173 eina_value_bool_init(!!flag));
174} 173}
175 174
176/**************** efl_model_composite_boolean **************/ 175/**************** efl_model_composite_boolean **************/
@@ -291,7 +290,7 @@ _efl_model_composite_boolean_efl_model_children_slice_get(Eo *obj,
291 start, count); 290 start, count);
292 291
293 req = malloc(sizeof (Efl_Model_Slice_Request)); 292 req = malloc(sizeof (Efl_Model_Slice_Request));
294 if (!req) return eina_future_rejected(efl_loop_future_scheduler_get(obj), 293 if (!req) return efl_loop_future_rejected(obj,
295 ENOMEM); 294 ENOMEM);
296 req->parent = efl_ref(obj); 295 req->parent = efl_ref(obj);
297 req->start = start; 296 req->start = start;
diff --git a/src/lib/ecore/efl_model_composite_selection.c b/src/lib/ecore/efl_model_composite_selection.c
index cb35c0f0ce..25f68c2f5f 100644
--- a/src/lib/ecore/efl_model_composite_selection.c
+++ b/src/lib/ecore/efl_model_composite_selection.c
@@ -126,8 +126,7 @@ _check_child_change(Efl_Model *child, Eina_Bool value)
126 126
127 if (prevflag & value) 127 if (prevflag & value)
128 { 128 {
129 r = eina_future_resolved(efl_loop_future_scheduler_get(child), 129 r = efl_loop_future_resolved(child, eina_value_bool_init(value));
130 eina_value_bool_init(value));
131 } 130 }
132 else 131 else
133 { 132 {
@@ -217,10 +216,9 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
217 changed = (!pd->exclusive != !exclusive); 216 changed = (!pd->exclusive != !exclusive);
218 pd->exclusive = !!exclusive; 217 pd->exclusive = !!exclusive;
219 218
220 if (changed) 219 if (changed) efl_model_properties_changed(obj, "exclusive");
221 efl_model_properties_changed(obj, "exclusive");
222 220
223 return eina_future_resolved(efl_loop_future_scheduler_get(obj), vf); 221 return efl_loop_future_resolved(obj, vf);
224 } 222 }
225 223
226 if (!strcmp("selected", property)) 224 if (!strcmp("selected", property))
@@ -233,7 +231,7 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
233 success &= eina_value_convert(value, &vl); 231 success &= eina_value_convert(value, &vl);
234 success &= eina_value_ulong_get(&vl, &l); 232 success &= eina_value_ulong_get(&vl, &l);
235 if (!success) 233 if (!success)
236 return eina_future_rejected(efl_loop_future_scheduler_get(obj), EFL_MODEL_ERROR_INCORRECT_VALUE); 234 return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
237 235
238 return efl_future_then 236 return efl_future_then
239 (obj, eina_future_then(efl_model_children_slice_get(obj, l, 1), 237 (obj, eina_future_then(efl_model_children_slice_get(obj, l, 1),
@@ -346,11 +344,11 @@ _efl_model_composite_selection_children_efl_model_property_set(Eo *obj,
346 eina_value_flush(&lvb); 344 eina_value_flush(&lvb);
347 345
348 if (!success) 346 if (!success)
349 return eina_future_rejected(efl_loop_future_scheduler_get(obj), EFL_MODEL_ERROR_INCORRECT_VALUE); 347 return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
350 348
351 // Nothing changed 349 // Nothing changed
352 if (newflag == prevflag) 350 if (newflag == prevflag)
353 return eina_future_resolved(efl_loop_future_scheduler_get(obj), 351 return efl_loop_future_resolved(obj,
354 eina_value_bool_init(newflag)); 352 eina_value_bool_init(newflag));
355 353
356 ve = efl_model_property_get(efl_parent_get(obj), "exclusive"); 354 ve = efl_model_property_get(efl_parent_get(obj), "exclusive");
@@ -402,8 +400,7 @@ _efl_model_composite_selection_children_efl_model_property_set(Eo *obj,
402 eina_value_free(vs); 400 eina_value_free(vs);
403 401
404 if (!success) 402 if (!success)
405 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 403 return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
406 EFL_MODEL_ERROR_INCORRECT_VALUE);
407 404
408 // There was, need to unselect the previous one along setting the new value 405 // There was, need to unselect the previous one along setting the new value
409 chain = eina_future_all(chain, 406 chain = eina_future_all(chain,
@@ -469,7 +466,7 @@ _efl_model_composite_selection_efl_model_children_slice_get(Eo *obj,
469 Eina_Future *f; 466 Eina_Future *f;
470 467
471 req = calloc(1, sizeof (Selection_Children_Request)); 468 req = calloc(1, sizeof (Selection_Children_Request));
472 if (!req) return eina_future_rejected(efl_loop_future_scheduler_get(obj), ENOMEM); 469 if (!req) return efl_loop_future_rejected(obj, ENOMEM);
473 req->parent = efl_ref(obj); 470 req->parent = efl_ref(obj);
474 req->start = start; 471 req->start = start;
475 472
diff --git a/src/lib/ecore/efl_model_container.c b/src/lib/ecore/efl_model_container.c
index ce5dc493aa..100c171567 100644
--- a/src/lib/ecore/efl_model_container.c
+++ b/src/lib/ecore/efl_model_container.c
@@ -233,7 +233,7 @@ _efl_model_container_efl_model_property_set(Eo *obj,
233 const char *property EINA_UNUSED, 233 const char *property EINA_UNUSED,
234 Eina_Value *value EINA_UNUSED) 234 Eina_Value *value EINA_UNUSED)
235{ 235{
236 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 236 return efl_loop_future_rejected(obj,
237 EFL_MODEL_ERROR_NOT_FOUND); 237 EFL_MODEL_ERROR_NOT_FOUND);
238} 238}
239 239
@@ -254,7 +254,7 @@ _efl_model_container_efl_model_children_slice_get(Eo *obj,
254 Eina_Value v; 254 Eina_Value v;
255 255
256 v = efl_model_list_value_get(sd->childrens, start, count); 256 v = efl_model_list_value_get(sd->childrens, start, count);
257 return eina_future_resolved(efl_loop_future_scheduler_get(obj), v); 257 return efl_loop_future_resolved(obj, v);
258} 258}
259 259
260static unsigned int 260static unsigned int
diff --git a/src/lib/ecore/efl_model_container_item.c b/src/lib/ecore/efl_model_container_item.c
index c3fa8d0c90..ec61f8ea28 100644
--- a/src/lib/ecore/efl_model_container_item.c
+++ b/src/lib/ecore/efl_model_container_item.c
@@ -58,12 +58,12 @@ _efl_model_container_item_efl_model_property_set(Eo *obj,
58 58
59 if (!cpd || !cpd->values || 59 if (!cpd || !cpd->values ||
60 sd->index >= eina_array_count_get(cpd->values)) 60 sd->index >= eina_array_count_get(cpd->values))
61 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 61 return efl_loop_future_rejected(obj,
62 EFL_MODEL_ERROR_NOT_FOUND); 62 EFL_MODEL_ERROR_NOT_FOUND);
63 63
64 eina_value_setup(&v,cpd->type); 64 eina_value_setup(&v,cpd->type);
65 if (!eina_value_convert(value, &v)) 65 if (!eina_value_convert(value, &v))
66 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 66 return efl_loop_future_rejected(obj,
67 EFL_MODEL_ERROR_INCORRECT_VALUE); 67 EFL_MODEL_ERROR_INCORRECT_VALUE);
68 68
69 // FIXME: This is trying to optimize and avoid the use of Eina_Value, 69 // FIXME: This is trying to optimize and avoid the use of Eina_Value,
@@ -80,13 +80,13 @@ _efl_model_container_item_efl_model_property_set(Eo *obj,
80 80
81 free(data); 81 free(data);
82 82
83 return eina_future_resolved(efl_loop_future_scheduler_get(obj), v); 83 return efl_loop_future_resolved(obj, v);
84 84
85 on_error: 85 on_error:
86 eina_value_flush(&v); 86 eina_value_flush(&v);
87 free(data); 87 free(data);
88 88
89 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 89 return efl_loop_future_rejected(obj,
90 EFL_MODEL_ERROR_UNKNOWN); 90 EFL_MODEL_ERROR_UNKNOWN);
91} 91}
92 92
@@ -132,7 +132,7 @@ _efl_model_container_item_efl_model_children_slice_get(Eo *obj,
132 unsigned int start EINA_UNUSED, 132 unsigned int start EINA_UNUSED,
133 unsigned int count EINA_UNUSED) 133 unsigned int count EINA_UNUSED)
134{ 134{
135 return eina_future_resolved(efl_loop_future_scheduler_get(obj), EINA_VALUE_EMPTY); 135 return efl_loop_future_resolved(obj, EINA_VALUE_EMPTY);
136} 136}
137 137
138EOLIAN static unsigned int 138EOLIAN static unsigned int
diff --git a/src/lib/ecore/efl_model_item.c b/src/lib/ecore/efl_model_item.c
index 13f60292c9..7e009e364c 100644
--- a/src/lib/ecore/efl_model_item.c
+++ b/src/lib/ecore/efl_model_item.c
@@ -97,7 +97,7 @@ _efl_model_item_efl_model_property_set(Eo *obj, Efl_Model_Item_Data *pd, const c
97 97
98 eina_array_free(evt.changed_properties); 98 eina_array_free(evt.changed_properties);
99 99
100 return eina_future_resolved(efl_loop_future_scheduler_get(obj), 100 return efl_loop_future_resolved(obj,
101 eina_value_reference_copy(value)); 101 eina_value_reference_copy(value));
102 102
103 hash_failed: 103 hash_failed:
@@ -105,7 +105,7 @@ _efl_model_item_efl_model_property_set(Eo *obj, Efl_Model_Item_Data *pd, const c
105 value_failed: 105 value_failed:
106 eina_stringshare_del(prop); 106 eina_stringshare_del(prop);
107 107
108 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 108 return efl_loop_future_rejected(obj,
109 ENOMEM); 109 ENOMEM);
110} 110}
111 111
@@ -133,7 +133,7 @@ _efl_model_item_efl_model_children_slice_get(Eo *obj, Efl_Model_Item_Data *pd, u
133 Eina_Value v; 133 Eina_Value v;
134 134
135 v = efl_model_list_value_get(pd->childrens, start, count); 135 v = efl_model_list_value_get(pd->childrens, start, count);
136 return eina_future_resolved(efl_loop_future_scheduler_get(obj), v); 136 return efl_loop_future_resolved(obj, v);
137} 137}
138 138
139static unsigned int 139static unsigned int