Nix 2.29.1
Nix, the purely functional package manager: C API (experimental)
|
Typedefs | |
typedef struct PrimOp | PrimOp |
PrimOp function. | |
typedef void(* | PrimOpFun) (void *user_data, nix_c_context *context, EvalState *state, nix_value **args, nix_value *ret) |
Function pointer for primops. |
Functions | |
PrimOp * | nix_alloc_primop (nix_c_context *context, PrimOpFun fun, int arity, const char *name, const char **args, const char *doc, void *user_data) |
Allocate a PrimOp. | |
nix_err | nix_register_primop (nix_c_context *context, PrimOp *primOp) |
add a primop to the builtins attribute set |
typedef void(* PrimOpFun) (void *user_data, nix_c_context *context, EvalState *state, nix_value **args, nix_value *ret) |
Function pointer for primops.
When you want to return an error, call nix_set_err_msg(context, NIX_ERR_UNKNOWN, "your error message here").
[in] | user_data | Arbitrary data that was initially supplied to nix_alloc_primop |
[out] | context | Stores error information. |
[in] | state | Evaluator state |
[in] | args | list of arguments. Note that these can be thunks and should be forced using nix_value_force before use. |
[out] | ret | return value |
PrimOp * nix_alloc_primop | ( | nix_c_context * | context, |
PrimOpFun | fun, | ||
int | arity, | ||
const char * | name, | ||
const char ** | args, | ||
const char * | doc, | ||
void * | user_data ) |
Allocate a PrimOp.
Owned by the garbage collector. Use nix_gc_decref() when you're done with the returned PrimOp.
[out] | context | Optional, stores error information |
[in] | fun | callback |
[in] | arity | expected number of function arguments |
[in] | name | function name |
[in] | args | array of argument names, NULL-terminated |
[in] | doc | optional, documentation for this primop |
[in] | user_data | optional, arbitrary data, passed to the callback when it's called |
nix_err nix_register_primop | ( | nix_c_context * | context, |
PrimOp * | primOp ) |
add a primop to the builtins attribute set
Only applies to States created after this call.
Moves your PrimOp content into the global evaluator registry, meaning your input PrimOp pointer is no longer usable. You are free to remove your references to it, after which it will be garbage collected.
[out] | context | Optional, stores error information |