eolian: update eolian_type_base_type_get for REGULAR types
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Tue, 12 May 2015 13:27:02 +0000 (14:27 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Tue, 12 May 2015 13:27:24 +0000 (14:27 +0100)
src/lib/eolian/Eolian.h
src/lib/eolian/database_type_api.c

index 77b26b0ea96a574a4da0b805423b08af2a7f925e..af2d575e5c430616b9019b2be88b18a4b4d99d57 100644 (file)
@@ -1619,7 +1619,10 @@ EAPI Eina_Stringshare *eolian_type_description_get(const Eolian_Type *tp);
 EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
 
 /*
- * @brief Get the base type of a pointer or alias type.
+ * @brief Get the base type of a pointer, alias or regular type.
+ *
+ * For pointers and aliases, it's a simple lookup. For regular types, it
+ * tries to look up alias, struct and enum in that order.
  *
  * @param[in] tp the type.
  * @return the base type when @c tp is a pointer or alias, NULL otherwise.
index b755471f1e2daf0894ae92ddf38b3b40c1b65f17..8f955906da95a47dfb95f6fa92ad9be02ae9d556 100644 (file)
@@ -204,7 +204,23 @@ eolian_type_base_type_get(const Eolian_Type *tp)
    Eolian_Type_Type tpt;
    EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
    tpt = eolian_type_type_get(tp);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_ALIAS, NULL);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_POINTER
+                                || tpt == EOLIAN_TYPE_ALIAS
+                                || tpt == EOLIAN_TYPE_REGULAR, NULL);
+   if (tpt == EOLIAN_TYPE_REGULAR)
+     {
+        /* for regular types, try looking up if it belongs to a struct,
+         * enum or an alias... otherwise return NULL
+         */
+       Eolian_Type *rtp;
+       rtp = eina_hash_find(_aliases, tp->full_name);
+       if (rtp) return rtp;
+       rtp = eina_hash_find(_structs, tp->full_name);
+       if (rtp) return rtp;
+       rtp = eina_hash_find(_enums, tp->full_name);
+       if (rtp) return rtp;
+       return NULL;
+     }
    return tp->base_type;
 }