From: Daniel Kolesa Date: Wed, 3 Jun 2015 14:35:13 +0000 (+0100) Subject: eolian: properly fill and free all doc fields X-Git-Tag: v1.15.0-alpha1~352 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2c47737b1f8cfa8762b7093b5b8d598c135fb73;p=platform%2Fupstream%2Fefl.git eolian: properly fill and free all doc fields --- diff --git a/src/lib/eolian/database_class.c b/src/lib/eolian/database_class.c index 18ecd1a..8250c0d 100644 --- a/src/lib/eolian/database_class.c +++ b/src/lib/eolian/database_class.c @@ -38,6 +38,8 @@ database_class_del(Eolian_Class *cl) if (cl->eo_prefix) eina_stringshare_del(cl->eo_prefix); if (cl->data_type) eina_stringshare_del(cl->data_type); + database_doc_del(cl->doc); + if (cl->namespaces) EINA_LIST_FREE(cl->namespaces, s) if (s) eina_stringshare_del(s); diff --git a/src/lib/eolian/database_event.c b/src/lib/eolian/database_event.c index d153405..57d25e0 100644 --- a/src/lib/eolian/database_event.c +++ b/src/lib/eolian/database_event.c @@ -12,5 +12,6 @@ database_event_del(Eolian_Event *event) if (event->name) eina_stringshare_del(event->name); if (event->comment) eina_stringshare_del(event->comment); database_type_del(event->type); + database_doc_del(event->doc); free(event); } diff --git a/src/lib/eolian/database_function.c b/src/lib/eolian/database_function.c index 9729077..ff3590d 100644 --- a/src/lib/eolian/database_function.c +++ b/src/lib/eolian/database_function.c @@ -32,6 +32,11 @@ database_function_del(Eolian_Function *fid) if (fid->common_description) eina_stringshare_del(fid->common_description); if (fid->get_return_comment) eina_stringshare_del(fid->get_return_comment); if (fid->set_return_comment) eina_stringshare_del(fid->set_return_comment); + database_doc_del(fid->common_doc); + database_doc_del(fid->get_doc); + database_doc_del(fid->set_doc); + database_doc_del(fid->get_return_doc); + database_doc_del(fid->set_return_doc); free(fid); } diff --git a/src/lib/eolian/database_function_parameter.c b/src/lib/eolian/database_function_parameter.c index ed2f13e..75f0835 100644 --- a/src/lib/eolian/database_function_parameter.c +++ b/src/lib/eolian/database_function_parameter.c @@ -13,5 +13,6 @@ database_parameter_del(Eolian_Function_Parameter *pdesc) database_type_del(pdesc->type); eina_stringshare_del(pdesc->description); + database_doc_del(pdesc->doc); free(pdesc); } diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index 930f9e1..aab452d 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -25,6 +25,7 @@ database_type_del(Eolian_Type *tp) if (tp->comment) eina_stringshare_del(tp->comment); if (tp->legacy) eina_stringshare_del(tp->legacy); if (tp->freefunc) eina_stringshare_del(tp->freefunc); + database_doc_del(tp->doc); free(tp); } diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c index 5d8c2ad..37130ac 100644 --- a/src/lib/eolian/database_var.c +++ b/src/lib/eolian/database_var.c @@ -19,6 +19,7 @@ database_var_del(Eolian_Variable *var) eina_stringshare_del(sp); if (var->value) database_expr_del(var->value); if (var->comment) eina_stringshare_del(var->comment); + database_doc_del(var->doc); free(var); } diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 69fef67..1f612f1 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -871,6 +871,7 @@ _free_tok(Eo_Token *tok) if (tok->token == TOK_DOC) { /* free doc */ + if (!tok->value.doc) return; eina_stringshare_del(tok->value.doc->summary); eina_stringshare_del(tok->value.doc->description); free(tok->value.doc); diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 2a4c9ae..195ae49 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -14,6 +14,14 @@ (exp).line = l; \ (exp).column = c; +#define FILL_DOC(ls, def, docf) \ + if (ls->t.token == TOK_DOC) \ + { \ + def->docf = ls->t.value.doc; \ + ls->t.value.doc = NULL; \ + eo_lexer_get(ls); \ + } + static void error_expected(Eo_Lexer *ls, int token) { @@ -460,6 +468,7 @@ _struct_field_free(Eolian_Struct_Type_Field *def) if (def->name) eina_stringshare_del(def->name); database_type_del(def->type); if (def->comment) eina_stringshare_del(def->comment); + database_doc_del(def->doc); free(def); } @@ -481,7 +490,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern, def->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, def, doc); while (ls->t.token != '}') { const char *fname; @@ -508,7 +517,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern, fdef->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, fdef, doc); } check_match(ls, '}', '{', bline, bcolumn); FILL_BASE(def->base, ls, line, column); @@ -523,6 +532,7 @@ _enum_field_free(Eolian_Enum_Type_Field *def) if (def->name) eina_stringshare_del(def->name); database_expr_del(def->value); if (def->comment) eina_stringshare_del(def->comment); + database_doc_del(def->doc); free(def); } @@ -542,7 +552,7 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern, def->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, def, doc); if (ls->t.token == TOK_VALUE && ls->t.kw == KW_legacy) { if (eo_lexer_lookahead(ls) == ':') @@ -627,7 +637,7 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern, fdef->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, fdef, doc); if (!want_next) break; } @@ -886,7 +896,7 @@ parse_typedef(Eo_Lexer *ls) def->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, def, doc); return def; } @@ -938,7 +948,7 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global) def->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, def, doc); return def; } @@ -946,6 +956,7 @@ typedef struct _Eo_Ret_Def { Eolian_Type *type; Eina_Stringshare *comment; + Eolian_Documentation *doc; Eolian_Expression *default_ret_val; Eina_Bool warn_unused:1; } Eo_Ret_Def; @@ -960,6 +971,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void) else ret->type = parse_type(ls); ret->comment = NULL; + ret->doc = NULL; ret->default_ret_val = NULL; ret->warn_unused = EINA_FALSE; if (ls->t.token == '(') @@ -982,7 +994,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void) ret->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, ret, doc); } static void @@ -1064,7 +1076,7 @@ end: par->description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, par, doc); } static void @@ -1129,7 +1141,14 @@ parse_accessor(Eo_Lexer *ls, Eolian_Function *prop) prop->set_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + if (is_get) + { + FILL_DOC(ls, prop, get_doc); + } + else + { + FILL_DOC(ls, prop, set_doc); + } for (;;) switch (ls->t.kw) { case KW_return: @@ -1142,6 +1161,7 @@ parse_accessor(Eo_Lexer *ls, Eolian_Function *prop) { prop->get_ret_type = ret.type; prop->get_return_comment = ret.comment; + prop->get_return_doc = ret.doc; prop->get_ret_val = ret.default_ret_val; prop->get_return_warn_unused = ret.warn_unused; } @@ -1149,6 +1169,7 @@ parse_accessor(Eo_Lexer *ls, Eolian_Function *prop) { prop->set_ret_type = ret.type; prop->set_return_comment = ret.comment; + prop->set_return_doc = ret.doc; prop->set_ret_val = ret.default_ret_val; prop->set_return_warn_unused = ret.warn_unused; } @@ -1259,7 +1280,7 @@ body: prop->common_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, prop, common_doc); for (;;) switch (ls->t.kw) { case KW_get: @@ -1345,7 +1366,7 @@ body: meth->common_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, meth, common_doc); for (;;) switch (ls->t.kw) { case KW_return: @@ -1356,6 +1377,7 @@ body: if (ret.default_ret_val) pop_expr(ls); meth->get_ret_type = ret.type; meth->get_return_comment = ret.comment; + meth->get_return_doc = ret.doc; meth->get_ret_val = ret.default_ret_val; meth->get_return_warn_unused = ret.warn_unused; break; @@ -1598,7 +1620,7 @@ parse_event(Eo_Lexer *ls) ev->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, ev, doc); ev->klass = ls->tmp.kls; } @@ -1675,7 +1697,7 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type) ls->tmp.kls->description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, ls->tmp.kls, doc); if (type == EOLIAN_CLASS_INTERFACE) { ls->tmp.kls->data_type = eina_stringshare_add("null"); @@ -1944,7 +1966,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot) def->comment = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } - test_next(ls, TOK_DOC); + FILL_DOC(ls, def, doc); FILL_BASE(def->base, ls, line, col); database_struct_add(def); pop_type(ls); diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index ceca0e3..b0c4ab4 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -161,6 +161,13 @@ eolian_declaration_variable_get(const Eolian_Declaration *decl) return (const Eolian_Variable *)decl->data; } +void database_doc_del(Eolian_Documentation *doc) +{ + if (!doc) return; + eina_stringshare_del(doc->summary); + eina_stringshare_del(doc->description); + free(doc); +} #define EO_SUFFIX ".eo" #define EOT_SUFFIX ".eot" diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 62b50f2..c3a7a55 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -284,6 +284,8 @@ Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Clas void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type, Eina_Stringshare *file, void *ptr); +void database_doc_del(Eolian_Documentation *doc); + /* types */ void database_type_add(Eolian_Type *def);