diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c index 79b21783e1..f38b9147f3 100644 --- a/src/lib/eolian/database_fill.c +++ b/src/lib/eolian/database_fill.c @@ -1,83 +1,6 @@ #include "eo_parser.h" -static Eina_Bool -_db_fill_accessor(Eolian_Function *foo_id, Eo_Class_Def *kls, - Eo_Accessor_Def *accessor) -{ - if (accessor->type == SETTER) - foo_id->type = (foo_id->type == EOLIAN_PROP_GET) ? EOLIAN_PROPERTY - : EOLIAN_PROP_SET; - else - foo_id->type = (foo_id->type == EOLIAN_PROP_SET) ? EOLIAN_PROPERTY - : EOLIAN_PROP_GET; - - if (accessor->ret && accessor->ret->type) - { - if (accessor->type == SETTER) - { - foo_id->set_ret_type = accessor->ret->type; - foo_id->set_ret_val = accessor->ret->default_ret_val; - foo_id->set_return_comment = eina_stringshare_ref(accessor->ret->comment); - foo_id->set_return_warn_unused = accessor->ret->warn_unused; - } - else - { - foo_id->get_ret_type = accessor->ret->type; - foo_id->get_ret_val = accessor->ret->default_ret_val; - foo_id->get_return_comment = eina_stringshare_ref(accessor->ret->comment); - foo_id->get_return_warn_unused = accessor->ret->warn_unused; - } - accessor->ret->type = NULL; - accessor->ret->default_ret_val = NULL; - } - - if (accessor->type == SETTER) - { - foo_id->set_description = eina_stringshare_ref(accessor->comment); - if (accessor->legacy) - foo_id->set_legacy = eina_stringshare_ref(accessor->legacy); - foo_id->set_only_legacy = accessor->only_legacy; - } - else - { - foo_id->get_description = eina_stringshare_ref(accessor->comment); - if (accessor->legacy) - foo_id->get_legacy = eina_stringshare_ref(accessor->legacy); - foo_id->get_only_legacy = accessor->only_legacy; - } - - if (kls->type == EOLIAN_CLASS_INTERFACE) - { - if (accessor->type == SETTER) - foo_id->set_virtual_pure = EINA_TRUE; - else - foo_id->get_virtual_pure = EINA_TRUE; - } - - if (accessor->type == GETTER) - foo_id->base = accessor->base; - else - foo_id->set_base = accessor->base; - - accessor->base.file = NULL; - - return EINA_TRUE; -} - -static Eina_Bool -_db_fill_accessors(Eolian_Function *foo_id, Eo_Class_Def *kls, - Eo_Property_Def *prop) -{ - if (prop->get_accessor && !_db_fill_accessor(foo_id, kls, prop->get_accessor)) - return EINA_FALSE; - if (prop->set_accessor && !_db_fill_accessor(foo_id, kls, prop->set_accessor)) - return EINA_FALSE; - - return EINA_TRUE; -} - - -static Eina_Bool +static void _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) { Eolian_Function *foo_id = database_function_new(prop->name, @@ -88,7 +11,75 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) foo_id->keys = prop->keys ; prop->keys = NULL; foo_id->params = prop->values; prop->values = NULL; - if (!_db_fill_accessors(foo_id, kls, prop)) goto failure; + + if (prop->get_ret) + { + 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; + } + if (prop->set_ret) + { + 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; + } + + if (prop->get_legacy) + { + foo_id->get_legacy = prop->get_legacy; + prop->get_legacy = NULL; + } + if (prop->set_legacy) + { + foo_id->set_legacy = prop->set_legacy; + prop->set_legacy = NULL; + } + foo_id->get_only_legacy = prop->get_only_legacy; + foo_id->set_only_legacy = prop->set_only_legacy; + + if (prop->get_comment) + { + foo_id->get_description = prop->get_comment; + prop->get_comment = NULL; + } + if (prop->set_comment) + { + foo_id->set_description = prop->set_comment; + prop->set_comment = NULL; + } + + 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; + } + + if (prop->set_accessor) + { + 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; + } if (!prop->get_accessor && !prop->set_accessor) { @@ -100,24 +91,16 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop) } cl->properties = eina_list_append(cl->properties, foo_id); - - return EINA_TRUE; - -failure: - database_function_del(foo_id); - return EINA_FALSE; } -static Eina_Bool +static void _db_fill_properties(Eolian_Class *cl, Eo_Class_Def *kls) { Eo_Property_Def *prop; Eina_List *l; EINA_LIST_FOREACH(kls->properties, l, prop) - if (!_db_fill_property(cl, kls, prop)) return EINA_FALSE; - - return EINA_TRUE; + _db_fill_property(cl, kls, prop); } static Eina_Bool @@ -144,8 +127,7 @@ _db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth) foo_id->obj_is_const = meth->obj_const; foo_id->is_class = meth->is_class; - if (meth->only_legacy) - foo_id->get_only_legacy = EINA_TRUE; + foo_id->get_only_legacy = meth->only_legacy; foo_id->params = meth->params; meth->params = NULL; @@ -443,7 +425,8 @@ _db_fill_class(Eo_Class_Def *kls) if (kls->data_type) cl->data_type = eina_stringshare_ref(kls->data_type); - if (!_db_fill_properties (cl, kls)) return EINA_FALSE; + _db_fill_properties(cl, kls); + 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; diff --git a/src/lib/eolian/eo_definitions.c b/src/lib/eolian/eo_definitions.c index c8958b7e07..8a77ca2778 100644 --- a/src/lib/eolian/eo_definitions.c +++ b/src/lib/eolian/eo_definitions.c @@ -12,24 +12,6 @@ eo_definitions_ret_free(Eo_Ret_Def *ret) free(ret); } -static void -eo_definitions_accessor_free(Eo_Accessor_Def *accessor) -{ - if (accessor->base.file) - eina_stringshare_del(accessor->base.file); - - if (accessor->comment) - eina_stringshare_del(accessor->comment); - - if (accessor->legacy) - eina_stringshare_del(accessor->legacy); - - if (accessor->ret) - eo_definitions_ret_free(accessor->ret); - - free(accessor); -} - static void eo_definitions_property_def_free(Eo_Property_Def *prop) { @@ -47,10 +29,23 @@ eo_definitions_property_def_free(Eo_Property_Def *prop) EINA_LIST_FREE(prop->values, param) database_parameter_del(param); - if (prop->get_accessor) - eo_definitions_accessor_free(prop->get_accessor); - if (prop->set_accessor) - eo_definitions_accessor_free(prop->set_accessor); + if (prop->get_comment) + eina_stringshare_del(prop->get_comment); + + if (prop->set_comment) + eina_stringshare_del(prop->set_comment); + + if (prop->get_legacy) + eina_stringshare_del(prop->get_legacy); + + if (prop->set_legacy) + eina_stringshare_del(prop->set_legacy); + + if (prop->get_ret) + eo_definitions_ret_free(prop->get_ret); + + if (prop->set_ret) + eo_definitions_ret_free(prop->set_ret); free(prop); } @@ -163,9 +158,6 @@ eo_definitions_temps_free(Eo_Lexer_Temps *tmp) if (tmp->param) database_parameter_del(tmp->param); - if (tmp->accessor) - eo_definitions_accessor_free(tmp->accessor); - EINA_LIST_FREE(tmp->str_items, s) if (s) eina_stringshare_del(s); diff --git a/src/lib/eolian/eo_definitions.h b/src/lib/eolian/eo_definitions.h index b2f3e1158b..fe0167732f 100644 --- a/src/lib/eolian/eo_definitions.h +++ b/src/lib/eolian/eo_definitions.h @@ -16,35 +16,26 @@ typedef struct _Eo_Ret_Def Eina_Bool warn_unused:1; } Eo_Ret_Def; -/* ACCESSOR */ - -typedef enum _Eo_Accessor_Type -{ - SETTER, - GETTER -} Eo_Accessor_Type; - -typedef struct _Eo_Accessor_Def -{ - Eolian_Object base; - Eo_Accessor_Type type; - Eo_Ret_Def *ret; - Eina_Stringshare *comment; - Eina_Stringshare* legacy; - Eina_Bool only_legacy:1; -} Eo_Accessor_Def; - /* PROPERTY */ 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; - Eo_Accessor_Def *get_accessor; - Eo_Accessor_Def *set_accessor; + Eina_Stringshare *get_comment; + Eina_Stringshare *set_comment; + Eina_Stringshare *get_legacy; + Eina_Stringshare *set_legacy; int scope; + Eina_Bool get_accessor: 1; + Eina_Bool set_accessor: 1; + Eina_Bool get_only_legacy: 1; + Eina_Bool set_only_legacy: 1; Eina_Bool is_class:1; } Eo_Property_Def; @@ -98,7 +89,6 @@ typedef struct _Eo_Lexer_Temps Eo_Property_Def *prop; Eo_Method_Def *meth; Eolian_Function_Parameter *param; - Eo_Accessor_Def *accessor; Eina_List *str_items; Eolian_Event *event; Eolian_Implement *impl; diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 1e3f056099..afe725cd48 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1215,40 +1215,57 @@ parse_legacy(Eo_Lexer *ls) check_next(ls, ';'); } -static Eo_Accessor_Def * -parse_accessor(Eo_Lexer *ls) +static void +parse_accessor(Eo_Lexer *ls, Eo_Property_Def *prop) { int line, col; - Eo_Accessor_Def *acc = NULL; Eina_Bool has_return = EINA_FALSE, has_legacy = EINA_FALSE, has_eo = EINA_FALSE; - acc = calloc(1, sizeof(Eo_Accessor_Def)); - acc->base.file = eina_stringshare_ref(ls->filename); - acc->base.line = ls->line_number; - acc->base.column = ls->column; - ls->tmp.accessor = acc; - acc->type = (ls->t.kw == KW_get) ? GETTER : SETTER; + Eina_Bool is_get = (ls->t.kw == KW_get); + if (is_get) + { + prop->base.file = eina_stringshare_ref(ls->filename); + prop->base.line = ls->line_number; + prop->base.column = ls->column; + prop->get_accessor = EINA_TRUE; + } + else + { + prop->set_base.file = eina_stringshare_ref(ls->filename); + prop->set_base.line = ls->line_number; + prop->set_base.column = ls->column; + prop->set_accessor = EINA_TRUE; + } eo_lexer_get(ls); line = ls->line_number; col = ls->column; check_next(ls, '{'); if (ls->t.token == TOK_COMMENT) { - acc->comment = eina_stringshare_ref(ls->t.value.s); + if (is_get) + prop->get_comment = eina_stringshare_ref(ls->t.value.s); + else + prop->set_comment = 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, acc->type == GETTER); - acc->ret = ls->tmp.ret_def; + parse_return(ls, is_get); + if (is_get) + prop->get_ret = ls->tmp.ret_def; + else + prop->set_ret = ls->tmp.ret_def; ls->tmp.ret_def = NULL; break; case KW_legacy: CASE_LOCK(ls, legacy, "legacy name") parse_legacy(ls); - acc->legacy = ls->tmp.legacy_def; + if (is_get) + prop->get_legacy = ls->tmp.legacy_def; + else + prop->set_legacy = ls->tmp.legacy_def; ls->tmp.legacy_def = NULL; break; case KW_eo: @@ -1257,15 +1274,16 @@ parse_accessor(Eo_Lexer *ls) check_next(ls, ':'); check_kw_next(ls, KW_null); check_next(ls, ';'); - acc->only_legacy = EINA_TRUE; + if (is_get) + prop->get_only_legacy = EINA_TRUE; + else + prop->set_only_legacy = EINA_TRUE; break; default: goto end; } end: check_match(ls, '}', '{', line, col); - ls->tmp.accessor = NULL; - return acc; } static void @@ -1324,11 +1342,11 @@ body: { case KW_get: CASE_LOCK(ls, get, "get definition") - prop->get_accessor = parse_accessor(ls); + parse_accessor(ls, prop); break; case KW_set: CASE_LOCK(ls, set, "set definition") - prop->set_accessor = parse_accessor(ls); + parse_accessor(ls, prop); break; case KW_keys: CASE_LOCK(ls, keys, "keys definition")