raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=26b5eb8a26c196ac2d707766e938c9a35982eb98

commit 26b5eb8a26c196ac2d707766e938c9a35982eb98
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu Apr 21 15:15:13 2016 +0900

    eo base - add loop_get for base class
    
    base class objects will ask their parent object to get the loop. this
    means it recurses all objects regardless of type until it finds an
    object that returns a proper loop object - eg a loop object returns
    itself, a window, gfx/ui object returns the mainloop object etc. etc.
    
    @feature
---
 src/lib/eo/eo_base.eo                | 18 ++++++++++++++++++
 src/lib/eo/eo_base_class.c           |  8 ++++++++
 src/tests/eo/suite/eo_test_general.c | 18 ++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo
index a804e1b..d1fc1ab 100644
--- a/src/lib/eo/eo_base.eo
+++ b/src/lib/eo/eo_base.eo
@@ -137,6 +137,24 @@ abstract Eo.Base ()
             finalized: bool;
          }
       }
+      @property loop {
+         [[The owning loop object.
+
+           Objects that have anything to do with I/O, time based events
+           or anything async should have an owining loop. They will ask
+           their parent for the owning loop and iterate until the
+           toplevel/root object. The root object should be a loop object
+           which will return itself. Some objects may shortcut this
+           and be fixed to live in only a single loop. Either way all
+           you need to do is get the loop for an object and use that
+           for I/O, timing etc. needs.
+         ]]
+         get {
+         }
+         values {
+            obj: Eo.Base *; [[ XXX: this should be Efl.Loop *; ]]
+         }
+      }
       constructor {
          [[Call the object's constructor.
 
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 16c0d4f..f81e54e 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -682,6 +682,14 @@ _eo_base_finalized_get(Eo *obj_id, Eo_Base_Data *pd 
EINA_UNUSED)
    return obj->finalized;
 }
 
+// XXX: this should be Efl_Loop *;
+EOLIAN static Eo_Base *
+_eo_base_loop_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
+{
+   if (!pd->parent) return eo_loop_get(pd->parent);
+   return NULL;
+}
+
 /* Children accessor */
 typedef struct _Eo_Children_Iterator Eo_Children_Iterator;
 struct _Eo_Children_Iterator
diff --git a/src/tests/eo/suite/eo_test_general.c 
b/src/tests/eo/suite/eo_test_general.c
index 44d39d2..2980c19 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -1139,6 +1139,23 @@ START_TEST(eo_comment)
 }
 END_TEST
 
+START_TEST(eo_loop)
+{
+   eo_init();
+   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+   Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
+   Eo *objtmp;
+
+   eo_parent_set(obj2, obj);
+   objtmp = eo_loop_get(obj2);
+   fail_if(NULL != objtmp);
+
+   eo_del(obj);
+
+   eo_shutdown();
+}
+END_TEST
+
 void eo_test_general(TCase *tc)
 {
    tcase_add_test(tc, eo_simple);
@@ -1159,4 +1176,5 @@ void eo_test_general(TCase *tc)
    tcase_add_test(tc, eo_del_intercept);
    tcase_add_test(tc, eo_name);
    tcase_add_test(tc, eo_comment);
+   tcase_add_test(tc, eo_loop);
 }

-- 


Reply via email to