mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 14:14:45 +02:00
parent
4e96d48e87
commit
b4c74efde0
@ -23,6 +23,7 @@
|
||||
#include "base/scriptframe.hpp"
|
||||
#include "base/initialize.hpp"
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <cmath>
|
||||
|
||||
@ -138,6 +139,26 @@ static double MathTan(double x)
|
||||
return std::tan(x);
|
||||
}
|
||||
|
||||
static bool MathIsnan(double x)
|
||||
{
|
||||
return boost::math::isnan(x);
|
||||
}
|
||||
|
||||
static bool MathIsinf(double x)
|
||||
{
|
||||
return boost::math::isinf(x);
|
||||
}
|
||||
|
||||
static double MathSign(double x)
|
||||
{
|
||||
if (x > 0)
|
||||
return 1;
|
||||
else if (x < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void InitializeMathObj(void)
|
||||
{
|
||||
Dictionary::Ptr mathObj = new Dictionary();
|
||||
@ -171,6 +192,9 @@ static void InitializeMathObj(void)
|
||||
mathObj->Set("sin", new ScriptFunction(WrapScriptFunction(MathSin)));
|
||||
mathObj->Set("sqrt", new ScriptFunction(WrapScriptFunction(MathSqrt)));
|
||||
mathObj->Set("tan", new ScriptFunction(WrapScriptFunction(MathTan)));
|
||||
mathObj->Set("isnan", new ScriptFunction(WrapScriptFunction(MathIsnan)));
|
||||
mathObj->Set("isinf", new ScriptFunction(WrapScriptFunction(MathIsinf)));
|
||||
mathObj->Set("sign", new ScriptFunction(WrapScriptFunction(MathSign)));
|
||||
|
||||
ScriptGlobal::Set("Math", mathObj);
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ bool icinga::operator<(const Value& lhs, const Value& rhs)
|
||||
if (lhs.IsString() && rhs.IsString())
|
||||
return static_cast<String>(lhs) < static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
return static_cast<double>(lhs) < static_cast<double>(rhs);
|
||||
else if (lhs.GetTypeName() != rhs.GetTypeName())
|
||||
return lhs.GetTypeName() < rhs.GetTypeName();
|
||||
else
|
||||
@ -586,7 +586,7 @@ bool icinga::operator>(const Value& lhs, const Value& rhs)
|
||||
if (lhs.IsString() && rhs.IsString())
|
||||
return static_cast<String>(lhs) > static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
return static_cast<double>(lhs) > static_cast<double>(rhs);
|
||||
else if (lhs.GetTypeName() != rhs.GetTypeName())
|
||||
return lhs.GetTypeName() > rhs.GetTypeName();
|
||||
else
|
||||
@ -618,7 +618,7 @@ bool icinga::operator<=(const Value& lhs, const Value& rhs)
|
||||
if (lhs.IsString() && rhs.IsString())
|
||||
return static_cast<String>(lhs) <= static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
return static_cast<double>(lhs) <= static_cast<double>(rhs);
|
||||
else if (lhs.GetTypeName() != rhs.GetTypeName())
|
||||
return lhs.GetTypeName() <= rhs.GetTypeName();
|
||||
else
|
||||
@ -650,7 +650,7 @@ bool icinga::operator>=(const Value& lhs, const Value& rhs)
|
||||
if (lhs.IsString() && rhs.IsString())
|
||||
return static_cast<String>(lhs) >= static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
return static_cast<double>(lhs) >= static_cast<double>(rhs);
|
||||
else if (lhs.GetTypeName() != rhs.GetTypeName())
|
||||
return lhs.GetTypeName() >= rhs.GetTypeName();
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user