From eeca57fdb0bf1bc370356418a6ff830851e5639d Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 28 Aug 2017 17:22:09 +0200 Subject: [PATCH] eolian: less clumsy return type handling --- src/lib/eolian/eo_parser.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 4c2f14f..655936e 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1002,7 +1002,7 @@ typedef struct _Eo_Ret_Def } Eo_Ret_Def; static void -parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void) +parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void, Eina_Bool allow_def) { eo_lexer_get(ls); check_next(ls, ':'); @@ -1013,7 +1013,7 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void) ret->doc = NULL; ret->default_ret_val = NULL; ret->warn_unused = EINA_FALSE; - if (ls->t.token == '(') + if (allow_def && (ls->t.token == '(')) { int line = ls->line_number, col = ls->column; ls->expr_mode = EINA_TRUE; @@ -1208,7 +1208,7 @@ parse_accessor: case KW_return: CASE_LOCK(ls, return, "return") Eo_Ret_Def ret; - parse_return(ls, &ret, is_get); + parse_return(ls, &ret, is_get, EINA_TRUE); pop_type(ls); if (ret.default_ret_val) pop_expr(ls); if (is_get) @@ -1440,13 +1440,8 @@ body: case KW_return: CASE_LOCK(ls, return, "return"); Eo_Ret_Def ret; - parse_return(ls, &ret, EINA_FALSE); + parse_return(ls, &ret, EINA_FALSE, EINA_FALSE); pop_type(ls); - if (ret.default_ret_val) - { - eo_lexer_syntax_error(ls, "default return value invalid for function pointer"); - return NULL; - } meth->get_ret_type = ret.type; meth->get_return_doc = ret.doc; meth->get_ret_val = NULL; @@ -1548,7 +1543,7 @@ body: case KW_return: CASE_LOCK(ls, return, "return") Eo_Ret_Def ret; - parse_return(ls, &ret, EINA_FALSE); + parse_return(ls, &ret, EINA_FALSE, EINA_TRUE); pop_type(ls); if (ret.default_ret_val) pop_expr(ls); meth->get_ret_type = ret.type; -- 2.7.4