Nix 2.29.1
Nix, the purely functional package manager: C API (experimental)
Loading...
Searching...
No Matches
Externals

Deal with external values. More...

Files

file  nix_api_external.h
 libexpr C bindings dealing with external values

Data Structures

struct  NixCExternalValueDesc
 Definition for a class of external values. More...

Typedefs

typedef struct nix_string_return nix_string_return
 Represents a string owned by the Nix language evaluator.
typedef struct nix_printer nix_printer
 Wraps a stream that can output multiple string pieces.
typedef struct nix_string_context nix_string_context
 A list of string context items.
typedef struct NixCExternalValueDesc NixCExternalValueDesc
 Definition for a class of external values.
typedef struct ExternalValue ExternalValue
 External Value.

Functions

void nix_set_string_return (nix_string_return *str, const char *c)
 Sets the contents of a nix_string_return.
nix_err nix_external_print (nix_c_context *context, nix_printer *printer, const char *str)
nix_err nix_external_add_string_context (nix_c_context *context, nix_string_context *string_context, const char *c)
ExternalValuenix_create_external_value (nix_c_context *context, NixCExternalValueDesc *desc, void *v)
 Create an external value, that can be given to nix_init_external.
void * nix_get_external_value_content (nix_c_context *context, ExternalValue *b)
 Extract the pointer from a nix c external value.

Detailed Description

Deal with external values.

Typedef Documentation

◆ ExternalValue

typedef struct ExternalValue ExternalValue

External Value.

Owned by the GC

◆ nix_string_return

Represents a string owned by the Nix language evaluator.

See also
nix_set_owned_string

◆ NixCExternalValueDesc

typedef struct NixCExternalValueDesc NixCExternalValueDesc

Definition for a class of external values.

Create and implement one of these, then pass it to nix_create_external_value Make sure to keep it alive while the external value lives.

Optional functions can be set to NULL

See also
nix_create_external_value

Function Documentation

◆ nix_create_external_value()

ExternalValue * nix_create_external_value ( nix_c_context * context,
NixCExternalValueDesc * desc,
void * v )

Create an external value, that can be given to nix_init_external.

Owned by the GC. Use nix_gc_decref when you're done with the pointer.

Parameters
[out]contextOptional, stores error information
[in]desca NixCExternalValueDesc, you should keep this alive as long as the ExternalValue lives
[in]vthe value to store
Returns
external value, owned by the garbage collector
See also
nix_init_external

◆ nix_external_add_string_context()

nix_err nix_external_add_string_context ( nix_c_context * context,
nix_string_context * string_context,
const char * c )

Add string context to the nix_string_context object

Parameters
[out]contextOptional, stores error information
[out]string_contextThe nix_string_context to add to
[in]cThe context string to add
Returns
NIX_OK if everything worked

◆ nix_external_print()

nix_err nix_external_print ( nix_c_context * context,
nix_printer * printer,
const char * str )

Print to the nix_printer

Parameters
[out]contextOptional, stores error information
[out]printerThe nix_printer to print to
[in]strThe string to print
Returns
NIX_OK if everything worked

◆ nix_get_external_value_content()

void * nix_get_external_value_content ( nix_c_context * context,
ExternalValue * b )

Extract the pointer from a nix c external value.

Parameters
[out]contextOptional, stores error information
[in]bThe external value
Returns
The pointer, or null if the external value was not from nix c.
See also
nix_get_external

◆ nix_set_string_return()

void nix_set_string_return ( nix_string_return * str,
const char * c )

Sets the contents of a nix_string_return.

Copies the passed string.

Parameters
[out]strthe nix_string_return to write to
[in]cThe string to copy