mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-31 15:36:47 +02:00
C API: Add nix_value_{inc,dec}ref
- Can be implemented more easily by more eval architectures. - Better types in generated bindings remove some uncertainty and doubt.
This commit is contained in:
parent
0b56c98b1c
commit
c50db4e58c
3 changed files with 33 additions and 0 deletions
|
@ -181,6 +181,15 @@ nix_err nix_gc_decref(nix_c_context * context, const void *)
|
||||||
void nix_gc_now() {}
|
void nix_gc_now() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nix_err nix_value_incref(nix_c_context * context, nix_value *x)
|
||||||
|
{
|
||||||
|
return nix_gc_incref(context, (const void *) x);
|
||||||
|
}
|
||||||
|
nix_err nix_value_decref(nix_c_context * context, nix_value *x)
|
||||||
|
{
|
||||||
|
return nix_gc_decref(context, (const void *) x);
|
||||||
|
}
|
||||||
|
|
||||||
void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd))
|
void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_BOEHMGC
|
#ifdef HAVE_BOEHMGC
|
||||||
|
|
|
@ -189,6 +189,11 @@ void nix_state_free(EvalState * state);
|
||||||
* you're done with a value returned by the evaluator.
|
* you're done with a value returned by the evaluator.
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Deprecate nix_gc_incref in favor of the type-specific reference counting functions?
|
||||||
|
// e.g. nix_value_incref.
|
||||||
|
// It gives implementors more flexibility, and adds safety, so that generated
|
||||||
|
// bindings can be used without fighting the host type system (where applicable).
|
||||||
/**
|
/**
|
||||||
* @brief Increment the garbage collector reference counter for the given object.
|
* @brief Increment the garbage collector reference counter for the given object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -147,6 +147,25 @@ nix_err nix_register_primop(nix_c_context * context, PrimOp * primOp);
|
||||||
*/
|
*/
|
||||||
Value * nix_alloc_value(nix_c_context * context, EvalState * state);
|
Value * nix_alloc_value(nix_c_context * context, EvalState * state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Increment the garbage collector reference counter for the given `nix_value`.
|
||||||
|
*
|
||||||
|
* The Nix language evaluator C API keeps track of alive objects by reference counting.
|
||||||
|
* When you're done with a refcounted pointer, call nix_value_decref().
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] value The object to keep alive
|
||||||
|
*/
|
||||||
|
nix_err nix_value_incref(nix_c_context * context, nix_value * value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decrement the garbage collector reference counter for the given object
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] value The object to stop referencing
|
||||||
|
*/
|
||||||
|
nix_err nix_value_decref(nix_c_context * context, nix_value * value);
|
||||||
|
|
||||||
/** @addtogroup value_manip Manipulating values
|
/** @addtogroup value_manip Manipulating values
|
||||||
* @brief Functions to inspect and change Nix language values, represented by Value.
|
* @brief Functions to inspect and change Nix language values, represented by Value.
|
||||||
* @{
|
* @{
|
||||||
|
|
Loading…
Reference in a new issue