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