q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=10843dc0e232367e89e1bd721d301d1930a47fc0
commit 10843dc0e232367e89e1bd721d301d1930a47fc0 Author: Daniel Kolesa <d.kol...@samsung.com> Date: Wed Sep 10 16:17:47 2014 +0100 eolian: remove Eo_Ret_Def --- src/lib/eolian/database_fill.c | 71 +++++++++++++++++++---------------------- src/lib/eolian/eo_definitions.c | 48 +++++++++++++++------------- src/lib/eolian/eo_definitions.h | 35 ++++++++++---------- src/lib/eolian/eo_parser.c | 62 ++++++++++++++++++++++++++--------- 4 files changed, 122 insertions(+), 94 deletions(-) diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c index f38b914..d0081cd 100644 --- a/src/lib/eolian/database_fill.c +++ b/src/lib/eolian/database_fill.c @@ -10,27 +10,27 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) foo_id->is_class = prop->is_class; foo_id->keys = prop->keys ; prop->keys = NULL; - foo_id->params = prop->values; prop->values = NULL; + foo_id->params = prop->params; prop->params = NULL; - if (prop->get_ret) + if (prop->get_ret_type) { - foo_id->get_ret_type = prop->get_ret->type; - prop->get_ret->type = NULL; - foo_id->get_ret_val = prop->get_ret->default_ret_val; - prop->get_ret->default_ret_val = NULL; - foo_id->get_return_comment = prop->get_ret->comment; - prop->get_ret->comment = NULL; - foo_id->get_return_warn_unused = prop->get_ret->warn_unused; + foo_id->get_ret_type = prop->get_ret_type; + prop->get_ret_type = NULL; + foo_id->get_ret_val = prop->get_ret_val; + prop->get_ret_val = NULL; + foo_id->get_return_comment = prop->get_return_comment; + prop->get_return_comment = NULL; + foo_id->get_return_warn_unused = prop->get_return_warn_unused; } - if (prop->set_ret) + if (prop->set_ret_type) { - foo_id->set_ret_type = prop->set_ret->type; - prop->set_ret->type = NULL; - foo_id->set_ret_val = prop->set_ret->default_ret_val; - prop->set_ret->default_ret_val = NULL; - foo_id->set_return_comment = prop->set_ret->comment; - prop->set_ret->comment = NULL; - foo_id->set_return_warn_unused = prop->set_ret->warn_unused; + foo_id->set_ret_type = prop->set_ret_type; + prop->set_ret_type = NULL; + foo_id->set_ret_val = prop->set_ret_val; + prop->set_ret_val = NULL; + foo_id->set_return_comment = prop->set_return_comment; + prop->set_return_comment = NULL; + foo_id->set_return_warn_unused = prop->set_return_warn_unused; } if (prop->get_legacy) @@ -46,25 +46,23 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) foo_id->get_only_legacy = prop->get_only_legacy; foo_id->set_only_legacy = prop->set_only_legacy; - if (prop->get_comment) + if (prop->get_description) { - foo_id->get_description = prop->get_comment; - prop->get_comment = NULL; + foo_id->get_description = prop->get_description; + prop->get_description = NULL; } - if (prop->set_comment) + if (prop->set_description) { - foo_id->set_description = prop->set_comment; - prop->set_comment = NULL; + foo_id->set_description = prop->set_description; + prop->set_description = NULL; } + foo_id->type = prop->type; + if (prop->get_accessor) { if (kls->type == EOLIAN_CLASS_INTERFACE) foo_id->get_virtual_pure = EINA_TRUE; - if (foo_id->type == EOLIAN_PROP_SET) - foo_id->type = EOLIAN_PROPERTY; - else - foo_id->type = EOLIAN_PROP_GET; foo_id->base = prop->base; prop->base.file = NULL; } @@ -73,10 +71,6 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) { if (kls->type == EOLIAN_CLASS_INTERFACE) foo_id->set_virtual_pure = EINA_TRUE; - if (foo_id->type == EOLIAN_PROP_GET) - foo_id->type = EOLIAN_PROPERTY; - else - foo_id->type = EOLIAN_PROP_SET; foo_id->set_base = prop->set_base; prop->set_base.file = NULL; } @@ -112,14 +106,15 @@ _db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth) cl->methods = eina_list_append(cl->methods, foo_id); - if (meth->ret) + if (meth->ret_type) { - foo_id->get_ret_type = meth->ret->type; - foo_id->get_return_comment = eina_stringshare_ref(meth->ret->comment); - foo_id->get_return_warn_unused = meth->ret->warn_unused; - foo_id->get_ret_val = meth->ret->default_ret_val; - meth->ret->type = NULL; - meth->ret->default_ret_val = NULL; + foo_id->get_ret_type = meth->ret_type; + meth->ret_type = NULL; + foo_id->get_return_comment = meth->ret_comment; + meth->ret_comment = NULL; + foo_id->get_return_warn_unused = meth->ret_warn_unused; + foo_id->get_ret_val = meth->default_ret_val; + meth->default_ret_val = NULL; } foo_id->get_description = eina_stringshare_ref(meth->comment); diff --git a/src/lib/eolian/eo_definitions.c b/src/lib/eolian/eo_definitions.c index 8a77ca2..4511e39 100644 --- a/src/lib/eolian/eo_definitions.c +++ b/src/lib/eolian/eo_definitions.c @@ -4,15 +4,6 @@ #include "eo_definitions.h" static void -eo_definitions_ret_free(Eo_Ret_Def *ret) -{ - if (ret->type) database_type_del(ret->type); - if (ret->comment) eina_stringshare_del(ret->comment); - database_expr_del(ret->default_ret_val); - free(ret); -} - -static void eo_definitions_property_def_free(Eo_Property_Def *prop) { Eolian_Function_Parameter *param; @@ -26,14 +17,14 @@ eo_definitions_property_def_free(Eo_Property_Def *prop) EINA_LIST_FREE(prop->keys, param) database_parameter_del(param); - EINA_LIST_FREE(prop->values, param) + EINA_LIST_FREE(prop->params, param) database_parameter_del(param); - if (prop->get_comment) - eina_stringshare_del(prop->get_comment); + if (prop->get_description) + eina_stringshare_del(prop->get_description); - if (prop->set_comment) - eina_stringshare_del(prop->set_comment); + if (prop->set_description) + eina_stringshare_del(prop->set_description); if (prop->get_legacy) eina_stringshare_del(prop->get_legacy); @@ -41,11 +32,20 @@ eo_definitions_property_def_free(Eo_Property_Def *prop) if (prop->set_legacy) eina_stringshare_del(prop->set_legacy); - if (prop->get_ret) - eo_definitions_ret_free(prop->get_ret); + if (prop->get_ret_type) + database_type_del(prop->get_ret_type); + + if (prop->set_ret_type) + database_type_del(prop->set_ret_type); - if (prop->set_ret) - eo_definitions_ret_free(prop->set_ret); + if (prop->get_return_comment) + eina_stringshare_del(prop->get_return_comment); + + if (prop->set_return_comment) + eina_stringshare_del(prop->set_return_comment); + + database_expr_del(prop->get_ret_val); + database_expr_del(prop->set_ret_val); free(prop); } @@ -58,8 +58,13 @@ eo_definitions_method_def_free(Eo_Method_Def *meth) if (meth->base.file) eina_stringshare_del(meth->base.file); - if (meth->ret) - eo_definitions_ret_free(meth->ret); + if (meth->ret_type) + database_type_del(meth->ret_type); + + if (meth->ret_comment) + eina_stringshare_del(meth->ret_comment); + + database_expr_del(meth->default_ret_val); if (meth->name) eina_stringshare_del(meth->name); @@ -140,9 +145,6 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp) if (tmp->kls) eo_definitions_class_def_free(tmp->kls); - if (tmp->ret_def) - eo_definitions_ret_free(tmp->ret_def); - EINA_LIST_FREE(tmp->type_defs, tp) database_type_del(tp); diff --git a/src/lib/eolian/eo_definitions.h b/src/lib/eolian/eo_definitions.h index fe01677..a6e25e1 100644 --- a/src/lib/eolian/eo_definitions.h +++ b/src/lib/eolian/eo_definitions.h @@ -6,16 +6,6 @@ #include "eolian_database.h" -/* RET */ - -typedef struct _Eo_Ret_Def -{ - Eolian_Type *type; - Eina_Stringshare *comment; - Eolian_Expression *default_ret_val; - Eina_Bool warn_unused:1; -} Eo_Ret_Def; - /* PROPERTY */ typedef struct _Eo_Property_Def @@ -23,17 +13,24 @@ typedef struct _Eo_Property_Def Eolian_Object base; Eolian_Object set_base; Eina_Stringshare *name; - Eo_Ret_Def *get_ret; - Eo_Ret_Def *set_ret; Eina_List *keys; - Eina_List *values; - Eina_Stringshare *get_comment; - Eina_Stringshare *set_comment; + Eina_List *params; + Eolian_Function_Type type; + Eolian_Object_Scope scope; + Eolian_Type *get_ret_type; + Eolian_Type *set_ret_type; + Eolian_Expression *get_ret_val; + Eolian_Expression *set_ret_val; + Eina_Stringshare *get_return_comment; + Eina_Stringshare *set_return_comment; Eina_Stringshare *get_legacy; Eina_Stringshare *set_legacy; - int scope; + Eina_Stringshare *get_description; + Eina_Stringshare *set_description; Eina_Bool get_accessor: 1; Eina_Bool set_accessor: 1; + Eina_Bool get_return_warn_unused :1; /* also used for methods */ + Eina_Bool set_return_warn_unused :1; Eina_Bool get_only_legacy: 1; Eina_Bool set_only_legacy: 1; Eina_Bool is_class:1; @@ -44,7 +41,9 @@ typedef struct _Eo_Property_Def typedef struct _Eo_Method_Def { Eolian_Object base; - Eo_Ret_Def *ret; + Eolian_Type *ret_type; + Eina_Stringshare *ret_comment; + Eolian_Expression *default_ret_val; Eina_Stringshare *name; Eina_Stringshare *comment; Eina_List *params; @@ -53,6 +52,7 @@ typedef struct _Eo_Method_Def int scope; Eina_Bool is_class:1; Eina_Bool only_legacy:1; + Eina_Bool ret_warn_unused:1; } Eo_Method_Def; /* CLASS */ @@ -83,7 +83,6 @@ typedef struct _Eo_Lexer_Temps Eina_List *params; Eina_Stringshare *legacy_def; Eo_Class_Def *kls; - Eo_Ret_Def *ret_def; Eina_List *type_defs; Eina_List *var_defs; Eo_Property_Def *prop; diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index afe725c..37d1b5c 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1096,18 +1096,26 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global) return def; } +typedef struct _Eo_Ret_Def +{ + Eolian_Type *type; + Eina_Stringshare *comment; + Eolian_Expression *default_ret_val; + Eina_Bool warn_unused:1; +} Eo_Ret_Def; + static void -parse_return(Eo_Lexer *ls, Eina_Bool allow_void) +parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void) { - Eo_Ret_Def *ret = calloc(1, sizeof(Eo_Ret_Def)); - ls->tmp.ret_def = ret; eo_lexer_get(ls); check_next(ls, ':'); if (allow_void) ret->type = parse_type_void(ls); else ret->type = parse_type(ls); - pop_type(ls); + ret->comment = NULL; + ret->default_ret_val = NULL; + ret->warn_unused = EINA_FALSE; if (ls->t.token == '(') { int line = ls->line_number, col = ls->column; @@ -1115,7 +1123,6 @@ parse_return(Eo_Lexer *ls, Eina_Bool allow_void) eo_lexer_get(ls); ret->default_ret_val = parse_expr(ls); ls->expr_mode = EINA_FALSE; - pop_expr(ls); check_match(ls, ')', '(', line, col); } if (ls->t.kw == KW_at_warn_unused) @@ -1228,6 +1235,10 @@ parse_accessor(Eo_Lexer *ls, Eo_Property_Def *prop) prop->base.line = ls->line_number; prop->base.column = ls->column; prop->get_accessor = EINA_TRUE; + if (prop->type == EOLIAN_PROP_SET) + prop->type = EOLIAN_PROPERTY; + else + prop->type = EOLIAN_PROP_GET; } else { @@ -1235,6 +1246,10 @@ parse_accessor(Eo_Lexer *ls, Eo_Property_Def *prop) prop->set_base.line = ls->line_number; prop->set_base.column = ls->column; prop->set_accessor = EINA_TRUE; + if (prop->type == EOLIAN_PROP_GET) + prop->type = EOLIAN_PROPERTY; + else + prop->type = EOLIAN_PROP_SET; } eo_lexer_get(ls); line = ls->line_number; @@ -1243,21 +1258,33 @@ parse_accessor(Eo_Lexer *ls, Eo_Property_Def *prop) if (ls->t.token == TOK_COMMENT) { if (is_get) - prop->get_comment = eina_stringshare_ref(ls->t.value.s); + prop->get_description = eina_stringshare_ref(ls->t.value.s); else - prop->set_comment = eina_stringshare_ref(ls->t.value.s); + prop->set_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } for (;;) switch (ls->t.kw) { case KW_return: CASE_LOCK(ls, return, "return") - parse_return(ls, is_get); + Eo_Ret_Def ret; + parse_return(ls, &ret, is_get); + pop_type(ls); + if (ret.default_ret_val) pop_expr(ls); if (is_get) - prop->get_ret = ls->tmp.ret_def; + { + prop->get_ret_type = ret.type; + prop->get_return_comment = ret.comment; + prop->get_ret_val = ret.default_ret_val; + prop->get_return_warn_unused = ret.warn_unused; + } else - prop->set_ret = ls->tmp.ret_def; - ls->tmp.ret_def = NULL; + { + prop->set_ret_type = ret.type; + prop->set_return_comment = ret.comment; + prop->set_ret_val = ret.default_ret_val; + prop->set_return_warn_unused = ret.warn_unused; + } break; case KW_legacy: CASE_LOCK(ls, legacy, "legacy name") @@ -1357,7 +1384,7 @@ body: case KW_values: CASE_LOCK(ls, values, "values definition") parse_params(ls, EINA_FALSE, EINA_TRUE); - prop->values = ls->tmp.params; + prop->params = ls->tmp.params; ls->tmp.params = NULL; break; default: @@ -1437,9 +1464,14 @@ body: { case KW_return: CASE_LOCK(ls, return, "return") - parse_return(ls, EINA_FALSE); - meth->ret = ls->tmp.ret_def; - ls->tmp.ret_def = NULL; + Eo_Ret_Def ret; + parse_return(ls, &ret, EINA_FALSE); + pop_type(ls); + if (ret.default_ret_val) pop_expr(ls); + meth->ret_type = ret.type; + meth->ret_comment = ret.comment; + meth->default_ret_val = ret.default_ret_val; + meth->ret_warn_unused = ret.warn_unused; break; case KW_legacy: CASE_LOCK(ls, legacy, "legacy name") --