nix_api_expr: document nix_value_force

This commit is contained in:
Yorick van Pelt 2023-08-03 15:45:39 +02:00 committed by José Luis Lafuente
parent e58a9384c6
commit e74d6c1b3d
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
2 changed files with 13 additions and 1 deletions

View file

@ -97,9 +97,15 @@ nix_err nix_value_call(nix_c_context *context, State *state, Value *fn,
/** /**
* @brief Forces the evaluation of a Nix value. * @brief Forces the evaluation of a Nix value.
* *
* The Nix interpreter is lazy, and not-yet-evaluated Values can be
* of type NIX_TYPE_THUNK instead of their actual value.
*
* This function converts Values into their final type.
*
* @param[out] context Optional, stores error information * @param[out] context Optional, stores error information
* @param[in] state The state of the evaluation. * @param[in] state The state of the evaluation.
* @param[in,out] value The Nix value to force. * @param[in,out] value The Nix value to force.
* @post values is not of type NIX_TYPE_THUNK
* @return NIX_OK if the force operation was successful, an error code * @return NIX_OK if the force operation was successful, an error code
* otherwise. * otherwise.
*/ */
@ -108,6 +114,11 @@ nix_err nix_value_force(nix_c_context *context, State *state, Value *value);
/** /**
* @brief Forces the deep evaluation of a Nix value. * @brief Forces the deep evaluation of a Nix value.
* *
* Recursively calls nix_value_force
*
* @see nix_value_force
* @warning Calling this function on a recursive data structure will cause a
* stack overflow.
* @param[out] context Optional, stores error information * @param[out] context Optional, stores error information
* @param[in] state The state of the evaluation. * @param[in] state The state of the evaluation.
* @param[in,out] value The Nix value to force. * @param[in,out] value The Nix value to force.

View file

@ -23,7 +23,8 @@ extern "C" {
* @brief Dealing with errors from the Nix side * @brief Dealing with errors from the Nix side
* *
* To handle errors that can be returned from the Nix API, * To handle errors that can be returned from the Nix API,
* a nix_c_context can be passed to any function that potentially returns an error. * a nix_c_context can be passed to any function that potentially returns an
* error.
* *
* Error information will be stored in this context, and can be retrieved * Error information will be stored in this context, and can be retrieved
* using nix_err_code and nix_err_msg. * using nix_err_code and nix_err_msg.