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

C API: Keep the structure flat

See https://github.com/NixOS/nix/pull/10329
This commit is contained in:
José Luis Lafuente 2024-03-28 19:00:04 +01:00
parent d96b52bd8b
commit c57de60522
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
26 changed files with 50 additions and 32 deletions

View file

@ -0,0 +1,64 @@
#ifndef NIX_API_EXPR_INTERNAL_H
#define NIX_API_EXPR_INTERNAL_H
#include "eval.hh"
#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;
};
struct BindingsBuilder
{
nix::BindingsBuilder builder;
};
struct ListBuilder
{
CListBuilder builder;
};
struct nix_string_return
{
std::string str;
};
struct nix_printer
{
std::ostream & s;
};
struct nix_string_context
{
nix::NixStringContext & ctx;
};
#endif // NIX_API_EXPR_INTERNAL_H