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:
parent
c57de60522
commit
925a8fda6e
4 changed files with 16 additions and 38 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue