summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_model.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-16 21:50:37 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-16 22:01:07 -0300
commit8e4f383d61188020d5ceeee691fd7df761f10202 (patch)
treeb747603d70956b51d2ba719a3c4cfb710904bbb4 /src/lib/eio/eio_model.c
parent52e2774523209655e868d1244f0e2dd3b2d44491 (diff)
efl: Move promise parameter to return in data model
Summary: Instead of: efl_model_property_get("name", &promise); now: promise = efl_model_property_get("name"); Reviewers: stefan_schmidt, cedric Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D4038
Diffstat (limited to 'src/lib/eio/eio_model.c')
-rw-r--r--src/lib/eio/eio_model.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index 7b8589f..3f2bcdd 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -288,18 +288,20 @@ _eio_model_efl_model_properties_get(Eo *obj EINA_UNUSED, Eio_Model_Data *_pd)
288/** 288/**
289 * Property Get 289 * Property Get
290 */ 290 */
291static void 291static Eina_Promise*
292_eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *property, Eina_Promise_Owner *promise) 292_eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *property)
293{ 293{
294 _Eio_Property_Name property_name; 294 _Eio_Property_Name property_name;
295 const char* value = NULL; 295 const char* value = NULL;
296 296 Eina_Promise_Owner *promise = eina_promise_add();
297 EINA_SAFETY_ON_NULL_RETURN(priv); 297 Eina_Promise *rpromise = eina_promise_owner_promise_get(promise);
298
299 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, rpromise);
298 300
299 if (property == NULL) 301 if (property == NULL)
300 { 302 {
301 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 303 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
302 return; 304 return rpromise;
303 } 305 }
304 306
305 if(strcmp(_eio_model_prop_names[EIO_MODEL_PROP_FILENAME], property) == 0) 307 if(strcmp(_eio_model_prop_names[EIO_MODEL_PROP_FILENAME], property) == 0)
@@ -321,7 +323,7 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
321 if (value == NULL) 323 if (value == NULL)
322 { 324 {
323 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 325 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
324 return; 326 return rpromise;
325 } 327 }
326 property_name = EIO_MODEL_PROP_MIME_TYPE; 328 property_name = EIO_MODEL_PROP_MIME_TYPE;
327 } 329 }
@@ -336,7 +338,7 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
336 else 338 else
337 { 339 {
338 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 340 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
339 return; 341 return rpromise;
340 } 342 }
341 343
342 switch(property_name) 344 switch(property_name)
@@ -362,6 +364,7 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
362 } 364 }
363 break; 365 break;
364 } 366 }
367 return rpromise;
365} 368}
366 369
367/** 370/**
@@ -417,12 +420,15 @@ _eio_model_efl_model_property_set(Eo *obj EINA_UNUSED,
417/** 420/**
418 * Children Count Get 421 * Children Count Get
419 */ 422 */
420static void 423static Eina_Promise*
421_eio_model_efl_model_children_count_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eina_Promise_Owner *promise) 424_eio_model_efl_model_children_count_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
422{ 425{
426 Eina_Promise_Owner *promise = eina_promise_add();
427 Eina_Promise* rpromise = eina_promise_owner_promise_get(promise);
423 unsigned int *c = calloc(sizeof(unsigned int), 1); 428 unsigned int *c = calloc(sizeof(unsigned int), 1);
424 *c = eina_list_count(priv->children_list); 429 *c = eina_list_count(priv->children_list);
425 eina_promise_owner_value_set(promise, c, free); 430 eina_promise_owner_value_set(promise, c, free);
431 return rpromise;
426} 432}
427 433
428static void 434static void
@@ -596,10 +602,12 @@ _eio_model_efl_model_child_del(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eo *ch
596/** 602/**
597 * Children Slice Get 603 * Children Slice Get
598 */ 604 */
599static void 605static Eina_Promise*
600_eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, 606_eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv,
601 unsigned start, unsigned count, Eina_Promise_Owner *promise) 607 unsigned int start, unsigned int count)
602{ 608{
609 Eina_Promise_Owner *promise = eina_promise_add();
610 Eina_Promise* rpromise = eina_promise_owner_promise_get(promise);
603 /** 611 /**
604 * children must be already loaded otherwise we do nothing 612 * children must be already loaded otherwise we do nothing
605 * and parameter is set to NULL. 613 * and parameter is set to NULL.
@@ -607,7 +615,7 @@ _eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *pri
607 if (!priv->path) 615 if (!priv->path)
608 { 616 {
609 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_INIT_FAILED); 617 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_INIT_FAILED);
610 return; 618 return rpromise;
611 } 619 }
612 620
613 if (!(priv->is_listed)) 621 if (!(priv->is_listed))
@@ -627,11 +635,12 @@ _eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *pri
627 _eio_main_children_load_cb, _eio_done_children_load_cb, 635 _eio_main_children_load_cb, _eio_done_children_load_cb,
628 _eio_error_children_load_cb, priv); 636 _eio_error_children_load_cb, priv);
629 } 637 }
630 return; 638 return rpromise;
631 } 639 }
632 640
633 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, start, count); 641 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, start, count);
634 eina_promise_owner_value_set(promise, accessor, (Eina_Promise_Free_Cb)&eina_accessor_free); 642 eina_promise_owner_value_set(promise, accessor, (Eina_Promise_Free_Cb)&eina_accessor_free);
643 return rpromise;
635} 644}
636 645
637 646