forked from enlightenment/efl
eolian: remove the expression eval_type API
This is unnecessary because for all contexts where type is relevant the validator already makes sure the type and expression match correctly, so you don't ever need to re-validate it. If you are doing a generic case and are not sure, just use MASK_ALL.
This commit is contained in:
parent
0021d1386d
commit
6751f011c1
|
@ -107,7 +107,7 @@ _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type
|
|||
{
|
||||
if (exp)
|
||||
{
|
||||
Eolian_Value val = eolian_expression_eval_type(exp, tp);
|
||||
Eolian_Value val = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||
Eina_Stringshare *lit = eolian_expression_value_to_literal(&val);
|
||||
if (lit)
|
||||
{
|
||||
|
|
|
@ -191,7 +191,7 @@ _var_generate(const Eolian_State *state, const Eolian_Variable *vr)
|
|||
eina_strbuf_prepend_printf(buf, "#ifndef %s\n", fn);
|
||||
eina_strbuf_append_printf(buf, "#define %s ", fn);
|
||||
const Eolian_Expression *vv = eolian_variable_value_get(vr);
|
||||
Eolian_Value val = eolian_expression_eval_type(vv, vt);
|
||||
Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL);
|
||||
Eina_Stringshare *lit = eolian_expression_value_to_literal(&val);
|
||||
eina_strbuf_append(buf, lit);
|
||||
Eina_Stringshare *exp = eolian_expression_serialize(vv);
|
||||
|
@ -397,7 +397,7 @@ _source_gen_var(Eina_Strbuf *buf, const Eolian_Variable *vr)
|
|||
eina_stringshare_del(ct);
|
||||
free(fn);
|
||||
|
||||
Eolian_Value val = eolian_expression_eval_type(vv, vt);
|
||||
Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL);
|
||||
Eina_Stringshare *lit = eolian_expression_value_to_literal(&val);
|
||||
eina_strbuf_append(buf, lit);
|
||||
eina_strbuf_append_char(buf, ';');
|
||||
|
|
|
@ -460,7 +460,6 @@ ffi.cdef [[
|
|||
const Eolian_Function *eolian_typedecl_function_pointer_get(const Eolian_Typedecl *tp);
|
||||
|
||||
Eolian_Value_t eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m);
|
||||
Eolian_Value_t eolian_expression_eval_type(const Eolian_Expression *expr, const Eolian_Type *type);
|
||||
const char *eolian_expression_value_to_literal(const Eolian_Value *v);
|
||||
const char *eolian_expression_serialize(const Eolian_Expression *expr);
|
||||
Eolian_Expression_Type eolian_expression_type_get(const Eolian_Expression *expr);
|
||||
|
@ -1711,12 +1710,6 @@ M.Expression = ffi.metatype("Eolian_Expression", {
|
|||
return ffi.cast("Eolian_Value*", v)
|
||||
end,
|
||||
|
||||
eval_type = function(self, tp)
|
||||
local v = eolian.eolian_expression_eval_type(self, tp)
|
||||
if v == nil then return nil end
|
||||
return ffi.cast("Eolian_Value*", v)
|
||||
end,
|
||||
|
||||
serialize = function(self)
|
||||
local v = eolian.eolian_expression_serialize(self)
|
||||
if v == nil then return nil end
|
||||
|
|
|
@ -3077,20 +3077,6 @@ eolian_type_namespaces_get(const Eolian_Type *tp)
|
|||
*/
|
||||
EAPI Eolian_Value eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m);
|
||||
|
||||
/*
|
||||
* @brief Evaluate an Eolian expression given a type instead of a mask.
|
||||
*
|
||||
* @param[in] expr the expression.
|
||||
* @param[in] type the type the expression is assigned to.
|
||||
* @return the value, its type is set to EOLIAN_EXPR_UNKNOWN on error.
|
||||
*
|
||||
* The mask is automatically decided from the given type, allowing only values
|
||||
* that can be assigned to that type.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eolian_Value eolian_expression_eval_type(const Eolian_Expression *expr, const Eolian_Type *type);
|
||||
|
||||
/*
|
||||
* @brief Convert the result of expression evaluation to a literal as in how
|
||||
* it would appear in C (e.g. strings are quoted and escaped).
|
||||
|
|
|
@ -15,16 +15,6 @@ eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m)
|
|||
return database_expr_eval(NULL, (Eolian_Expression *)expr, m, NULL, NULL);
|
||||
}
|
||||
|
||||
EAPI Eolian_Value
|
||||
eolian_expression_eval_type(const Eolian_Expression *expr,
|
||||
const Eolian_Type *type)
|
||||
{
|
||||
Eolian_Value err;
|
||||
err.type = EOLIAN_EXPR_UNKNOWN;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err);
|
||||
return database_expr_eval_type(NULL, (Eolian_Expression *)expr, type, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_append_char_escaped(Eina_Strbuf *buf, char c)
|
||||
{
|
||||
|
|
|
@ -1015,7 +1015,7 @@ struct variable_def
|
|||
if (!expr)
|
||||
throw std::runtime_error("Could not get constant variable value expression");
|
||||
|
||||
this->expression_value = ::eolian_expression_eval_type(expr, ::eolian_variable_base_type_get(variable));
|
||||
this->expression_value = ::eolian_expression_eval(expr, ::EOLIAN_MASK_ALL);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -800,7 +800,7 @@ EFL_START_TEST(eolian_var)
|
|||
fail_if(!(name = eolian_type_short_name_get(type)));
|
||||
fail_if(strcmp(name, "int"));
|
||||
fail_if(!(exp = eolian_variable_value_get(var)));
|
||||
v = eolian_expression_eval_type(exp, type);
|
||||
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||
fail_if(v.type != EOLIAN_EXPR_INT);
|
||||
fail_if(v.value.i != 5);
|
||||
|
||||
|
@ -812,7 +812,7 @@ EFL_START_TEST(eolian_var)
|
|||
fail_if(!(name = eolian_type_short_name_get(type)));
|
||||
fail_if(strcmp(name, "float"));
|
||||
fail_if(!(exp = eolian_variable_value_get(var)));
|
||||
v = eolian_expression_eval_type(exp, type);
|
||||
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||
fail_if(v.type != EOLIAN_EXPR_FLOAT);
|
||||
fail_if(((int)v.value.f) != 10);
|
||||
|
||||
|
|
Loading…
Reference in New Issue