summaryrefslogtreecommitdiff
path: root/src/bin/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-08-07 15:15:07 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-08-21 09:26:03 +0100
commit8c1b9ed3e22e6742f116ae2b8ff2414044c77b65 (patch)
treec9eb357e1630d20e70da70d2c67fe7f1f80b2cd6 /src/bin/eolian
parent90e17acd155d202d7c695f6c8192a7fe330978f8 (diff)
eolian: initial API for expression evaluation
This commit also does several side (related) changes. Particularly, it updates the Eolian C generator to use the new API, it adds missing expr types (null, char) and masks, updates the API dealing with default return values to use expressions instead of strings and does several fixes (mainly in lexer) around the place. It also disallows single quoted strings as those are reserved for characters.
Diffstat (limited to 'src/bin/eolian')
-rw-r--r--src/bin/eolian/eo_generator.c16
-rw-r--r--src/bin/eolian/legacy_generator.c16
2 files changed, 16 insertions, 16 deletions
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index 2d5f7deb73..48234b0972 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -464,20 +464,20 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid,
464 func_env.lower_eo_func); 464 func_env.lower_eo_func);
465 if (!ret_is_void) 465 if (!ret_is_void)
466 { 466 {
467 const char *default_ret_val = 467 const Eolian_Expression *default_ret_val =
468 eolian_function_return_default_value_get(funcid, ftype); 468 eolian_function_return_default_value_get(funcid, ftype);
469 const char *val_str = NULL;
469 if (default_ret_val) 470 if (default_ret_val)
470 { 471 {
471 if (!strcmp(default_ret_val, "true")) 472 Eina_Value *val = NULL;
472 default_ret_val = "EINA_TRUE"; 473 Eolian_Expression_Type etp = eolian_expression_eval_type
473 else if (!strcmp(default_ret_val, "false")) 474 (default_ret_val, rettypet, &val);
474 default_ret_val = "EINA_FALSE"; 475 if (etp)
475 else if (!strcmp(default_ret_val, "null")) 476 val_str = eolian_expression_value_to_literal(val, etp);
476 default_ret_val = "NULL";
477 } 477 }
478 eina_strbuf_append_printf(eo_func_decl, ", %s%s, %s", 478 eina_strbuf_append_printf(eo_func_decl, ", %s%s, %s",
479 ret_const ? "const " : "", rettype, 479 ret_const ? "const " : "", rettype,
480 default_ret_val?default_ret_val:"0"); 480 val_str?val_str:"0");
481 481
482 } 482 }
483 if (has_params) 483 if (has_params)
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index 8e0efbdc04..1794384e69 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -326,21 +326,21 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo
326 { 326 {
327 char tmp_ret_str[0xFF]; 327 char tmp_ret_str[0xFF];
328 sprintf (tmp_ret_str, "%s%s", ret_const?"const ":"", rettype); 328 sprintf (tmp_ret_str, "%s%s", ret_const?"const ":"", rettype);
329 const char *default_ret_val = 329 const Eolian_Expression *default_ret_val =
330 eolian_function_return_default_value_get(funcid, ftype); 330 eolian_function_return_default_value_get(funcid, ftype);
331 const char *val_str = NULL;
331 if (default_ret_val) 332 if (default_ret_val)
332 { 333 {
333 if (!strcmp(default_ret_val, "true")) 334 Eina_Value *val = NULL;
334 default_ret_val = "EINA_TRUE"; 335 Eolian_Expression_Type etp = eolian_expression_eval_type
335 else if (!strcmp(default_ret_val, "false")) 336 (default_ret_val, rettypet, &val);
336 default_ret_val = "EINA_FALSE"; 337 if (etp)
337 else if (!strcmp(default_ret_val, "null")) 338 val_str = eolian_expression_value_to_literal(val, etp);
338 default_ret_val = "NULL";
339 } 339 }
340 Eina_Bool had_star = !!strchr(rettype, '*'); 340 Eina_Bool had_star = !!strchr(rettype, '*');
341 sprintf (tmpstr, " %s%s%s%s = %s;\n", 341 sprintf (tmpstr, " %s%s%s%s = %s;\n",
342 ret_const?"const ":"", rettype, had_star?"":" ", retname, 342 ret_const?"const ":"", rettype, had_star?"":" ", retname,
343 default_ret_val?default_ret_val:"0"); 343 val_str?val_str:"0");
344 344
345 eina_strbuf_replace_all(fbody, "@#ret_type", tmp_ret_str); 345 eina_strbuf_replace_all(fbody, "@#ret_type", tmp_ret_str);
346 eina_strbuf_replace_all(fbody, "@#ret_init_val", tmpstr); 346 eina_strbuf_replace_all(fbody, "@#ret_init_val", tmpstr);