Files
lix/tests/functional/plugins/plugintest.cc
T
eldritch horrors 6cc2ef7c6d libexpr: remove RegisterPrimOp static initializer helper
Change-Id: I0cc6d54fca26c66b13f930303086b08b2afb4d54
2026-01-14 16:22:08 +00:00

48 lines
898 B
C++

#include "lix/libutil/config.hh"
#include "lix/libexpr/primops.hh"
#include <stdlib.h>
using namespace nix;
#ifdef MISSING_REFERENCE
extern void meow();
#else
#define meow() {}
#endif
struct MySettings : Config
{
Setting<bool> settingSet{this, false, "setting-set",
"Whether the plugin-defined setting was set"};
};
bool entryCalled = false;
MySettings mySettings;
static GlobalConfig::Register rs(&mySettings);
[[gnu::used, gnu::unused, gnu::retain]]
static void maybeRequireMeowForDlopen() {
meow();
}
static void prim_anotherNull (EvalState & state, Value ** args, Value & v)
{
assert(entryCalled);
if (mySettings.settingSet)
v.mkNull();
else
v.mkBool(false);
}
extern "C" void nix_plugin_entry()
{
PluginPrimOps::add({
.name = "anotherNull",
.arity = 0,
.fun = prim_anotherNull,
});
entryCalled = true;
}