q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=cc387bd621b7e2a11f7d6e1be1d280ca02951b9a
commit cc387bd621b7e2a11f7d6e1be1d280ca02951b9a Author: Daniel Kolesa <[email protected]> Date: Wed Jul 9 10:49:52 2014 +0100 eolian: add EOLIAN_TYPE_REGULAR_STRUCT rather than including the struct keyword in name field --- src/lib/eolian/Eolian.h | 1 + src/lib/eolian/eo_parser.c | 15 ++++----------- src/lib/eolian/eolian_database.c | 22 +++++++++++++++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 5687cd8..7c3f4df 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -118,6 +118,7 @@ typedef enum EOLIAN_TYPE_UNKNOWN_TYPE, EOLIAN_TYPE_VOID, EOLIAN_TYPE_REGULAR, + EOLIAN_TYPE_REGULAR_STRUCT, EOLIAN_TYPE_POINTER, EOLIAN_TYPE_FUNCTION, EOLIAN_TYPE_STRUCT diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 45f89e1..da898ac 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -303,22 +303,13 @@ parse_type_struct(Eo_Lexer *ls, Eina_Bool allow_struct, Eina_Bool allow_anon) def->type = EOLIAN_TYPE_VOID; else { - def->type = EOLIAN_TYPE_REGULAR; + def->type = has_struct ? EOLIAN_TYPE_REGULAR_STRUCT : EOLIAN_TYPE_REGULAR; def->is_const = EINA_FALSE; check(ls, TOK_VALUE); ctype = eo_lexer_get_c_type(ls->t.kw); if (ctype && has_struct) eo_lexer_syntax_error(ls, "invalid struct name"); - if (has_struct) - { - Eina_Strbuf *buf = eina_strbuf_new(); - eina_strbuf_append(buf, "struct "); - eina_strbuf_append(buf, ls->t.value); - def->name = eina_stringshare_add(eina_strbuf_string_get(buf)); - eina_strbuf_free(buf); - } - else - def->name = eina_stringshare_add(ctype ? ctype : ls->t.value); + def->name = eina_stringshare_add(ctype ? ctype : ls->t.value); } eo_lexer_get(ls); parse_ptr: @@ -1046,6 +1037,8 @@ _print_type(FILE *f, Eo_Type_Def *tp) fputs("const(", f); if (tp->type == EOLIAN_TYPE_REGULAR) fputs(tp->name, f); + else if (tp->type == EOLIAN_TYPE_REGULAR_STRUCT) + fprintf(f, "struct %s", tp->name); else if (tp->type == EOLIAN_TYPE_POINTER) { _print_type(f, tp->base_type); diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index d8a4d48..0d890b7 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -1168,7 +1168,9 @@ eolian_type_subtypes_list_get(Eolian_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_REGULAR || tpt == EOLIAN_TYPE_POINTER, NULL); + EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_REGULAR + || tpt == EOLIAN_TYPE_POINTER + || tpt == EOLIAN_TYPE_REGULAR_STRUCT, NULL); if (!tpp->subtypes) return NULL; return eina_list_iterator_new(tpp->subtypes); } @@ -1295,11 +1297,20 @@ _type_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) _stype_to_str(tp, buf, name); return; } - if ((tpp->type == EOLIAN_TYPE_REGULAR || tpp->type == EOLIAN_TYPE_VOID) + if ((tpp->type == EOLIAN_TYPE_REGULAR + || tpp->type == EOLIAN_TYPE_REGULAR_STRUCT + || tpp->type == EOLIAN_TYPE_VOID) && tpp->is_const) - eina_strbuf_append(buf, "const "); + { + eina_strbuf_append(buf, "const "); + } if (tpp->type == EOLIAN_TYPE_REGULAR) eina_strbuf_append(buf, tpp->name); + else if (tpp->type == EOLIAN_TYPE_REGULAR_STRUCT) + { + eina_strbuf_append(buf, "struct "); + eina_strbuf_append(buf, tpp->name); + } else if (tpp->type == EOLIAN_TYPE_VOID) eina_strbuf_append(buf, "void"); else @@ -1391,6 +1402,11 @@ _type_print(Eolian_Type tp, Eina_Strbuf *buf) eina_strbuf_append(buf, "const("); if (tpp->type == EOLIAN_TYPE_REGULAR) eina_strbuf_append(buf, tpp->name); + else if (tpp->type == EOLIAN_TYPE_REGULAR_STRUCT) + { + eina_strbuf_append(buf, "struct "); + eina_strbuf_append(buf, tpp->name); + } else if (tpp->type == EOLIAN_TYPE_POINTER) { _type_print(tpp->base_type, buf); --
