Nix 2.17.0
Nix, the purely functional package manager; stable external interfaces
|
Definition for a class of external values. More...
#include <nix_api_external.h>
Data Fields | |
void(* | print )(void *self, nix_printer *printer) |
Called when printing the external value. More... | |
void(* | showType )(void *self, nix_string_return *res) |
Called on :t. More... | |
void(* | typeOf )(void *self, nix_string_return *res) |
Called on builtins.typeOf More... | |
void(* | coerceToString )(void *self, nix_string_context *c, int coerceMore, int copyToStore, nix_string_return *res) |
Called on "${str}" and builtins.toString. More... | |
int(* | equal )(void *self, void *other) |
Try to compare two external values. More... | |
void(* | printValueAsJSON )(void *self, State *, int strict, nix_string_context *c, bool copyToStore, nix_string_return *res) |
Convert the external value to json. More... | |
void(* | printValueAsXML )(void *self, State *, int strict, int location, void *doc, nix_string_context *c, void *drvsSeen, int pos) |
Convert the external value to XML. More... | |
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
void(* NixCExternalValueDesc::coerceToString) (void *self, nix_string_context *c, int coerceMore, int copyToStore, nix_string_return *res) |
Called on "${str}" and builtins.toString.
The latter with coerceMore=true Optional, the default is to throw an error.
[in] | self | the void* passed to nix_create_external_value |
[out] | c | writable string context for the resulting string |
[in] | coerceMore | boolean, try to coerce to strings in more cases instead of throwing an error |
[in] | copyToStore | boolean, whether to copy referenced paths to store or keep them as-is |
[out] | res | the return value. Not touching this, or setting it to the empty string, will make the conversion throw an error. |
int(* NixCExternalValueDesc::equal) (void *self, void *other) |
Try to compare two external values.
Optional, the default is always false. If the other object was not a Nix C external value, this comparison will also return false
[in] | self | the void* passed to nix_create_external_value |
[in] | other | the void* passed to the other object's nix_create_external_value |
void(* NixCExternalValueDesc::print) (void *self, nix_printer *printer) |
Called when printing the external value.
[in] | self | the void* passed to nix_create_external_value |
[out] | printer | The printer to print to, pass to nix_external_print |
void(* NixCExternalValueDesc::printValueAsJSON) (void *self, State *, int strict, nix_string_context *c, bool copyToStore, nix_string_return *res) |
Convert the external value to json.
Optional, the default is to throw an error
[in] | self | the void* passed to nix_create_external_value |
[in] | state | The evaluator state |
[in] | strict | boolean Whether to force the value before printing |
[out] | c | writable string context for the resulting string |
[in] | copyToStore | whether to copy referenced paths to store or keep them as-is |
[out] | res | the return value. Gets parsed as JSON. Not touching this, or setting it to the empty string, will make the conversion throw an error. |
void(* NixCExternalValueDesc::printValueAsXML) (void *self, State *, int strict, int location, void *doc, nix_string_context *c, void *drvsSeen, int pos) |
Convert the external value to XML.
Optional, the default is to throw an error
[in] | self | the void* passed to nix_create_external_value |
[in] | state | The evaluator state |
[in] | strict | boolean Whether to force the value before printing |
[in] | location | boolean Whether to include position information in the xml |
[out] | doc | XML document to output to |
[out] | c | writable string context for the resulting string |
[in,out] | drvsSeen | a path set to avoid duplicating derivations |
[in] | pos | The position of the call. |
void(* NixCExternalValueDesc::showType) (void *self, nix_string_return *res) |
Called on :t.
[in] | self | the void* passed to nix_create_external_value |
[out] | res | the return value |
void(* NixCExternalValueDesc::typeOf) (void *self, nix_string_return *res) |
Called on builtins.typeOf
self | the void* passed to nix_create_external_value | |
[out] | res | the return value |