mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-07 18:57:19 +02:00
C API: fix after rebase
This commit is contained in:
parent
6c231dcf68
commit
2349185c96
3 changed files with 10 additions and 7 deletions
|
@ -108,17 +108,21 @@ public:
|
||||||
* Coerce the value to a string.
|
* Coerce the value to a string.
|
||||||
*/
|
*/
|
||||||
virtual std::string coerceToString(
|
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) {
|
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_context ctx{context};
|
||||||
nix_string_return res{""};
|
nix_string_return res{""};
|
||||||
// todo: pos, errors
|
// todo: pos, errors
|
||||||
desc.coerceToString(v, &ctx, copyMore, copyToStore, &res);
|
desc.coerceToString(v, &ctx, copyMore, copyToStore, &res);
|
||||||
if (res.str.empty()) {
|
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);
|
return std::move(res.str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ typedef struct NixCExternalValueDesc
|
||||||
} 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.
|
* 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
|
* as the ExternalValue lives
|
||||||
* @param[in] v the value to store
|
* @param[in] v the value to store
|
||||||
* @returns external value, owned by the garbage collector
|
* @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);
|
ExternalValue * nix_create_external_value(nix_c_context * context, NixCExternalValueDesc * desc, void * v);
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,7 @@ static void nix_c_primop_wrapper(
|
||||||
f(userdata, &ctx, (EvalState *) &state, (Value **) args, (Value *) &v);
|
f(userdata, &ctx, (EvalState *) &state, (Value **) args, (Value *) &v);
|
||||||
/* TODO: In the future, this should throw different errors depending on the error code */
|
/* TODO: In the future, this should throw different errors depending on the error code */
|
||||||
if (ctx.last_err_code != NIX_OK)
|
if (ctx.last_err_code != NIX_OK)
|
||||||
state.debugThrowLastTrace(nix::Error(
|
state.error<nix::EvalError>("Error from builtin function: %s", *ctx.last_err).atPos(pos).debugThrow();
|
||||||
{.msg = nix::hintfmt("Error from builtin function: %s", *ctx.last_err), .errPos = state.positions[pos]}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimOp * nix_alloc_primop(
|
PrimOp * nix_alloc_primop(
|
||||||
|
|
Loading…
Add table
Reference in a new issue