1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

C API: Value -> nix_value

See issue https://github.com/NixOS/nix/issues/10434
This commit is contained in:
Robert Hensing 2024-06-13 18:51:58 +02:00
parent 5d8118d9cb
commit b94e1d6218
8 changed files with 161 additions and 155 deletions

View file

@ -33,11 +33,11 @@ typedef struct EvalState EvalState; // nix::EvalState
/** @brief A Nix language value, or thunk that may evaluate to a value.
*
* Values are the primary objects manipulated in the Nix language.
* They are considered to be immutable from a user's perspective, but the process of evaluating a Value changes its
* ValueType if it was a thunk. After a Value has been evaluated, its ValueType does not change.
* They are considered to be immutable from a user's perspective, but the process of evaluating a value changes its
* ValueType if it was a thunk. After a value has been evaluated, its ValueType does not change.
*
* Evaluation in this context refers to the process of evaluating a single Value object, also called "forcing" the
* Value; see `nix_value_force`.
* Evaluation in this context refers to the process of evaluating a single value object, also called "forcing" the
* value; see `nix_value_force`.
*
* The evaluator manages its own memory, but your use of the C API must follow the reference counting rules.
*
@ -74,7 +74,7 @@ nix_err nix_libexpr_init(nix_c_context * context);
* @return NIX_OK if the evaluation was successful, an error code otherwise.
*/
nix_err nix_expr_eval_from_string(
nix_c_context * context, EvalState * state, const char * expr, const char * path, Value * value);
nix_c_context * context, EvalState * state, const char * expr, const char * path, nix_value * value);
/**
* @brief Calls a Nix function with an argument.
@ -88,7 +88,7 @@ nix_err nix_expr_eval_from_string(
* @see nix_init_apply() for a similar function that does not performs the call immediately, but stores it as a thunk.
* Note the different argument order.
*/
nix_err nix_value_call(nix_c_context * context, EvalState * state, Value * fn, Value * arg, Value * value);
nix_err nix_value_call(nix_c_context * context, EvalState * state, nix_value * fn, nix_value * arg, nix_value * value);
/**
* @brief Calls a Nix function with multiple arguments.
@ -107,7 +107,7 @@ nix_err nix_value_call(nix_c_context * context, EvalState * state, Value * fn, V
* @see NIX_VALUE_CALL For a macro that wraps this function for convenience.
*/
nix_err nix_value_call_multi(
nix_c_context * context, EvalState * state, Value * fn, size_t nargs, Value ** args, Value * value);
nix_c_context * context, EvalState * state, nix_value * fn, size_t nargs, nix_value ** args, nix_value * value);
/**
* @brief Calls a Nix function with multiple arguments.
@ -125,7 +125,7 @@ nix_err nix_value_call_multi(
*/
#define NIX_VALUE_CALL(context, state, value, fn, ...) \
do { \
Value * args_array[] = {__VA_ARGS__}; \
nix_value * args_array[] = {__VA_ARGS__}; \
size_t nargs = sizeof(args_array) / sizeof(args_array[0]); \
nix_value_call_multi(context, state, fn, nargs, args_array, value); \
} while (0)
@ -133,12 +133,10 @@ nix_err nix_value_call_multi(
/**
* @brief Forces the evaluation of a Nix value.
*
* The Nix interpreter is lazy, and not-yet-evaluated Values can be
* The Nix interpreter is lazy, and not-yet-evaluated values can be
* of type NIX_TYPE_THUNK instead of their actual value.
*
* This function mutates such a Value, so that, if successful, it has its final type.
*
* @note This function is mainly needed before calling @ref getters, but not for API calls that return a `Value`.
* This function mutates such a `nix_value`, so that, if successful, it has its final type.
*
* @param[out] context Optional, stores error information
* @param[in] state The state of the evaluation.
@ -147,7 +145,7 @@ nix_err nix_value_call_multi(
* @return NIX_OK if the force operation was successful, an error code
* otherwise.
*/
nix_err nix_value_force(nix_c_context * context, EvalState * state, Value * value);
nix_err nix_value_force(nix_c_context * context, EvalState * state, nix_value * value);
/**
* @brief Forces the deep evaluation of a Nix value.
@ -163,7 +161,7 @@ nix_err nix_value_force(nix_c_context * context, EvalState * state, Value * valu
* @return NIX_OK if the deep force operation was successful, an error code
* otherwise.
*/
nix_err nix_value_force_deep(nix_c_context * context, EvalState * state, Value * value);
nix_err nix_value_force_deep(nix_c_context * context, EvalState * state, nix_value * value);
/**
* @brief Create a new Nix language evaluator state.