mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
C API: add more tests
This commit is contained in:
parent
2e1dbbe307
commit
1093ab64a2
6 changed files with 86 additions and 26 deletions
|
@ -382,13 +382,13 @@ nix_err nix_init_string(nix_c_context * context, Value * value, const char * str
|
|||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_init_path_string(nix_c_context * context, Value * value, const char * str)
|
||||
nix_err nix_init_path_string(nix_c_context * context, EvalState * s, Value * value, const char * str)
|
||||
{
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
try {
|
||||
auto & v = check_value_not_null(value);
|
||||
v.mkPath(std::string_view(str));
|
||||
v.mkPath(s->state.rootPath(nix::CanonPath(str)));
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ nix_err nix_register_primop(nix_c_context * context, PrimOp * primOp);
|
|||
* @return value, or null in case of errors
|
||||
*
|
||||
*/
|
||||
|
||||
Value * nix_alloc_value(nix_c_context * context, EvalState * state);
|
||||
/** @addtogroup value_manip Manipulating values
|
||||
* @brief Functions to inspect and change Nix language values, represented by Value.
|
||||
|
@ -142,6 +143,7 @@ Value * nix_alloc_value(nix_c_context * context, EvalState * state);
|
|||
* @param[in] value Nix value to inspect
|
||||
* @return type of nix value
|
||||
*/
|
||||
|
||||
ValueType nix_get_type(nix_c_context * context, const Value * value);
|
||||
/** @brief Get type name of value as defined in the evaluator
|
||||
* @param[out] context Optional, stores error information
|
||||
|
@ -149,6 +151,7 @@ ValueType nix_get_type(nix_c_context * context, const Value * value);
|
|||
* @return type name, owned string
|
||||
* @todo way to free the result
|
||||
*/
|
||||
|
||||
const char * nix_get_typename(nix_c_context * context, const Value * value);
|
||||
|
||||
/** @brief Get boolean value
|
||||
|
@ -290,24 +293,24 @@ nix_err nix_init_bool(nix_c_context * context, Value * value, bool b);
|
|||
* @param[in] str the string, copied
|
||||
* @return error code, NIX_OK on success.
|
||||
*/
|
||||
|
||||
nix_err nix_init_string(nix_c_context * context, Value * value, const char * str);
|
||||
|
||||
/** @brief Set a path
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[out] value Nix value to modify
|
||||
* @param[in] str the path string, copied
|
||||
* @return error code, NIX_OK on success.
|
||||
*/
|
||||
nix_err nix_init_path_string(nix_c_context * context, EvalState * s, Value * value, const char * str);
|
||||
|
||||
nix_err nix_init_path_string(nix_c_context * context, Value * value, const char * str);
|
||||
/** @brief Set a float
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[out] value Nix value to modify
|
||||
* @param[in] d the float, 64-bits
|
||||
* @return error code, NIX_OK on success.
|
||||
*/
|
||||
|
||||
nix_err nix_init_float(nix_c_context * context, Value * value, double d);
|
||||
|
||||
/** @brief Set an int
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[out] value Nix value to modify
|
||||
|
|
|
@ -897,11 +897,6 @@ void Value::mkStringMove(const char * s, const NixStringContext & context)
|
|||
copyContextToValue(*this, context);
|
||||
}
|
||||
|
||||
void Value::mkPath(std::string_view path)
|
||||
{
|
||||
mkPath(makeImmutableString(path));
|
||||
}
|
||||
|
||||
void Value::mkPath(const SourcePath & path)
|
||||
{
|
||||
mkPath(&*path.accessor, makeImmutableString(path.path.abs()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue