From 2349185c966983ee1ac1d748f53be5b42461ebcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Lafuente?= <jose.lafuente@tweag.io> Date: Sun, 25 Feb 2024 00:26:36 +0100 Subject: [PATCH] C API: fix after rebase --- src/libexpr/c/nix_api_external.cc | 10 +++++++--- src/libexpr/c/nix_api_external.h | 4 ++-- src/libexpr/c/nix_api_value.cc | 3 +-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libexpr/c/nix_api_external.cc b/src/libexpr/c/nix_api_external.cc index 2e8a98567..3af4af4d4 100644 --- a/src/libexpr/c/nix_api_external.cc +++ b/src/libexpr/c/nix_api_external.cc @@ -108,17 +108,21 @@ public: * Coerce the value to a string. */ virtual std::string coerceToString( - const nix::Pos & pos, nix::NixStringContext & context, bool copyMore, bool copyToStore) const override + nix::EvalState & state, + const nix::PosIdx & pos, + nix::NixStringContext & context, + bool copyMore, + bool copyToStore) const override { if (!desc.coerceToString) { - return nix::ExternalValueBase::coerceToString(pos, context, copyMore, copyToStore); + return nix::ExternalValueBase::coerceToString(state, pos, context, copyMore, copyToStore); } nix_string_context ctx{context}; nix_string_return res{""}; // todo: pos, errors desc.coerceToString(v, &ctx, copyMore, copyToStore, &res); if (res.str.empty()) { - return nix::ExternalValueBase::coerceToString(pos, context, copyMore, copyToStore); + return nix::ExternalValueBase::coerceToString(state, pos, context, copyMore, copyToStore); } return std::move(res.str); } diff --git a/src/libexpr/c/nix_api_external.h b/src/libexpr/c/nix_api_external.h index c935bbe56..12ea00407 100644 --- a/src/libexpr/c/nix_api_external.h +++ b/src/libexpr/c/nix_api_external.h @@ -165,7 +165,7 @@ typedef struct NixCExternalValueDesc } NixCExternalValueDesc; /** - * @brief Create an external value, that can be given to nix_set_external + * @brief Create an external value, that can be given to nix_init_external * * Owned by the GC. Use nix_gc_decref when you're done with the pointer. * @@ -174,7 +174,7 @@ typedef struct NixCExternalValueDesc * as the ExternalValue lives * @param[in] v the value to store * @returns external value, owned by the garbage collector - * @see nix_set_external + * @see nix_init_external */ ExternalValue * nix_create_external_value(nix_c_context * context, NixCExternalValueDesc * desc, void * v); diff --git a/src/libexpr/c/nix_api_value.cc b/src/libexpr/c/nix_api_value.cc index dbddbd876..e63d13f7a 100644 --- a/src/libexpr/c/nix_api_value.cc +++ b/src/libexpr/c/nix_api_value.cc @@ -72,8 +72,7 @@ static void nix_c_primop_wrapper( f(userdata, &ctx, (EvalState *) &state, (Value **) args, (Value *) &v); /* TODO: In the future, this should throw different errors depending on the error code */ if (ctx.last_err_code != NIX_OK) - state.debugThrowLastTrace(nix::Error( - {.msg = nix::hintfmt("Error from builtin function: %s", *ctx.last_err), .errPos = state.positions[pos]})); + state.error<nix::EvalError>("Error from builtin function: %s", *ctx.last_err).atPos(pos).debugThrow(); } PrimOp * nix_alloc_primop(