2018-03-27 18:41:31 +02:00
|
|
|
#include "config.hh"
|
2018-02-08 17:26:18 +01:00
|
|
|
#include "primops.hh"
|
2024-03-11 08:50:57 +01:00
|
|
|
#include <stdlib.h>
|
2018-02-08 17:26:18 +01:00
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
2024-03-11 08:50:57 +01:00
|
|
|
#ifdef MISSING_REFERENCE
|
|
|
|
extern void meow();
|
|
|
|
#else
|
|
|
|
#define meow() {}
|
|
|
|
#endif
|
|
|
|
|
2018-03-27 18:41:31 +02:00
|
|
|
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"};
|
2018-03-27 18:41:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
MySettings mySettings;
|
2018-02-13 20:43:32 +01:00
|
|
|
|
2018-03-27 18:41:31 +02:00
|
|
|
static GlobalConfig::Register rs(&mySettings);
|
2018-02-13 20:43:32 +01:00
|
|
|
|
2024-03-11 08:50:57 +01:00
|
|
|
[[gnu::used, gnu::unused, gnu::retain]]
|
|
|
|
static void maybeRequireMeowForDlopen() {
|
|
|
|
meow();
|
|
|
|
}
|
|
|
|
|
2022-03-04 19:31:59 +01:00
|
|
|
static void prim_anotherNull (EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
2018-02-08 17:26:18 +01:00
|
|
|
{
|
2018-03-27 18:41:31 +02:00
|
|
|
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);
|
2018-02-08 17:26:18 +01:00
|
|
|
}
|
|
|
|
|
2023-06-11 17:03:14 +02:00
|
|
|
static RegisterPrimOp rp({
|
|
|
|
.name = "anotherNull",
|
|
|
|
.arity = 0,
|
|
|
|
.fun = prim_anotherNull,
|
|
|
|
});
|