From e444d43bbbbb916cf931ba3ba03a6b06744429c9 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 14 Dec 2016 18:14:10 +0100 Subject: [PATCH] eolian: handle pointer types in typechecking expr eval Also improve expr error messages and fix Eolian tests. --- src/lib/eolian/database_expr.c | 6 +++--- src/lib/eolian/database_expr_api.c | 2 ++ src/tests/eolian/data/class_simple_ref.c | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c index 21dfe6578c..45f89a9530 100644 --- a/src/lib/eolian/database_expr.c +++ b/src/lib/eolian/database_expr.c @@ -50,7 +50,7 @@ mask_to_str(int mask, char *buf) } static Eina_Bool -expr_type_error(const Eolian_Expression *expr, int mask, int type) +expr_type_error(const Eolian_Expression *expr, int type, int mask) { char buf[512]; char ebuf[256]; @@ -153,9 +153,9 @@ promote(Eolian_Expression *a, Eolian_Expression *b) assert(a->type && b->type); /* not a number */ if (a->type >= EOLIAN_EXPR_STRING) - return expr_type_error(a, EOLIAN_MASK_NUMBER, expr_type_to_mask(a)); + return expr_type_error(a, expr_type_to_mask(a), EOLIAN_MASK_NUMBER); if (b->type >= EOLIAN_EXPR_STRING) - return expr_type_error(b, EOLIAN_MASK_NUMBER, expr_type_to_mask(b)); + return expr_type_error(b, expr_type_to_mask(b), EOLIAN_MASK_NUMBER); /* no need for promotion */ if (a->type == b->type) return EINA_TRUE; /* if either operand is floating point, everything has to be */ diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c index db38c045c6..6cfca9466c 100644 --- a/src/lib/eolian/database_expr_api.c +++ b/src/lib/eolian/database_expr_api.c @@ -29,6 +29,8 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type) case EOLIAN_TYPE_REGULAR: { int kw = eo_lexer_keyword_str_to_id(type->name); + if (type->is_ptr) + return database_expr_eval(expr, EOLIAN_MASK_NULL); if (!kw || kw < KW_byte || kw >= KW_void) { const Eolian_Typedecl *base = eolian_type_typedecl_get(type); diff --git a/src/tests/eolian/data/class_simple_ref.c b/src/tests/eolian/data/class_simple_ref.c index 0a601ff184..baa47d6fa6 100644 --- a/src/tests/eolian/data/class_simple_ref.c +++ b/src/tests/eolian/data/class_simple_ref.c @@ -2,7 +2,7 @@ EWAPI float BAR = 10.300000f; Eina_Bool _class_simple_a_set(Eo *obj, Evas_Simple_Data *pd, int value); -EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_a_set, Eina_Bool, EINA_TRUE, EFL_FUNC_CALL(value), int value); +EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_a_set, Eina_Bool, EINA_TRUE /* true */, EFL_FUNC_CALL(value), int value); int _class_simple_a_get(Eo *obj, Evas_Simple_Data *pd); @@ -20,11 +20,11 @@ static char *__eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, cha return _class_simple_foo(obj, pd, a, b, c, d); } -EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_foo, char *, NULL, EFL_FUNC_CALL(a, b, c, d), int a, char *b, double *c, int *d); +EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_foo, char *, NULL /* null */, EFL_FUNC_CALL(a, b, c, d), int a, char *b, double *c, int *d); int *_class_simple_bar(Eo *obj, Evas_Simple_Data *pd, int x); -EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_bar, int *, 0, EFL_FUNC_CALL(x), int x); +EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_bar, int *, NULL, EFL_FUNC_CALL(x), int x); static Eina_Bool _class_simple_class_initializer(Efl_Class *klass)