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:
parent
3d79f38709
commit
ab9250286a
5 changed files with 30 additions and 21 deletions
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue