"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/config/vmops.hpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

vmops.hpp  (icinga2-2.11.5):vmops.hpp  (icinga2-2.12.0)
skipping to change at line 29 skipping to change at line 29
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
#include <map> #include <map>
#include <vector> #include <vector>
namespace icinga namespace icinga
{ {
class VMOps class VMOps
{ {
public: public:
static inline bool FindVarImportRef(ScriptFrame& frame, const std::vector <std::shared_ptr<Expression> >& imports, const String& name, Value *result, cons t DebugInfo& debugInfo = DebugInfo()) static inline bool FindVarImportRef(ScriptFrame& frame, const std::vector <Expression::Ptr>& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
{ {
for (const auto& import : imports) { for (const auto& import : imports) {
ExpressionResult res = import->Evaluate(frame); ExpressionResult res = import->Evaluate(frame);
Object::Ptr obj = res.GetValue(); Object::Ptr obj = res.GetValue();
if (obj->HasOwnField(name)) { if (obj->HasOwnField(name)) {
*result = obj; *result = obj;
return true; return true;
} }
} }
return false; return false;
} }
static inline bool FindVarImport(ScriptFrame& frame, const std::vector<st d::shared_ptr<Expression> >& imports, const String& name, Value *result, const D ebugInfo& debugInfo = DebugInfo()) static inline bool FindVarImport(ScriptFrame& frame, const std::vector<Ex pression::Ptr>& imports, const String& name, Value *result, const DebugInfo& deb ugInfo = DebugInfo())
{ {
Value parent; Value parent;
if (FindVarImportRef(frame, imports, name, &parent, debugInfo)) { if (FindVarImportRef(frame, imports, name, &parent, debugInfo)) {
*result = GetField(parent, name, frame.Sandboxed, debugIn fo); *result = GetField(parent, name, frame.Sandboxed, debugIn fo);
return true; return true;
} }
return false; return false;
} }
skipping to change at line 94 skipping to change at line 94
static inline Value FunctionCall(ScriptFrame& frame, const Value& self, c onst Function::Ptr& func, const std::vector<Value>& arguments) static inline Value FunctionCall(ScriptFrame& frame, const Value& self, c onst Function::Ptr& func, const std::vector<Value>& arguments)
{ {
if (!self.IsEmpty() || self.IsString()) if (!self.IsEmpty() || self.IsString())
return func->InvokeThis(self, arguments); return func->InvokeThis(self, arguments);
else else
return func->Invoke(arguments); return func->Invoke(arguments);
} }
static inline Value NewFunction(ScriptFrame& frame, const String& name, c onst std::vector<String>& argNames, static inline Value NewFunction(ScriptFrame& frame, const String& name, c onst std::vector<String>& argNames,
const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression) const std::map<String, std::unique_ptr<Expression> >& closedVars, const Expression::Ptr& expression)
{ {
auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars); auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars);
auto wrapper = [argNames, evaluatedClosedVars, expression](const std::vector<Value>& arguments) -> Value { auto wrapper = [argNames, evaluatedClosedVars, expression](const std::vector<Value>& arguments) -> Value {
if (arguments.size() < argNames.size()) if (arguments.size() < argNames.size())
BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function")); BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
ScriptFrame *frame = ScriptFrame::GetCurrentFrame(); ScriptFrame *frame = ScriptFrame::GetCurrentFrame();
frame->Locals = new Dictionary(); frame->Locals = new Dictionary();
skipping to change at line 118 skipping to change at line 118
for (std::vector<Value>::size_type i = 0; i < std::min(ar guments.size(), argNames.size()); i++) for (std::vector<Value>::size_type i = 0; i < std::min(ar guments.size(), argNames.size()); i++)
frame->Locals->Set(argNames[i], arguments[i]); frame->Locals->Set(argNames[i], arguments[i]);
return expression->Evaluate(*frame); return expression->Evaluate(*frame);
}; };
return new Function(name, wrapper, argNames); return new Function(name, wrapper, argNames);
} }
static inline Value NewApply(ScriptFrame& frame, const String& type, cons static inline Value NewApply(ScriptFrame& frame, const String& type, cons
t String& target, const String& name, const std::shared_ptr<Expression>& filter, t String& target, const String& name, const Expression::Ptr& filter,
const String& package, const String& fkvar, const String& fvvar, const String& package, const String& fkvar, const String& fvvar,
const std::shared_ptr<Expression>& fterm, const std::map<String, std::unique_ptr const Expression::Ptr& fterm, const std::map<String, std::unique_ptr<Expression>
<Expression> >& closedVars, >& closedVars,
bool ignoreOnError, const std::shared_ptr<Expression>& expression bool ignoreOnError, const Expression::Ptr& expression, const Debu
, const DebugInfo& debugInfo = DebugInfo()) gInfo& debugInfo = DebugInfo())
{ {
ApplyRule::AddRule(type, target, name, expression, filter, packag e, fkvar, ApplyRule::AddRule(type, target, name, expression, filter, packag e, fkvar,
fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVar s(frame, closedVars)); fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVar s(frame, closedVars));
return Empty; return Empty;
} }
static inline Value NewObject(ScriptFrame& frame, bool abstract, const Ty static inline Value NewObject(ScriptFrame& frame, bool abstract, const Ty
pe::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter, pe::Ptr& type, const String& name, const Expression::Ptr& filter,
const String& zone, const String& package, bool defaultTmpl, bool const String& zone, const String& package, bool defaultTmpl, bool
ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars
, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = De , const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
bugInfo())
{ {
ConfigItemBuilder item{debugInfo}; ConfigItemBuilder item{debugInfo};
String checkName = name; String checkName = name;
if (!abstract) { if (!abstract) {
auto *nc = dynamic_cast<NameComposer *>(type.get()); auto *nc = dynamic_cast<NameComposer *>(type.get());
if (nc) if (nc)
checkName = nc->MakeName(name, nullptr); checkName = nc->MakeName(name, nullptr);
 End of changes. 5 change blocks. 
16 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)