|
Nix 2.34.6
Nix, the purely functional package manager: C API (experimental)
|
Data Structures | |
| struct | PrimOp |
| PrimOp function. More... | |
Typedefs | |
| 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.
Call 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 becomes invalid. The PrimOp must not be used with nix_init_primop() before or after this call, as this would cause undefined behavior. You must call nix_gc_decref() on the original PrimOp pointer after this call to release your reference.
| [out] | context | Optional, stores error information |
| [in] | primOp | PrimOp to register |