1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 19:01:16 +02:00

C API: Use new ListBuilder helper

See https://github.com/NixOS/nix/pull/10251
This commit is contained in:
José Luis Lafuente 2024-03-28 19:02:01 +01:00
parent c57de60522
commit 925a8fda6e
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
4 changed files with 16 additions and 38 deletions

View file

@ -5,32 +5,6 @@
#include "attr-set.hh"
#include "nix_api_value.h"
class CListBuilder
{
private:
std::vector<nix::Value *> values;
public:
CListBuilder(size_t capacity)
{
values.reserve(capacity);
}
void push_back(nix::Value * value)
{
values.push_back(value);
}
Value * finish(nix::EvalState * state, nix::Value * list)
{
state->mkList(*list, values.size());
for (size_t n = 0; n < list->listSize(); ++n) {
list->listElems()[n] = values[n];
}
return list;
}
};
struct EvalState
{
nix::EvalState state;
@ -43,7 +17,7 @@ struct BindingsBuilder
struct ListBuilder
{
CListBuilder builder;
nix::ListBuilder builder;
};
struct nix_string_return