lix/tests/functional/plugins/plugintest.cc

41 lines
763 B
C++
Raw Normal View History

#include "config.hh"
#include "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",
2018-02-13 20:43:32 +01:00
"Whether the plugin-defined setting was set"};
};
MySettings mySettings;
2018-02-13 20:43:32 +01:00
static GlobalConfig::Register rs(&mySettings);
2018-02-13 20:43:32 +01:00
[[gnu::used, gnu::unused, gnu::retain]]
static void maybeRequireMeowForDlopen() {
meow();
}
static void prim_anotherNull (EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
if (mySettings.settingSet)
2022-01-04 18:40:39 +01:00
v.mkNull();
2018-02-13 20:43:32 +01:00
else
2022-01-04 18:40:39 +01:00
v.mkBool(false);
}
static RegisterPrimOp rp({
.name = "anotherNull",
.arity = 0,
.fun = prim_anotherNull,
});