summaryrefslogtreecommitdiffstats
path: root/lib/base/boolean-script.cpp
blob: a9167ca87268e7c66b62b0e7efab6b33d2aeff1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

#include "base/boolean.hpp"
#include "base/convert.hpp"
#include "base/function.hpp"
#include "base/functionwrapper.hpp"
#include "base/scriptframe.hpp"

using namespace icinga;

static String BooleanToString()
{
	ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
	bool self = vframe->Self;
	return self ? "true" : "false";
}

Object::Ptr Boolean::GetPrototype()
{
	static Dictionary::Ptr prototype = new Dictionary({
		{ "to_string", new Function("Boolean#to_string", BooleanToString, {}, true) }
	});

	return prototype;
}