1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 07:31:15 +02:00

C API: add a way to throw errors from primops

This commit is contained in:
Yorick van Pelt 2023-08-28 22:19:28 +02:00 committed by José Luis Lafuente
parent 3d79f38709
commit ab9250286a
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
5 changed files with 30 additions and 21 deletions

View file

@ -65,15 +65,17 @@ typedef struct ExternalValue ExternalValue;
* @{
*/
/** @brief Function pointer for primops
* @param[in] user_data Arbitrary data, passed to nix_alloc_primop and stored.
* When you want to return an error, call nix_set_err_msg(context, NIX_ERR_UNKNOWN, "your error message here").
*
* @param[in] user_data Arbitrary data that was initially supplied to nix_alloc_primop
* @param[out] context Stores error information.
* @param[in] state Evaluator state
* @param[in] pos Call position, opaque index into the state's position table.
* @param[in] args list of arguments. Note that these can be thunks and should be forced using nix_value_force before
* use.
* @param[out] ret return value
* @see nix_alloc_primop, nix_set_primop
*/
typedef void (*PrimOpFun)(void * user_data, State * state, int pos, Value ** args, Value * ret);
typedef void (*PrimOpFun)(void * user_data, nix_c_context * context, State * state, Value ** args, Value * ret);
/** @brief Allocate a PrimOp
*
@ -86,7 +88,7 @@ typedef void (*PrimOpFun)(void * user_data, State * state, int pos, Value ** arg
* @param[in] name function name
* @param[in] args array of argument names, NULL-terminated
* @param[in] doc optional, documentation for this primop
* @param[in] user_data optional, arbitrary data, passed to the function when it's called
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called
* @return primop, or null in case of errors
* @see nix_set_primop
*/