From 460cfd9e34f7b515e15badb952e1a7c49b409a94 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 21 Jul 2014 14:38:43 +0100 Subject: [PATCH] eolian: type_struct_description, type_struct_file -> type_description, type_file --- src/lib/eolian/Eolian.h | 8 ++++---- src/lib/eolian/database_type_api.c | 18 +++++++++++++----- src/lib/eolian/eolian_database.h | 3 ++- src/tests/eolian/eolian_parsing.c | 4 ++-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index b283f176e4..313843202a 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -867,24 +867,24 @@ EAPI const Eolian_Type *eolian_type_struct_field_get(const Eolian_Type *tp, cons EAPI Eina_Stringshare *eolian_type_struct_field_description_get(const Eolian_Type *tp, const char *field); /* - * @brief Get the description of a struct type. + * @brief Get the description of a struct/alias type. * * @param[in] tp the type. * @return the description when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise. * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_struct_description_get(const Eolian_Type *tp); +EAPI Eina_Stringshare *eolian_type_description_get(const Eolian_Type *tp); /* - * @brief Get the filename of a struct type. + * @brief Get the filename of a struct/alias type. * * @param[in] tp the type. * @return the filename when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise. * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_struct_file_get(const Eolian_Type *tp); +EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp); /* * @brief Get the return type of a function type. diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 1e31b801bc..485353aaa0 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -104,18 +104,26 @@ eolian_type_struct_field_description_get(const Eolian_Type *tp, const char *fiel } EAPI Eina_Stringshare * -eolian_type_struct_description_get(const Eolian_Type *tp) +eolian_type_description_get(const Eolian_Type *tp) { + Eolian_Type_Type tpp; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, NULL); - return tp->comment; + 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->comment); } EAPI Eina_Stringshare * -eolian_type_struct_file_get(const Eolian_Type *tp) +eolian_type_file_get(const Eolian_Type *tp) { + Eolian_Type_Type tpp; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, 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->file); } diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 76ea38355b..bec161b21a 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -100,7 +100,7 @@ struct _Eolian_Type { Eolian_Type_Type type; union { - /* pointers */ + /* pointers and regular types */ struct { Eina_List *subtypes; Eolian_Type *base_type; @@ -112,6 +112,7 @@ struct _Eolian_Type }; /* structs, aliases, regular types */ struct { + void *pad; /* make space for subtypes */ Eina_Stringshare *name; /* all */ Eina_Stringshare *full_name; /* all */ Eina_List *namespaces; /* all */ diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index c6429d3cba..128c6d2a68 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -508,7 +508,7 @@ START_TEST(eolian_struct) /* named struct */ fail_if(!(type = eolian_type_struct_find_by_name("Named"))); fail_if(!(type_name = eolian_type_name_get(type))); - fail_if(!(file = eolian_type_struct_file_get(type))); + fail_if(!(file = eolian_type_file_get(type))); fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT); fail_if(eolian_type_is_own(type)); fail_if(eolian_type_is_const(type)); @@ -528,7 +528,7 @@ START_TEST(eolian_struct) /* referencing */ fail_if(!(type = eolian_type_struct_find_by_name("Another"))); fail_if(!(type_name = eolian_type_name_get(type))); - fail_if(!(file = eolian_type_struct_file_get(type))); + fail_if(!(file = eolian_type_file_get(type))); fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT); fail_if(strcmp(type_name, "Another")); eina_stringshare_del(type_name);