forked from enlightenment/efl
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
This commit is contained in:
parent
f9958821e9
commit
2becd0feb3
|
@ -121,10 +121,10 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
|
|||
Eina_Bool flag;
|
||||
|
||||
if (!property)
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_UNKNOWN);
|
||||
if (strcmp(property, "child.index") == 0)
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_READ_ONLY);
|
||||
|
||||
s = eina_stringshare_add(property);
|
||||
|
@ -137,10 +137,10 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
|
|||
|
||||
eina_value_setup(&b, EINA_VALUE_TYPE_BOOL);
|
||||
if (!eina_value_convert(value, &b))
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_UNKNOWN);
|
||||
if (!eina_value_get(value, &flag))
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_UNKNOWN);
|
||||
|
||||
eina_value_flush(&b);
|
||||
|
@ -153,7 +153,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
|
|||
unsigned char *tmp;
|
||||
|
||||
tmp = realloc(v->buffer, rcount);
|
||||
if (!tmp) return eina_future_rejected(efl_loop_future_scheduler_get(obj), ENOMEM);
|
||||
if (!tmp) return efl_loop_future_rejected(obj, ENOMEM);
|
||||
v->buffer = tmp;
|
||||
memset(v->buffer + v->buffer_count, 0, rcount - v->buffer_count);
|
||||
v->buffer_count = rcount;
|
||||
|
@ -169,8 +169,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
|
|||
efl_model_properties_changed(obj, property);
|
||||
|
||||
// Return fulfilled future
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj),
|
||||
eina_value_bool_init(!!flag));
|
||||
return efl_loop_future_resolved(obj, eina_value_bool_init(!!flag));
|
||||
}
|
||||
|
||||
/**************** efl_model_composite_boolean **************/
|
||||
|
@ -291,7 +290,7 @@ _efl_model_composite_boolean_efl_model_children_slice_get(Eo *obj,
|
|||
start, count);
|
||||
|
||||
req = malloc(sizeof (Efl_Model_Slice_Request));
|
||||
if (!req) return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
if (!req) return efl_loop_future_rejected(obj,
|
||||
ENOMEM);
|
||||
req->parent = efl_ref(obj);
|
||||
req->start = start;
|
||||
|
|
|
@ -126,8 +126,7 @@ _check_child_change(Efl_Model *child, Eina_Bool value)
|
|||
|
||||
if (prevflag & value)
|
||||
{
|
||||
r = eina_future_resolved(efl_loop_future_scheduler_get(child),
|
||||
eina_value_bool_init(value));
|
||||
r = efl_loop_future_resolved(child, eina_value_bool_init(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -217,10 +216,9 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
|
|||
changed = (!pd->exclusive != !exclusive);
|
||||
pd->exclusive = !!exclusive;
|
||||
|
||||
if (changed)
|
||||
efl_model_properties_changed(obj, "exclusive");
|
||||
if (changed) efl_model_properties_changed(obj, "exclusive");
|
||||
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj), vf);
|
||||
return efl_loop_future_resolved(obj, vf);
|
||||
}
|
||||
|
||||
if (!strcmp("selected", property))
|
||||
|
@ -233,7 +231,7 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
|
|||
success &= eina_value_convert(value, &vl);
|
||||
success &= eina_value_ulong_get(&vl, &l);
|
||||
if (!success)
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj), EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
|
||||
return efl_future_then
|
||||
(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,
|
|||
eina_value_flush(&lvb);
|
||||
|
||||
if (!success)
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj), EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
|
||||
// Nothing changed
|
||||
if (newflag == prevflag)
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_resolved(obj,
|
||||
eina_value_bool_init(newflag));
|
||||
|
||||
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,
|
|||
eina_value_free(vs);
|
||||
|
||||
if (!success)
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
|
||||
// There was, need to unselect the previous one along setting the new value
|
||||
chain = eina_future_all(chain,
|
||||
|
@ -469,7 +466,7 @@ _efl_model_composite_selection_efl_model_children_slice_get(Eo *obj,
|
|||
Eina_Future *f;
|
||||
|
||||
req = calloc(1, sizeof (Selection_Children_Request));
|
||||
if (!req) return eina_future_rejected(efl_loop_future_scheduler_get(obj), ENOMEM);
|
||||
if (!req) return efl_loop_future_rejected(obj, ENOMEM);
|
||||
req->parent = efl_ref(obj);
|
||||
req->start = start;
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ _efl_model_container_efl_model_property_set(Eo *obj,
|
|||
const char *property EINA_UNUSED,
|
||||
Eina_Value *value EINA_UNUSED)
|
||||
{
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ _efl_model_container_efl_model_children_slice_get(Eo *obj,
|
|||
Eina_Value v;
|
||||
|
||||
v = efl_model_list_value_get(sd->childrens, start, count);
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj), v);
|
||||
return efl_loop_future_resolved(obj, v);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
|
|
|
@ -58,12 +58,12 @@ _efl_model_container_item_efl_model_property_set(Eo *obj,
|
|||
|
||||
if (!cpd || !cpd->values ||
|
||||
sd->index >= eina_array_count_get(cpd->values))
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_NOT_FOUND);
|
||||
|
||||
eina_value_setup(&v,cpd->type);
|
||||
if (!eina_value_convert(value, &v))
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
|
||||
// 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,
|
|||
|
||||
free(data);
|
||||
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj), v);
|
||||
return efl_loop_future_resolved(obj, v);
|
||||
|
||||
on_error:
|
||||
eina_value_flush(&v);
|
||||
free(data);
|
||||
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
EFL_MODEL_ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ _efl_model_container_item_efl_model_children_slice_get(Eo *obj,
|
|||
unsigned int start EINA_UNUSED,
|
||||
unsigned int count EINA_UNUSED)
|
||||
{
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj), EINA_VALUE_EMPTY);
|
||||
return efl_loop_future_resolved(obj, EINA_VALUE_EMPTY);
|
||||
}
|
||||
|
||||
EOLIAN static unsigned int
|
||||
|
|
|
@ -97,7 +97,7 @@ _efl_model_item_efl_model_property_set(Eo *obj, Efl_Model_Item_Data *pd, const c
|
|||
|
||||
eina_array_free(evt.changed_properties);
|
||||
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_resolved(obj,
|
||||
eina_value_reference_copy(value));
|
||||
|
||||
hash_failed:
|
||||
|
@ -105,7 +105,7 @@ _efl_model_item_efl_model_property_set(Eo *obj, Efl_Model_Item_Data *pd, const c
|
|||
value_failed:
|
||||
eina_stringshare_del(prop);
|
||||
|
||||
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
|
||||
return efl_loop_future_rejected(obj,
|
||||
ENOMEM);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ _efl_model_item_efl_model_children_slice_get(Eo *obj, Efl_Model_Item_Data *pd, u
|
|||
Eina_Value v;
|
||||
|
||||
v = efl_model_list_value_get(pd->childrens, start, count);
|
||||
return eina_future_resolved(efl_loop_future_scheduler_get(obj), v);
|
||||
return efl_loop_future_resolved(obj, v);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
|
|
Loading…
Reference in New Issue