*/
EAPI Eolian_Value eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m);
+/*
+ * @brief Evaluate an Eolian expression into an out-param.
+ *
+ * @param[in] expr the expression.
+ * @param[in] mask the mask of allowed values (can combine with bitwise OR).
+ * @param[out] the value to fill
+ * @return EINA_TRUE on success, EINA_FALSE on failure
+ *
+ * This is like eolian_expression_eval, except it writes into an out-param
+ * and returns whether it succeeded or failed. On failure, no write is
+ * guaranteed.
+ *
+ * @since 1.25
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_expression_eval_fill(const Eolian_Expression *expr, Eolian_Expression_Mask m, Eolian_Value *val);
+
/*
* @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).
*/
EAPI Eolian_Value eolian_expression_value_get(const Eolian_Expression *expr);
+/*
+ * @brief Get the value of an expression into an out-param.
+ *
+ * @param[in] expr the expression.
+ * @param[out] val the value to fill.
+ * @return EINA_TRUE on success, EINA_FALSE on failure
+ *
+ * This is like eolian_expression_value_get, but it fills an out-param. On
+ * failure, nothing is guaranteed to be filled.
+ *
+ * @since 1.25
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_expression_value_get_fill(const Eolian_Expression *expr, Eolian_Value *val);
+
/*
* @brief Get the documentation of a constant.
*
return database_expr_eval(NULL, (Eolian_Expression *)expr, m, NULL, NULL);
}
+EAPI Eina_Bool
+eolian_expression_eval_fill(const Eolian_Expression *expr,
+ Eolian_Expression_Mask m, Eolian_Value *val)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(expr, EINA_FALSE);
+ Eolian_Value ret = database_expr_eval(NULL, (Eolian_Expression *)expr, m,
+ NULL, NULL);
+ if (ret.type == EOLIAN_EXPR_UNKNOWN)
+ return EINA_FALSE;
+ *val = ret;
+ return EINA_TRUE;
+}
+
static void
_append_char_escaped(Eina_Strbuf *buf, char c)
{
v.value = expr->value;
return v;
}
+
+EAPI Eina_Bool
+eolian_expression_value_get_fill(const Eolian_Expression *expr, Eolian_Value *val)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(expr, EINA_FALSE);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(expr->type != EOLIAN_EXPR_UNKNOWN
+ && expr->type != EOLIAN_EXPR_BINARY
+ && expr->type != EOLIAN_EXPR_UNARY, EINA_FALSE);
+ val->type = expr->type;
+ val->value = expr->value;
+ return EINA_TRUE;
+}
const Eolian_Type *tp;
const Eolian_Unit *unit;
Eina_Iterator *iter;
- Eolian_Value v;
+ Eolian_Value v, vv;
void *dummy;
Eolian_State *eos = eolian_state_new();
/* Set return */
tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
fail_if(!tp);
- printf("BUILT %d\n", (int)eolian_type_builtin_type_get(tp));
fail_if(eolian_type_builtin_type_get(tp) != EOLIAN_TYPE_BUILTIN_BOOL);
fail_if(strcmp(eolian_type_short_name_get(tp), "bool"));
expr = eolian_function_return_default_value_get(fid, EOLIAN_PROP_SET);
fail_if(!expr);
v = eolian_expression_eval(expr, EOLIAN_MASK_BOOL);
+ fail_if(!eolian_expression_eval_fill(expr, EOLIAN_MASK_BOOL, &vv));
fail_if(v.type != EOLIAN_EXPR_BOOL);
+ fail_if(vv.type != EOLIAN_EXPR_BOOL);
/* Get return */
tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
fail_if(tp);