q66 pushed a commit to branch master.

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

commit e089908545a23a9be59f4014906ad82b872aeafa
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Wed Nov 18 16:02:15 2015 +0000

    eolian: add eolian_type_aliased_base_get
    
    This adds a new API function that is there mainly for convenience (see doc).
    Also added/updated tests as necessary.
    
    @feature
---
 src/lib/eolian/Eolian.h             | 17 +++++++++++++++++
 src/lib/eolian/database_type_api.c  | 17 +++++++++++++++++
 src/tests/eolian/data/typedef.eo    |  3 +++
 src/tests/eolian/data/typedef_ref.c |  4 ++++
 src/tests/eolian/eolian_parsing.c   |  8 ++++++++
 5 files changed, 49 insertions(+)

diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 9f47a98..2aeb664 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1496,6 +1496,23 @@ EAPI Eina_Stringshare *eolian_type_file_get(const 
Eolian_Type *tp);
 EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
 
 /*
+ * @brief Get the lowest base type of an alias stack.
+ *
+ * If the given type is an alias, it returns the result of a recursive call
+ * to this function on its base type. If it's a regular type, it first tries
+ * to retrieve its base using eolian_type_base_type_get and if the retrieved
+ * base is an alias, returns a recursive call of this function on it. Otherwise
+ * it returns the given type. This is useful in order to retrieve what an
+ * aliased type actually is while still having convenience.
+ *
+ * @param[in] tp the type.
+ * @return the lowest alias base or the given type.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
+
+/*
  * @brief Get the class associated with an EOLIAN_TYPE_CLASS type.
  *
  * @param[in] tp the type.
diff --git a/src/lib/eolian/database_type_api.c 
b/src/lib/eolian/database_type_api.c
index 6030fa3..fae0428 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -251,6 +251,23 @@ eolian_type_base_type_get(const Eolian_Type *tp)
    return tp->base_type;
 }
 
+EAPI const Eolian_Type *
+eolian_type_aliased_base_get(const Eolian_Type *tp)
+{
+   if (!tp)
+     return NULL;
+   if (eolian_type_type_get(tp) == EOLIAN_TYPE_REGULAR)
+     {
+        const Eolian_Type *btp = eolian_type_base_type_get(tp);
+        if (btp && (eolian_type_type_get(btp) == EOLIAN_TYPE_ALIAS))
+          return eolian_type_aliased_base_get(btp);
+        return tp;
+     }
+   else if (eolian_type_type_get(tp) != EOLIAN_TYPE_ALIAS)
+     return tp;
+   return eolian_type_aliased_base_get(tp->base_type);
+}
+
 EAPI const Eolian_Class *
 eolian_type_class_get(const Eolian_Type *tp)
 {
diff --git a/src/tests/eolian/data/typedef.eo b/src/tests/eolian/data/typedef.eo
index 2df00c0..0e4a647 100644
--- a/src/tests/eolian/data/typedef.eo
+++ b/src/tests/eolian/data/typedef.eo
@@ -1,6 +1,9 @@
 type Evas.Coord: int; /* Simple type definition */
 type List_Objects: own(list<Eo *>*); /* A little more complex */
 
+type Evas.Coord2: Evas.Coord;
+type Evas.Coord3: Evas.Coord2;
+
 type @extern Evas.Pants: float; /* not generated */
 
 type Undef: __undefined_type; /* not generated */
diff --git a/src/tests/eolian/data/typedef_ref.c 
b/src/tests/eolian/data/typedef_ref.c
index e4b6993..cf661c1 100644
--- a/src/tests/eolian/data/typedef_ref.c
+++ b/src/tests/eolian/data/typedef_ref.c
@@ -15,6 +15,10 @@ typedef int Evas_Coord;
 
 typedef Eina_List *List_Objects;
 
+typedef Evas_Coord Evas_Coord2;
+
+typedef Evas_Coord2 Evas_Coord3;
+
 typedef enum
 {
   BAR_FIRST_ITEM = 0,
diff --git a/src/tests/eolian/eolian_parsing.c 
b/src/tests/eolian/eolian_parsing.c
index 6b37c4d..c104a61 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -369,6 +369,11 @@ START_TEST(eolian_typedef)
    fail_if(!(file = eolian_type_file_get(atype)));
    fail_if(strcmp(file, "typedef.eo"));
 
+   /* Lowest alias base */
+   fail_if(!(atype = eolian_type_alias_get_by_name("Evas.Coord3")));
+   fail_if(!(atype = eolian_type_aliased_base_get(atype)));
+   fail_if(strcmp(eolian_type_name_get(atype), "int"));
+
    /* Complex type */
    fail_if(!(atype = eolian_type_alias_get_by_name("List_Objects")));
    fail_if(!(type_name = eolian_type_name_get(atype)));
@@ -395,6 +400,9 @@ START_TEST(eolian_typedef)
    fail_if(!eina_iterator_next(iter, (void**)&atype));
    fail_if(!(type_name = eolian_type_name_get(atype)));
    fail_if(strcmp(type_name, "List_Objects"));
+   /* coord2 and coord3, skip */
+   fail_if(!eina_iterator_next(iter, (void**)&atype));
+   fail_if(!eina_iterator_next(iter, (void**)&atype));
    /* not generated extern, skip */
    fail_if(!eina_iterator_next(iter, (void**)&atype));
    /* not generated undefined type, skip */

-- 


Reply via email to