2023-07-14 16:53:30 +03:00
|
|
|
#ifndef NIX_API_EXPR_INTERNAL_H
|
|
|
|
#define NIX_API_EXPR_INTERNAL_H
|
|
|
|
|
2023-08-11 12:49:10 +03:00
|
|
|
#include "eval.hh"
|
|
|
|
#include "attr-set.hh"
|
2024-02-27 23:08:00 +02:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
};
|
2023-07-14 16:53:30 +03:00
|
|
|
|
2024-01-10 12:58:35 +02:00
|
|
|
struct EvalState
|
2023-08-28 17:45:02 +03:00
|
|
|
{
|
|
|
|
nix::EvalState state;
|
2023-07-14 16:53:30 +03:00
|
|
|
};
|
|
|
|
|
2023-08-28 17:45:02 +03:00
|
|
|
struct BindingsBuilder
|
|
|
|
{
|
|
|
|
nix::BindingsBuilder builder;
|
2023-07-27 16:58:18 +03:00
|
|
|
};
|
|
|
|
|
2024-02-27 23:08:00 +02:00
|
|
|
struct ListBuilder
|
|
|
|
{
|
|
|
|
CListBuilder builder;
|
|
|
|
};
|
|
|
|
|
2024-02-25 01:28:04 +02:00
|
|
|
struct nix_string_return
|
|
|
|
{
|
|
|
|
std::string str;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nix_printer
|
|
|
|
{
|
|
|
|
std::ostream & s;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nix_string_context
|
|
|
|
{
|
|
|
|
nix::NixStringContext & ctx;
|
|
|
|
};
|
|
|
|
|
2023-07-14 16:53:30 +03:00
|
|
|
#endif // NIX_API_EXPR_INTERNAL_H
|