eolian: new APIs: eolian_type_full_name_get, eolian_type_naespaces_list_get
authorDaniel Kolesa <d.kolesa@samsung.com>
Mon, 21 Jul 2014 13:27:23 +0000 (14:27 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Mon, 21 Jul 2014 13:27:23 +0000 (14:27 +0100)
src/lib/eolian/Eolian.h
src/lib/eolian/database_type_api.c
src/lib/eolian/eolian_database.h

index c276257..b283f17 100644 (file)
@@ -975,17 +975,41 @@ EAPI Eina_Stringshare *eolian_type_c_type_named_get(const Eolian_Type *tp, const
 EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
 
 /*
- * @brief Get the type name of the given type. You have to manually delete
- * the stringshare.
+ * @brief Get the name of the given type. You have to manually delete
+ * the stringshare. For EOLIAN_TYPE_REGULAR and EOLIAN_TYPE_REGULAR_STRUCT,
+ * this is for example "int". For EOLIAN_TYPE_STRUCT and EOLIAN_TYPE_ALIAS,
+ * this is the name of the alias or of the struct. Keep in mind that the name
+ * doesn't include namespaces for structs and aliases.
  *
  * @param[in] tp the type.
- * @return the name assuming @c tp is an EOLIAN_TYPE_REGULAR, NULL otherwise.
- * The name may include a "struct" keyword.
+ * @return the name.
  *
  * @ingroup Eolian
  */
 EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp);
 
+/*
+ * @brief Get the full (namespaced) name of a function. Only works on named
+ * types (not pointers, not functions, not void).
+ *
+ * @param[in] tp the type.
+ * @return the name.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_type_full_name_get(const Eolian_Type *tp);
+
+/*
+ * @brief Get an iterator to the list of namespaces of the given type. Only
+ * works on named types (not pointers, not functions, not void).
+ *
+ * @param[in] tp the type.
+ * @return the iterator.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_type_namespaces_list_get(const Eolian_Type *tp);
+
 #endif
 
 #ifdef __cplusplus
index 7078283..1e31b80 100644 (file)
@@ -180,7 +180,36 @@ eolian_type_c_type_get(const Eolian_Type *tp)
 EAPI Eina_Stringshare *
 eolian_type_name_get(const Eolian_Type *tp)
 {
+   Eolian_Type_Type tpp;
    EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
-   eina_stringshare_ref(tp->name);
-   return tp->name;
+   tpp = eolian_type_type_get(tp);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
+                                && tpp != EOLIAN_TYPE_FUNCTION
+                                && tpp != EOLIAN_TYPE_VOID, NULL);
+   return eina_stringshare_ref(tp->name);
+}
+
+EAPI Eina_Stringshare *
+eolian_type_full_name_get(const Eolian_Type *tp)
+{
+   Eolian_Type_Type tpp;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+   tpp = eolian_type_type_get(tp);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
+                                && tpp != EOLIAN_TYPE_FUNCTION
+                                && tpp != EOLIAN_TYPE_VOID, NULL);
+   return eina_stringshare_ref(tp->full_name);
+}
+
+EAPI Eina_Iterator *
+eolian_type_namespaces_list_get(const Eolian_Type *tp)
+{
+   Eolian_Type_Type tpp;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+   tpp = eolian_type_type_get(tp);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp != EOLIAN_TYPE_POINTER
+                                && tpp != EOLIAN_TYPE_FUNCTION
+                                && tpp != EOLIAN_TYPE_VOID, NULL);
+   if (!tp->namespaces) return NULL;
+   return eina_list_iterator_new(tp->namespaces);
 }
index 47c6263..76ea383 100644 (file)
@@ -113,8 +113,8 @@ struct _Eolian_Type
       /* structs, aliases, regular types */
       struct {
          Eina_Stringshare *name;       /* all */
-         Eina_Stringshare *full_name;  /* structs, aliases */
-         Eina_List        *namespaces; /* structs, aliases */
+         Eina_Stringshare *full_name;  /* all */
+         Eina_List        *namespaces; /* all */
          Eina_Hash        *fields;     /* structs */
          Eina_Stringshare *comment;    /* structs, aliases */
          Eina_Stringshare *file;       /* structs, aliases */