From 12ce49db0191a80d6922b879291e7ca5477d3c62 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 11 Sep 2014 10:29:48 +0100 Subject: [PATCH] eolian: remove Eo_Method_Def --- src/lib/eolian/database_fill.c | 52 +-------------------------------- src/lib/eolian/eo_definitions.c | 47 +++++------------------------ src/lib/eolian/eo_definitions.h | 22 +------------- src/lib/eolian/eo_parser.c | 38 ++++++++++++------------ 4 files changed, 29 insertions(+), 130 deletions(-) diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c index 46be5fbdc6..28c66d0cbf 100644 --- a/src/lib/eolian/database_fill.c +++ b/src/lib/eolian/database_fill.c @@ -1,55 +1,5 @@ #include "eo_parser.h" -static Eina_Bool -_db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth) -{ - Eolian_Function *foo_id = database_function_new(meth->name, EOLIAN_METHOD); - - foo_id->scope = meth->scope; - - cl->methods = eina_list_append(cl->methods, foo_id); - - if (meth->ret_type) - { - 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); - foo_id->get_legacy = eina_stringshare_ref(meth->legacy); - foo_id->obj_is_const = meth->obj_const; - foo_id->is_class = meth->is_class; - - foo_id->get_only_legacy = meth->only_legacy; - - foo_id->params = meth->params; meth->params = NULL; - - if (kls->type == EOLIAN_CLASS_INTERFACE) - foo_id->get_virtual_pure = EINA_TRUE; - - foo_id->base = meth->base; - meth->base.file = NULL; - - return EINA_TRUE; -} - -static Eina_Bool -_db_fill_methods(Eolian_Class *cl, Eo_Class_Def *kls) -{ - Eo_Method_Def *meth; - Eina_List *l; - - EINA_LIST_FOREACH(kls->methods, l, meth) - if (!_db_fill_method(cl, kls, meth)) return EINA_FALSE; - - return EINA_TRUE; -} - static int _func_error(Eolian_Class *cl, Eolian_Implement *impl) { @@ -324,8 +274,8 @@ _db_fill_class(Eo_Class_Def *kls) cl->data_type = eina_stringshare_ref(kls->data_type); cl->properties = kls->properties; kls->properties = NULL; + cl->methods = kls->methods ; kls->methods = NULL; - if (!_db_fill_methods (cl, kls)) return EINA_FALSE; if (!_db_fill_implements (cl, kls)) return EINA_FALSE; if (!_db_fill_constructors(cl, kls)) return EINA_FALSE; if (!_db_fill_events (cl, kls)) return EINA_FALSE; diff --git a/src/lib/eolian/eo_definitions.c b/src/lib/eolian/eo_definitions.c index ca4580c4b2..2bc965a762 100644 --- a/src/lib/eolian/eo_definitions.c +++ b/src/lib/eolian/eo_definitions.c @@ -3,41 +3,11 @@ #include "eo_definitions.h" -static void -eo_definitions_method_def_free(Eo_Method_Def *meth) -{ - Eolian_Function_Parameter *param; - - if (meth->base.file) - eina_stringshare_del(meth->base.file); - - 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); - if (meth->comment) - eina_stringshare_del(meth->comment); - if (meth->legacy) - eina_stringshare_del(meth->legacy); - - EINA_LIST_FREE(meth->params, param) - database_parameter_del(param); - - free(meth); -} - void eo_definitions_class_def_free(Eo_Class_Def *kls) { const char *s; - Eolian_Function *prop; - Eo_Method_Def *meth; + Eolian_Function *func; Eolian_Event *sgn; Eolian_Implement *impl; Eolian_Constructor *ctor; @@ -65,11 +35,11 @@ eo_definitions_class_def_free(Eo_Class_Def *kls) EINA_LIST_FREE(kls->constructors, ctor) database_constructor_del(ctor); - EINA_LIST_FREE(kls->properties, prop) - database_function_del(prop); + EINA_LIST_FREE(kls->properties, func) + database_function_del(func); - EINA_LIST_FREE(kls->methods, meth) - eo_definitions_method_def_free(meth); + EINA_LIST_FREE(kls->methods, func) + database_function_del(func); EINA_LIST_FREE(kls->events, sgn) database_event_del(sgn); @@ -104,11 +74,8 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp) EINA_LIST_FREE(tmp->var_defs, var) database_var_del(var); - if (tmp->prop) - database_function_del(tmp->prop); - - if (tmp->meth) - eo_definitions_method_def_free(tmp->meth); + if (tmp->func) + database_function_del(tmp->func); if (tmp->param) database_parameter_del(tmp->param); diff --git a/src/lib/eolian/eo_definitions.h b/src/lib/eolian/eo_definitions.h index e25a5651b6..a86ee5a17b 100644 --- a/src/lib/eolian/eo_definitions.h +++ b/src/lib/eolian/eo_definitions.h @@ -6,25 +6,6 @@ #include "eolian_database.h" -/* METHOD */ - -typedef struct _Eo_Method_Def -{ - Eolian_Object base; - Eolian_Type *ret_type; - Eina_Stringshare *ret_comment; - Eolian_Expression *default_ret_val; - Eina_Stringshare *name; - Eina_Stringshare *comment; - Eina_List *params; - Eina_Stringshare *legacy; - Eina_Bool obj_const; - int scope; - Eina_Bool is_class:1; - Eina_Bool only_legacy:1; - Eina_Bool ret_warn_unused:1; -} Eo_Method_Def; - /* CLASS */ typedef struct _Eo_Class_Def @@ -55,8 +36,7 @@ typedef struct _Eo_Lexer_Temps Eo_Class_Def *kls; Eina_List *type_defs; Eina_List *var_defs; - Eolian_Function *prop; - Eo_Method_Def *meth; + Eolian_Function *func; Eolian_Function_Parameter *param; Eina_List *str_items; Eolian_Event *event; diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index fef5d129f1..bf905b1036 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1331,11 +1331,11 @@ _interface_virtual_set(Eo_Lexer *ls, Eolian_Function *foo_id) if (ls->tmp.kls->type != EOLIAN_CLASS_INTERFACE) return; - if (foo_id->type == EOLIAN_PROP_GET) + if (foo_id->type == EOLIAN_PROP_GET || foo_id->type == EOLIAN_METHOD) foo_id->get_virtual_pure = EINA_TRUE; else if (foo_id->type == EOLIAN_PROP_SET) foo_id->set_virtual_pure = EINA_TRUE; - if (foo_id->type == EOLIAN_PROPERTY) + else if (foo_id->type == EOLIAN_PROPERTY) foo_id->get_virtual_pure = foo_id->set_virtual_pure = EINA_TRUE; } @@ -1351,7 +1351,7 @@ parse_property(Eo_Lexer *ls) prop->base.file = eina_stringshare_ref(ls->filename); prop->base.line = ls->line_number; prop->base.column = ls->column; - ls->tmp.prop = prop; + ls->tmp.func = prop; check(ls, TOK_VALUE); prop->name = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); @@ -1415,16 +1415,17 @@ static void parse_method(Eo_Lexer *ls, Eina_Bool ctor) { int line, col; - Eo_Method_Def *meth = NULL; + Eolian_Function *meth = NULL; Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE, has_return = EINA_FALSE, has_legacy = EINA_FALSE, has_protected = EINA_FALSE, has_class = EINA_FALSE, has_eo = EINA_FALSE; - meth = calloc(1, sizeof(Eo_Method_Def)); + meth = calloc(1, sizeof(Eolian_Function)); + meth->type = EOLIAN_METHOD; meth->base.file = eina_stringshare_ref(ls->filename); meth->base.line = ls->line_number; meth->base.column = ls->column; - ls->tmp.meth = meth; + ls->tmp.func = meth; if (ctor) { if (ls->t.token != TOK_VALUE) @@ -1456,7 +1457,7 @@ parse_method(Eo_Lexer *ls, Eina_Bool ctor) break; case KW_at_const: CASE_LOCK(ls, const, "const qualifier") - meth->obj_const = EINA_TRUE; + meth->obj_is_const = EINA_TRUE; eo_lexer_get(ls); break; case KW_at_class: @@ -1474,7 +1475,7 @@ body: check_next(ls, '{'); if (ls->t.token == TOK_COMMENT) { - meth->comment = eina_stringshare_ref(ls->t.value.s); + meth->get_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } for (;;) switch (ls->t.kw) @@ -1485,15 +1486,15 @@ body: 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; + meth->get_ret_type = ret.type; + meth->get_return_comment = ret.comment; + meth->get_ret_val = ret.default_ret_val; + meth->get_return_warn_unused = ret.warn_unused; break; case KW_legacy: CASE_LOCK(ls, legacy, "legacy name") parse_legacy(ls); - meth->legacy = ls->tmp.legacy_def; + meth->get_legacy = ls->tmp.legacy_def; ls->tmp.legacy_def = NULL; break; case KW_eo: @@ -1502,7 +1503,7 @@ body: check_next(ls, ':'); check_kw_next(ls, KW_null); check_next(ls, ';'); - meth->only_legacy = EINA_TRUE; + meth->get_only_legacy = EINA_TRUE; break; case KW_params: CASE_LOCK(ls, params, "params definition") @@ -1515,6 +1516,7 @@ body: } end: check_match(ls, '}', '{', line, col); + _interface_virtual_set(ls, meth); } static void @@ -1729,8 +1731,8 @@ parse_methods(Eo_Lexer *ls) { parse_method(ls, EINA_FALSE); ls->tmp.kls->methods = eina_list_append(ls->tmp.kls->methods, - ls->tmp.meth); - ls->tmp.meth = NULL; + ls->tmp.func); + ls->tmp.func = NULL; } check_match(ls, '}', '{', line, col); } @@ -1742,8 +1744,8 @@ parse_properties(Eo_Lexer *ls) { parse_property(ls); ls->tmp.kls->properties = eina_list_append(ls->tmp.kls->properties, - ls->tmp.prop); - ls->tmp.prop = NULL; + ls->tmp.func); + ls->tmp.func = NULL; } check_match(ls, '}', '{', line, col); }