libexpr C bindings dealing with values More...
#include "nix_api_util.h"#include "nix_api_store.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Typedefs | |
| typedef struct nix_value | nix_value |
| typedef struct EvalState | EvalState |
| typedef nix_value | Value |
| typedef struct BindingsBuilder | BindingsBuilder |
| Stores an under-construction set of bindings. | |
| typedef struct ListBuilder | ListBuilder |
| Stores an under-construction list. | |
| typedef struct PrimOp | PrimOp |
| PrimOp function. | |
| typedef struct ExternalValue | ExternalValue |
| External Value. | |
| typedef struct nix_realised_string | nix_realised_string |
| String without placeholders, and realised store paths. | |
| 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 | |
| nix_value * | nix_alloc_value (nix_c_context *context, EvalState *state) |
| Allocate a Nix value. | |
| nix_err | nix_value_incref (nix_c_context *context, nix_value *value) |
Increment the garbage collector reference counter for the given nix_value. | |
| nix_err | nix_value_decref (nix_c_context *context, nix_value *value) |
| Decrement the garbage collector reference counter for the given object. | |
| BindingsBuilder * | nix_make_bindings_builder (nix_c_context *context, EvalState *state, size_t capacity) |
| Create a bindings builder. | |
| nix_err | nix_bindings_builder_insert (nix_c_context *context, BindingsBuilder *builder, const char *name, nix_value *value) |
| Insert bindings into a builder. | |
| void | nix_bindings_builder_free (BindingsBuilder *builder) |
| Free a bindings builder. | |
| nix_realised_string * | nix_string_realise (nix_c_context *context, EvalState *state, nix_value *value, bool isIFD) |
| Realise a string context. | |
| const char * | nix_realised_string_get_buffer_start (nix_realised_string *realised_string) |
| Start of the string. | |
| size_t | nix_realised_string_get_buffer_size (nix_realised_string *realised_string) |
| Length of the string. | |
| size_t | nix_realised_string_get_store_path_count (nix_realised_string *realised_string) |
| Number of realised store paths. | |
| const StorePath * | nix_realised_string_get_store_path (nix_realised_string *realised_string, size_t index) |
| Get a store path. The store paths are stored in an arbitrary order. | |
| void | nix_realised_string_free (nix_realised_string *realised_string) |
| Free a realised string. | |
Getters | |
| ValueType | nix_get_type (nix_c_context *context, const nix_value *value) |
| Get value type. | |
| const char * | nix_get_typename (nix_c_context *context, const nix_value *value) |
| Get type name of value as defined in the evaluator. | |
| bool | nix_get_bool (nix_c_context *context, const nix_value *value) |
| Get boolean value. | |
| nix_err | nix_get_string (nix_c_context *context, const nix_value *value, nix_get_string_callback callback, void *user_data) |
| Get the raw string. | |
| const char * | nix_get_path_string (nix_c_context *context, const nix_value *value) |
| Get path as string. | |
| unsigned int | nix_get_list_size (nix_c_context *context, const nix_value *value) |
| Get the length of a list. | |
| unsigned int | nix_get_attrs_size (nix_c_context *context, const nix_value *value) |
| Get the element count of an attrset. | |
| double | nix_get_float (nix_c_context *context, const nix_value *value) |
| Get float value in 64 bits. | |
| int64_t | nix_get_int (nix_c_context *context, const nix_value *value) |
| Get int value. | |
| ExternalValue * | nix_get_external (nix_c_context *context, nix_value *value) |
| Get external reference. | |
| nix_value * | nix_get_list_byidx (nix_c_context *context, const nix_value *value, EvalState *state, unsigned int ix) |
| Get the ix'th element of a list. | |
| nix_value * | nix_get_attr_byname (nix_c_context *context, const nix_value *value, EvalState *state, const char *name) |
| Get an attr by name. | |
| bool | nix_has_attr_byname (nix_c_context *context, const nix_value *value, EvalState *state, const char *name) |
| Check if an attribute name exists on a value. | |
| nix_value * | nix_get_attr_byidx (nix_c_context *context, const nix_value *value, EvalState *state, unsigned int i, const char **name) |
| Get an attribute by index in the sorted bindings. | |
| const char * | nix_get_attr_name_byidx (nix_c_context *context, const nix_value *value, EvalState *state, unsigned int i) |
| Get an attribute name by index in the sorted bindings. | |
Initializers | |
Values are typically "returned" by initializing already allocated memory that serves as the return value. For this reason, the construction of values is not tied their allocation. Nix is a language with immutable values. Respect this property by only initializing Values once; and only initialize Values that are meant to be initialized by you. Failing to adhere to these rules may lead to undefined behavior. | |
| nix_err | nix_init_bool (nix_c_context *context, nix_value *value, bool b) |
| Set boolean value. | |
| nix_err | nix_init_string (nix_c_context *context, nix_value *value, const char *str) |
| Set a string. | |
| nix_err | nix_init_path_string (nix_c_context *context, EvalState *s, nix_value *value, const char *str) |
| Set a path. | |
| nix_err | nix_init_float (nix_c_context *context, nix_value *value, double d) |
| Set a float. | |
| nix_err | nix_init_int (nix_c_context *context, nix_value *value, int64_t i) |
| Set an int. | |
| nix_err | nix_init_null (nix_c_context *context, nix_value *value) |
| Set null. | |
| nix_err | nix_init_apply (nix_c_context *context, nix_value *value, nix_value *fn, nix_value *arg) |
| Set the value to a thunk that will perform a function application when needed. | |
| nix_err | nix_init_external (nix_c_context *context, nix_value *value, ExternalValue *val) |
| Set an external value. | |
| nix_err | nix_make_list (nix_c_context *context, ListBuilder *list_builder, nix_value *value) |
| Create a list from a list builder. | |
| ListBuilder * | nix_make_list_builder (nix_c_context *context, EvalState *state, size_t capacity) |
| Create a list builder. | |
| nix_err | nix_list_builder_insert (nix_c_context *context, ListBuilder *list_builder, unsigned int index, nix_value *value) |
| Insert bindings into a builder. | |
| void | nix_list_builder_free (ListBuilder *list_builder) |
| Free a list builder. | |
| nix_err | nix_make_attrs (nix_c_context *context, nix_value *value, BindingsBuilder *b) |
| Create an attribute set from a bindings builder. | |
| nix_err | nix_init_primop (nix_c_context *context, nix_value *value, PrimOp *op) |
| Set primop. | |
| nix_err | nix_copy_value (nix_c_context *context, nix_value *value, const nix_value *source) |
| Copy from another value. | |
libexpr C bindings dealing with values