diff --git a/src/libexpr/nix_api_expr.cc b/src/libexpr/nix_api_expr.cc index df8a66053..46c8835f2 100644 --- a/src/libexpr/nix_api_expr.cc +++ b/src/libexpr/nix_api_expr.cc @@ -39,27 +39,15 @@ nix_err nix_libexpr_init(nix_c_context *context) { NIXC_CATCH_ERRS } -Expr *nix_parse_expr_from_string(nix_c_context *context, State *state, - const char *expr, const char *path, - GCRef *ref) { +nix_err nix_expr_eval_from_string(nix_c_context *context, State *state, + const char *expr, const char *path, + Value *value) { if (context) context->last_err_code = NIX_OK; try { - Expr *result = state->state.parseExprFromString( + nix::Expr *parsedExpr = state->state.parseExprFromString( expr, state->state.rootPath(nix::CanonPath(path))); - if (ref) - ref->ptr = result; - return result; - } - NIXC_CATCH_ERRS_NULL -} - -nix_err nix_expr_eval(nix_c_context *context, State *state, Expr *expr, - Value *value) { - if (context) - context->last_err_code = NIX_OK; - try { - state->state.eval((nix::Expr *)expr, *(nix::Value *)value); + state->state.eval(parsedExpr, *(nix::Value *)value); } NIXC_CATCH_ERRS } diff --git a/src/libexpr/nix_api_expr.h b/src/libexpr/nix_api_expr.h index f99fee1b1..e53aa5cd9 100644 --- a/src/libexpr/nix_api_expr.h +++ b/src/libexpr/nix_api_expr.h @@ -13,12 +13,6 @@ extern "C" { // cffi start // Type definitions -/** - * @brief Represents a parsed nix Expression, can be evaluated into a Value. - * - * Owned by the GC. - */ -typedef void Expr; // nix::Expr /** * @brief Represents a nix evaluator state. * @@ -54,34 +48,19 @@ typedef struct GCRef GCRef; // void* nix_err nix_libexpr_init(nix_c_context *context); /** - * @brief Parses a Nix expression from a string. - * - * The returned expression is owned by the garbage collector. - * Pass a gcref to keep a reference. - * - * @param[out] context Optional, stores error information - * @param[in] state Evaluator state. - * @param[in] expr The Nix expression to parse. - * @param[in] path The file path to associate with the expression. - * @param[out] ref Optional, will store a reference to the returned value. - * @return A parsed expression or NULL on failure. - */ -Expr *nix_parse_expr_from_string(nix_c_context *context, State *state, - const char *expr, const char *path, - GCRef *ref); - -/** - * @brief Evaluates a parsed Nix expression. + * @brief Parses and evaluates a Nix expression from a string. * * @param[out] context Optional, stores error information * @param[in] state The state of the evaluation. - * @param[in] expr The Nix expression to evaluate. + * @param[in] expr The Nix expression to parse. + * @param[in] path The file path to associate with the expression. * @param[out] value The result of the evaluation. You should allocate this * yourself. * @return NIX_OK if the evaluation was successful, an error code otherwise. */ -nix_err nix_expr_eval(nix_c_context *context, State *state, Expr *expr, - Value *value); +nix_err nix_expr_eval_from_string(nix_c_context *context, State *state, + const char *expr, const char *path, + Value *value); /** * @brief Calls a Nix function with an argument. diff --git a/src/libexpr/nix_api_value.cc b/src/libexpr/nix_api_value.cc index 4a4a56ac3..6a2f19de9 100644 --- a/src/libexpr/nix_api_value.cc +++ b/src/libexpr/nix_api_value.cc @@ -386,17 +386,6 @@ nix_err nix_copy_value(nix_c_context *context, Value *value, Value *source) { NIXC_CATCH_ERRS } -nix_err nix_set_thunk(nix_c_context *context, State *s, Value *value, - Expr *expr) { - if (context) - context->last_err_code = NIX_OK; - try { - auto &v = check_value_not_null(value); - s->state.mkThunk_(v, (nix::Expr *)expr); - } - NIXC_CATCH_ERRS -} - typedef std::shared_ptr BindingsBuilder_Inner; nix_err nix_make_attrs(nix_c_context *context, Value *value, diff --git a/src/libexpr/nix_api_value.h b/src/libexpr/nix_api_value.h index 6d1604a6f..22ecfa86b 100644 --- a/src/libexpr/nix_api_value.h +++ b/src/libexpr/nix_api_value.h @@ -32,7 +32,6 @@ typedef enum { // forward declarations typedef void Value; -typedef void Expr; typedef struct State State; typedef struct GCRef GCRef; // type defs @@ -307,16 +306,6 @@ nix_err nix_set_primop(nix_c_context *context, Value *value, PrimOp *op); * @return error code, NIX_OK on success. */ nix_err nix_copy_value(nix_c_context *context, Value *value, Value *source); -/** @brief Make a thunk from an expr. - * - * Expr will be evaluated when the value is forced - * @param[out] context Optional, stores error information - * @param[out] value Nix value to modify - * @param[in] expr the expr to thunk - * @return error code, NIX_OK on success. - */ -nix_err nix_set_thunk(nix_c_context *context, State *s, Value *value, - Expr *expr); /**@}*/ /** @brief Create a bindings builder