mirror of
https://github.com/NixOS/nix
synced 2025-06-30 07:33:16 +02:00
nix_api_value: add nix_get_attr_name_byidx get attr names without forcing
This commit is contained in:
parent
9cccb8bae0
commit
e891aac2e4
2 changed files with 28 additions and 0 deletions
|
@ -266,6 +266,18 @@ Value *nix_get_attr_byidx(nix_c_context *context, const Value *value,
|
|||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
const char *nix_get_attr_name_byidx(nix_c_context *context, const Value *value,
|
||||
State *state, unsigned int i) {
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
try {
|
||||
auto &v = check_value_not_null(value);
|
||||
const nix::Attr &a = (*v.attrs)[i];
|
||||
return ((const std::string &)(state->state.symbols[a.name])).c_str();
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
nix_err nix_set_bool(nix_c_context *context, Value *value, bool b) {
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue