diff options
author | Vincent Ambo <mail@tazj.in> | 2022-05-18T15·39+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-05-19T14·08+0000 |
commit | d127f9bd0e7b9b2e0df2de8a2227f77c0907468d (patch) | |
tree | 68455040d88b8e0c2817601db88ede450873ff8e /third_party/nix/src/libexpr/primops/fromTOML.cc | |
parent | c85291c602ac666421627d6934ebc6d5be1b93e1 (diff) |
chore(3p/nix): unvendor tvix 0.1 r/4098
Nothing is using this now, and we'll likely never pick this up again, but we learned a lot in the process. Every now and then this breaks in some bizarre way on channel bumps and it's just a waste of time to maintain that. Change-Id: Idcf2f5acd4ca7070ce18d7149cbfc0d967dc0a44 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5632 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: lukegb <lukegb@tvl.fyi> Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'third_party/nix/src/libexpr/primops/fromTOML.cc')
-rw-r--r-- | third_party/nix/src/libexpr/primops/fromTOML.cc | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/third_party/nix/src/libexpr/primops/fromTOML.cc b/third_party/nix/src/libexpr/primops/fromTOML.cc deleted file mode 100644 index e3d2a4940769..000000000000 --- a/third_party/nix/src/libexpr/primops/fromTOML.cc +++ /dev/null @@ -1,94 +0,0 @@ -#include "cpptoml/cpptoml.h" -#include "libexpr/eval-inline.hh" -#include "libexpr/primops.hh" - -namespace nix { - -static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args, - Value& v) { - using namespace cpptoml; - - auto toml = state.forceStringNoCtx(*args[0], pos); - - std::istringstream tomlStream(toml); - - std::function<void(Value&, std::shared_ptr<base>)> visit; - - visit = [&](Value& v, std::shared_ptr<base> t) { - if (auto t2 = t->as_table()) { - size_t size = 0; - for (auto& i : *t2) { - (void)i; - size++; - } - - state.mkAttrs(v, size); - - for (auto& i : *t2) { - auto& v2 = *state.allocAttr(v, state.symbols.Create(i.first)); - - if (auto i2 = i.second->as_table_array()) { - size_t size2 = i2->get().size(); - state.mkList(v2, size2); - for (size_t j = 0; j < size2; ++j) { - visit(*((*v2.list)[j] = state.allocValue()), i2->get()[j]); - } - } else { - visit(v2, i.second); - } - } - } - - else if (auto t2 = t->as_array()) { - size_t size = t2->get().size(); - - state.mkList(v, size); - - for (size_t i = 0; i < size; ++i) { - visit(*((*v.list)[i] = state.allocValue()), t2->get()[i]); - } - } - - // Handle cases like 'a = [[{ a = true }]]', which IMHO should be - // parsed as a array containing an array containing a table, - // but instead are parsed as an array containing a table array - // containing a table. - else if (auto t2 = t->as_table_array()) { - size_t size = t2->get().size(); - - state.mkList(v, size); - - for (size_t j = 0; j < size; ++j) { - visit(*((*v.list)[j] = state.allocValue()), t2->get()[j]); - } - } - - else if (t->is_value()) { - if (auto val = t->as<int64_t>()) { - mkInt(v, val->get()); - } else if (auto val = t->as<NixFloat>()) { - mkFloat(v, val->get()); - } else if (auto val = t->as<bool>()) { - mkBool(v, val->get()); - } else if (auto val = t->as<std::string>()) { - mkString(v, val->get()); - } else { - throw EvalError("unsupported value type in TOML"); - } - } - - else { - abort(); - } - }; - - try { - visit(v, parser(tomlStream).parse()); - } catch (std::runtime_error& e) { - throw EvalError("while parsing a TOML string at %s: %s", pos, e.what()); - } -} - -static RegisterPrimOp r("fromTOML", 1, prim_fromTOML); - -} // namespace nix |