jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=27573e6e0bfeee08d7e133382729f14ceedac44a

commit 27573e6e0bfeee08d7e133382729f14ceedac44a
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Thu Apr 21 15:39:31 2016 +0900

    Edje: Convert access_part_list to an iterator
---
 src/lib/edje/Edje_Legacy.h  | 11 +++++++
 src/lib/edje/edje_object.eo | 11 +++----
 src/lib/edje/edje_util.c    | 75 +++++++++++++++++++++++++++++++++++++++------
 3 files changed, 80 insertions(+), 17 deletions(-)

diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index e361bef..9e6adf5 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -289,6 +289,17 @@ EAPI Evas_Object *edje_object_part_swallow_get(const 
Edje_Object *obj, const cha
  */
 EAPI void edje_object_part_unswallow(Edje_Object *obj, Evas_Object 
*obj_swallow);
 
+/**
+ * @brief Retrieve a list all accessibility part names
+ *
+ * @return A list all accessibility part names on obj
+ *
+ * @since 1.7.0
+ *
+ * @ingroup Edje_Object
+ */
+EAPI Eina_List *edje_object_access_part_list_get(const Edje_Object *obj);
+
 
 #include "edje_object.eo.legacy.h"
 #include "edje_edit.eo.legacy.h"
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 40e7d7b..a214e5d 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -352,13 +352,10 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File, 
Efl.Container)
             minh: Evas.Coord; [[Pointer to a variable where to store the 
minimum height]]
          }
       }
-      @property access_part_list {
-         get {
-            [[Retrieve a list all accessibility part names
-
-              @since 1.7.0]]
-            return: list<const(char)*> *; [[A list all accessibility part 
names on obj]]
-         }
+      access_part_iterate {
+         [[Iterate over all accessibility-enabled part names.]]
+         legacy: null;
+         return: free(own(iterator<const(char)*> *), eina_iterator_free);
       }
       @property load_error {
          get {
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index e935c8d..8f7899f 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -4942,22 +4942,77 @@ _edje_object_part_box_remove_all(Eo *obj EINA_UNUSED, 
Edje *ed, const char *part
    return ret;
 }
 
-EOLIAN Eina_List *
-_edje_object_access_part_list_get(Eo *obj EINA_UNUSED, Edje *ed)
+typedef struct _Part_Iterator Part_Iterator;
+struct _Part_Iterator
 {
-   Eina_List *access_parts = NULL;
-
-   if ((!ed)) return NULL;
+   Eina_Iterator  iterator;
+   Eo            *object;
+   Edje          *ed;
+   unsigned       index;
+};
 
-   unsigned int i;
-   for (i = 0; i < ed->table_parts_size; i++)
+static Eina_Bool
+_part_iterator_next(Part_Iterator *it, void **data)
+{
+   for (; it->index < it->ed->table_parts_size; it->index++)
      {
-        Edje_Real_Part *rp;
-        rp = ed->table_parts[i];
+        Edje_Real_Part *rp = it->ed->table_parts[it->index];
         if (rp->part->access)
-          access_parts = eina_list_append(access_parts, rp->part->name);
+          {
+             if (data) *data = (void*) rp->part->name;
+             it->index++;
+             return EINA_TRUE;
+          }
      }
 
+   return EINA_FALSE;
+}
+
+static Eo *
+_part_iterator_get_container(Part_Iterator *it)
+{
+   return it->object;
+}
+
+static void
+_part_iterator_free(Part_Iterator *it)
+{
+   free(it);
+}
+
+EOLIAN Eina_Iterator *
+_edje_object_access_part_iterate(Eo *obj EINA_UNUSED, Edje *ed)
+{
+   Part_Iterator *it;
+
+   it = calloc(1, sizeof(*it));
+   if (!it) return NULL;
+
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(_part_iterator_next);
+   it->iterator.get_container = 
FUNC_ITERATOR_GET_CONTAINER(_part_iterator_get_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(_part_iterator_free);
+   it->object = obj;
+   it->ed = ed;
+   it->index = 0;
+
+   return &it->iterator;
+}
+
+EAPI Eina_List *
+edje_object_access_part_list_get(const Edje_Object *obj)
+{
+   Eina_List *access_parts = NULL;
+   Eina_Iterator *it;
+   const char *str;
+
+   it = edje_obj_access_part_iterate((Eo *) obj);
+   EINA_ITERATOR_FOREACH(it, str)
+     access_parts = eina_list_append(access_parts, str);
+   eina_iterator_free(it);
+
    return access_parts;
 }
 

-- 


Reply via email to