eolian: new APIs: eolian_type_full_name_get, eolian_type_naespaces_list_get

This commit is contained in:
Daniel Kolesa 2014-07-21 14:27:23 +01:00
parent 197034bfd7
commit 7117aad879
3 changed files with 61 additions and 8 deletions

View 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); 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 * @brief Get the name of the given type. You have to manually delete
* the stringshare. * 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. * @param[in] tp the type.
* @return the name assuming @c tp is an EOLIAN_TYPE_REGULAR, NULL otherwise. * @return the name.
* The name may include a "struct" keyword.
* *
* @ingroup Eolian * @ingroup Eolian
*/ */
EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp); 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 #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -180,7 +180,36 @@ eolian_type_c_type_get(const Eolian_Type *tp)
EAPI Eina_Stringshare * EAPI Eina_Stringshare *
eolian_type_name_get(const Eolian_Type *tp) eolian_type_name_get(const Eolian_Type *tp)
{ {
Eolian_Type_Type tpp;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
eina_stringshare_ref(tp->name); tpp = eolian_type_type_get(tp);
return tp->name; 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);
} }

View File

@ -113,8 +113,8 @@ struct _Eolian_Type
/* structs, aliases, regular types */ /* structs, aliases, regular types */
struct { struct {
Eina_Stringshare *name; /* all */ Eina_Stringshare *name; /* all */
Eina_Stringshare *full_name; /* structs, aliases */ Eina_Stringshare *full_name; /* all */
Eina_List *namespaces; /* structs, aliases */ Eina_List *namespaces; /* all */
Eina_Hash *fields; /* structs */ Eina_Hash *fields; /* structs */
Eina_Stringshare *comment; /* structs, aliases */ Eina_Stringshare *comment; /* structs, aliases */
Eina_Stringshare *file; /* structs, aliases */ Eina_Stringshare *file; /* structs, aliases */