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:
parent
d96b52bd8b
commit
c57de60522
26 changed files with 50 additions and 32 deletions
64
src/libexpr-c/nix_api_expr_internal.h
Normal file
64
src/libexpr-c/nix_api_expr_internal.h
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue