q66 pushed a commit to branch master.

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

commit 881a8754abf8f0b9b09897fa5e38e5db34a7a413
Author: Daniel Kolesa <[email protected]>
Date:   Wed Jul 9 12:48:16 2014 +0100

    eolian: new API: eolian_type_struct_description_get
---
 src/lib/eolian/Eolian.h          | 10 ++++++++++
 src/lib/eolian/eo_definitions.h  |  5 ++++-
 src/lib/eolian/eo_parser.c       |  5 +++++
 src/lib/eolian/eolian_database.c | 26 ++++++++++++++++----------
 4 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 6a32215..bb78223 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -795,6 +795,16 @@ EAPI Eolian_Type eolian_type_struct_field_get(Eolian_Type 
tp, const char *field)
 EAPI const char *eolian_type_struct_field_description_get(Eolian_Type tp, 
const char *field);
 
 /*
+ * @brief Get the description of a struct type.
+ *
+ * @param[in] tp the type.
+ * @return the description when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise.
+ *
+ * @ingroup Eolian
+ */
+EAPI const char *eolian_type_struct_description_get(Eolian_Type tp);
+
+/*
  * @brief Get the return type of a function type.
  *
  * @param[in] tp the type.
diff --git a/src/lib/eolian/eo_definitions.h b/src/lib/eolian/eo_definitions.h
index 60a7cd7..58b924c 100644
--- a/src/lib/eolian/eo_definitions.h
+++ b/src/lib/eolian/eo_definitions.h
@@ -20,7 +20,10 @@ struct _eo_type_def
          Eina_List   *arguments;
          Eo_Type_Def *ret_type;
       };
-      Eina_Hash *fields;
+      struct {
+         Eina_Hash  *fields;
+         const char *comment;
+      };
    };
    Eina_Bool is_const  :1;
    Eina_Bool is_own    :1;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index d204756..91eb8a0 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -231,6 +231,11 @@ parse_struct(Eo_Lexer *ls, const char *name)
    def->type = EOLIAN_TYPE_STRUCT;
    def->fields = 
eina_hash_string_small_new(EINA_FREE_CB(eo_definitions_struct_field_free));
    check_next(ls, '{');
+   if (ls->t.token == TOK_COMMENT)
+     {
+        def->comment = eina_stringshare_add(ls->t.value);
+        eo_lexer_get(ls);
+     }
    while (ls->t.token != '}')
      {
         const char *fname;
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index a5dc46c..5d823e2 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -97,7 +97,10 @@ typedef struct
          Eina_List   *arguments;
          Eolian_Type  ret_type;
       };
-      Eina_Hash *fields;
+      struct {
+         Eina_Hash  *fields;
+         const char *comment;
+      };
    };
    Eina_Bool is_const  :1;
    Eina_Bool is_own    :1;
@@ -1186,10 +1189,8 @@ EAPI Eina_Iterator *
 eolian_type_struct_field_names_list_get(Eolian_Type tp)
 {
    _Parameter_Type *tpp = (_Parameter_Type*)tp;
-   Eolian_Type_Type tpt;
    EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
-   tpt = tpp->type;
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
    return eina_hash_iterator_key_new(tpp->fields);
 }
 
@@ -1198,11 +1199,9 @@ eolian_type_struct_field_get(Eolian_Type tp, const char 
*field)
 {
    _Parameter_Type *tpp = (_Parameter_Type*)tp;
    _Struct_Field_Type *sf = NULL;
-   Eolian_Type_Type tpt;
    EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
-   tpt = tpp->type;
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
    sf = eina_hash_find(tpp->fields, field);
    if (!sf) return NULL;
    return sf->type;
@@ -1213,16 +1212,23 @@ eolian_type_struct_field_description_get(Eolian_Type 
tp, const char *field)
 {
    _Parameter_Type *tpp = (_Parameter_Type*)tp;
    _Struct_Field_Type *sf = NULL;
-   Eolian_Type_Type tpt;
    EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
-   tpt = tpp->type;
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
    sf = eina_hash_find(tpp->fields, field);
    if (!sf) return NULL;
    return sf->comment;
 }
 
+EAPI const char *
+eolian_type_struct_description_get(Eolian_Type tp)
+{
+   _Parameter_Type *tpp = (_Parameter_Type*)tp;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
+   return tpp->comment;
+}
+
 EAPI Eolian_Type
 eolian_type_return_type_get(Eolian_Type tp)
 {

-- 


Reply via email to