From cfd775c9489806aeac4c8c4b7a6ec603713b258b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 12 Dec 2014 15:33:02 +0100 Subject: [PATCH] Move the VMFrame class to libbase refs #8065 --- lib/base/CMakeLists.txt | 2 +- lib/base/array-script.cpp | 16 ++-- lib/base/boolean-script.cpp | 4 +- lib/base/dictionary-script.cpp | 12 +-- lib/base/number-script.cpp | 4 +- lib/base/object-script.cpp | 4 +- .../vmframe.cpp => base/scriptframe.cpp} | 4 +- .../vmframe.hpp => base/scriptframe.hpp} | 22 ++--- lib/base/string-script.cpp | 6 +- lib/cli/daemoncommand.cpp | 2 +- lib/cli/replcommand.cpp | 2 +- lib/cli/repositoryutility.cpp | 2 +- lib/config/CMakeLists.txt | 1 - lib/config/applyrule.cpp | 2 +- lib/config/applyrule.hpp | 2 +- lib/config/config_parser.yy | 2 +- lib/config/configitem.cpp | 2 +- lib/config/expression.cpp | 80 +++++++++--------- lib/config/expression.hpp | 84 +++++++++---------- lib/config/vmops.hpp | 28 +++---- lib/icinga/dependency-apply.cpp | 4 +- lib/icinga/dependency.hpp | 4 +- lib/icinga/hostgroup.cpp | 2 +- lib/icinga/notification-apply.cpp | 4 +- lib/icinga/notification.hpp | 4 +- lib/icinga/scheduleddowntime-apply.cpp | 4 +- lib/icinga/scheduleddowntime.hpp | 4 +- lib/icinga/service-apply.cpp | 4 +- lib/icinga/service.hpp | 2 +- lib/icinga/servicegroup.cpp | 2 +- lib/icinga/usergroup.cpp | 2 +- 31 files changed, 158 insertions(+), 159 deletions(-) rename lib/{config/vmframe.cpp => base/scriptframe.cpp} (93%) rename lib/{config/vmframe.hpp => base/scriptframe.hpp} (82%) diff --git a/lib/base/CMakeLists.txt b/lib/base/CMakeLists.txt index 2004572af..75e1783a3 100644 --- a/lib/base/CMakeLists.txt +++ b/lib/base/CMakeLists.txt @@ -27,7 +27,7 @@ set(base_SOURCES convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp logger.cpp logger.thpp netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp object-script.cpp primitivetype.cpp process.cpp - ringbuffer.cpp scripterror.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp + ringbuffer.cpp scripterror.cpp scriptframe.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp scriptutils.cpp scriptvariable.cpp serializer.cpp socket.cpp stacktrace.cpp statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp diff --git a/lib/base/array-script.cpp b/lib/base/array-script.cpp index 6488f0f53..006adf0b4 100644 --- a/lib/base/array-script.cpp +++ b/lib/base/array-script.cpp @@ -20,55 +20,55 @@ #include "base/array.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static double ArrayLen(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); return self->GetLength(); } static void ArraySet(int index, const Value& value) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); self->Set(index, value); } static void ArrayAdd(const Value& value) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); self->Add(value); } static void ArrayRemove(int index) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); self->Remove(index); } static bool ArrayContains(const Value& value) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); return self->Contains(value); } static void ArrayClear(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); self->Clear(); } static void ArrayClone(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); self->ShallowClone(); } diff --git a/lib/base/boolean-script.cpp b/lib/base/boolean-script.cpp index faa5e840b..29f637463 100644 --- a/lib/base/boolean-script.cpp +++ b/lib/base/boolean-script.cpp @@ -21,13 +21,13 @@ #include "base/convert.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static String BooleanToString(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); bool self = vframe->Self; return self ? "true" : "false"; } diff --git a/lib/base/dictionary-script.cpp b/lib/base/dictionary-script.cpp index 6815ad255..61d43e5e9 100644 --- a/lib/base/dictionary-script.cpp +++ b/lib/base/dictionary-script.cpp @@ -20,41 +20,41 @@ #include "base/dictionary.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static double DictionaryLen(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Dictionary::Ptr self = static_cast(vframe->Self); return self->GetLength(); } static void DictionarySet(const String& key, const Value& value) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Dictionary::Ptr self = static_cast(vframe->Self); self->Set(key, value); } static void DictionaryRemove(const String& key) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Dictionary::Ptr self = static_cast(vframe->Self); self->Remove(key); } static bool DictionaryContains(const String& key) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Dictionary::Ptr self = static_cast(vframe->Self); return self->Contains(key); } static void DictionaryClone(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Dictionary::Ptr self = static_cast(vframe->Self); self->ShallowClone(); } diff --git a/lib/base/number-script.cpp b/lib/base/number-script.cpp index ad8d9722b..76dd582dc 100644 --- a/lib/base/number-script.cpp +++ b/lib/base/number-script.cpp @@ -21,13 +21,13 @@ #include "base/convert.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static String NumberToString(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); double self = vframe->Self; return Convert::ToString(self); } diff --git a/lib/base/object-script.cpp b/lib/base/object-script.cpp index af78afb87..c1d202d03 100644 --- a/lib/base/object-script.cpp +++ b/lib/base/object-script.cpp @@ -21,13 +21,13 @@ #include "base/dictionary.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static String ObjectToString(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Object::Ptr self = static_cast(vframe->Self); return self->ToString(); } diff --git a/lib/config/vmframe.cpp b/lib/base/scriptframe.cpp similarity index 93% rename from lib/config/vmframe.cpp rename to lib/base/scriptframe.cpp index 42b7fa120..58323e5dc 100644 --- a/lib/config/vmframe.cpp +++ b/lib/base/scriptframe.cpp @@ -17,8 +17,8 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; -boost::thread_specific_ptr VMFrame::m_CurrentFrame; +boost::thread_specific_ptr ScriptFrame::m_CurrentFrame; diff --git a/lib/config/vmframe.hpp b/lib/base/scriptframe.hpp similarity index 82% rename from lib/config/vmframe.hpp rename to lib/base/scriptframe.hpp index 4efa1a204..e128934d1 100644 --- a/lib/config/vmframe.hpp +++ b/lib/base/scriptframe.hpp @@ -27,35 +27,35 @@ namespace icinga { -struct VMFrame +struct I2_BASE_API ScriptFrame { Dictionary::Ptr Locals; Value Self; - VMFrame *NextFrame; + ScriptFrame *NextFrame; - VMFrame(void) + ScriptFrame(void) : Locals(new Dictionary()), Self(Locals) { NextFrame = GetCurrentFrame(); SetCurrentFrame(this); } - VMFrame(const Value& self) + ScriptFrame(const Value& self) : Locals(new Dictionary()), Self(self) { NextFrame = GetCurrentFrame(); SetCurrentFrame(this); } - ~VMFrame(void) + ~ScriptFrame(void) { ASSERT(GetCurrentFrame() == this); SetCurrentFrame(NextFrame); } - static inline VMFrame *GetCurrentFrame(void) + static inline ScriptFrame *GetCurrentFrame(void) { - VMFrame **pframe = m_CurrentFrame.get(); + ScriptFrame **pframe = m_CurrentFrame.get(); if (pframe) return *pframe; @@ -64,14 +64,14 @@ struct VMFrame } private: - static boost::thread_specific_ptr m_CurrentFrame; + static boost::thread_specific_ptr m_CurrentFrame; - static inline void SetCurrentFrame(VMFrame *frame) + static inline void SetCurrentFrame(ScriptFrame *frame) { - m_CurrentFrame.reset(new VMFrame *(frame)); + m_CurrentFrame.reset(new ScriptFrame *(frame)); } }; } -#endif /* VMOPS_H */ +#endif /* SCRIPTFRAME_H */ diff --git a/lib/base/string-script.cpp b/lib/base/string-script.cpp index a7244e188..2dfd7ba55 100644 --- a/lib/base/string-script.cpp +++ b/lib/base/string-script.cpp @@ -21,20 +21,20 @@ #include "base/dictionary.hpp" #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" -#include "config/vmframe.hpp" +#include "base/scriptframe.hpp" using namespace icinga; static int StringLen(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); String self = vframe->Self; return self.GetLength(); } static String StringToString(void) { - VMFrame *vframe = VMFrame::GetCurrentFrame(); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); return vframe->Self; } diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index 5f3a42452..ad7252b3d 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -65,7 +65,7 @@ static String LoadAppType(const String& typeSpec) static void ExecuteExpression(Expression *expression) { try { - VMFrame frame; + ScriptFrame frame; expression->Evaluate(frame); } catch (const ScriptError& ex) { ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo()); diff --git a/lib/cli/replcommand.cpp b/lib/cli/replcommand.cpp index aae29e2bc..ba7fc0f1e 100644 --- a/lib/cli/replcommand.cpp +++ b/lib/cli/replcommand.cpp @@ -56,7 +56,7 @@ void ReplCommand::InitParameters(boost::program_options::options_description& vi */ int ReplCommand::Run(const po::variables_map& vm, const std::vector& ap) const { - VMFrame frame; + ScriptFrame frame; while (std::cin.good()) { std::cout << ConsoleColorTag(Console_ForegroundRed) diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index 7c57984d9..b3efec940 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -235,7 +235,7 @@ bool RepositoryUtility::AddObject(const String& name, const String& type, const BOOST_FOREACH(boost::tie(fname, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) { Expression *expression = ConfigCompiler::CompileText(fname, fragment); if (expression) { - VMFrame frame; + ScriptFrame frame; expression->Evaluate(frame); delete expression; } diff --git a/lib/config/CMakeLists.txt b/lib/config/CMakeLists.txt index f6dffe6ad..596c70ccc 100644 --- a/lib/config/CMakeLists.txt +++ b/lib/config/CMakeLists.txt @@ -35,7 +35,6 @@ set(config_SOURCES configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS} configtype.cpp expression.cpp objectrule.cpp typerule.cpp typerulelist.cpp - vmframe.cpp ) if(ICINGA2_UNITY_BUILD) diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index a9274463f..17730076e 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -86,7 +86,7 @@ void ApplyRule::AddRule(const String& sourceType, const String& targetType, cons m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, fkvar, fvvar, fterm, di, scope)); } -bool ApplyRule::EvaluateFilter(VMFrame& frame) const +bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const { return m_Filter->Evaluate(frame).ToBool(); } diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index af4b5c61b..b4f659126 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -49,7 +49,7 @@ public: void AddMatch(void); bool HasMatches(void) const; - bool EvaluateFilter(VMFrame& frame) const; + bool EvaluateFilter(ScriptFrame& frame) const; static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr& expression, const boost::shared_ptr& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr& fterm, const DebugInfo& di, const Dictionary::Ptr& scope); diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index f45ad237a..54ffb43cc 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -316,7 +316,7 @@ library: T_LIBRARY T_STRING constant: T_CONST identifier T_SET rterm { - VMFrame frame; + ScriptFrame frame; ScriptVariable::Ptr sv = ScriptVariable::Set($2, $4->Evaluate(frame)); free($2); delete $4; diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 4d07a216e..43d1c124d 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -164,7 +164,7 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard) DebugHint debugHints; try { - VMFrame frame(dobj); + ScriptFrame frame(dobj); frame.Locals = m_Scope; m_Expression->Evaluate(frame, &debugHints); } catch (const ScriptError& ex) { diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 709866aa9..66f76187a 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -34,7 +34,7 @@ using namespace icinga; Expression::~Expression(void) { } -Value Expression::Evaluate(VMFrame& frame, DebugHint *dhint) const +Value Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) const { try { #ifdef _DEBUG @@ -77,7 +77,7 @@ LiteralExpression::LiteralExpression(const Value& value) : m_Value(value) { } -Value LiteralExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LiteralExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Value; } @@ -87,102 +87,102 @@ const DebugInfo& DebuggableExpression::GetDebugInfo(void) const return m_DebugInfo; } -Value VariableExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value VariableExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return VMOps::Variable(frame, m_Variable, GetDebugInfo()); } -Value NegateExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value NegateExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return ~(long)m_Operand->Evaluate(frame); } -Value LogicalNegateExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LogicalNegateExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return !m_Operand->Evaluate(frame).ToBool(); } -Value AddExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value AddExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) + m_Operand2->Evaluate(frame); } -Value SubtractExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value SubtractExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) - m_Operand2->Evaluate(frame); } -Value MultiplyExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value MultiplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) * m_Operand2->Evaluate(frame); } -Value DivideExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value DivideExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) / m_Operand2->Evaluate(frame); } -Value ModuloExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ModuloExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return (long)m_Operand1->Evaluate(frame) % (long)m_Operand2->Evaluate(frame); } -Value XorExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value XorExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return (long)m_Operand1->Evaluate(frame) ^ (long)m_Operand2->Evaluate(frame); } -Value BinaryAndExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value BinaryAndExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) & m_Operand2->Evaluate(frame); } -Value BinaryOrExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value BinaryOrExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) | m_Operand2->Evaluate(frame); } -Value ShiftLeftExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ShiftLeftExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) << m_Operand2->Evaluate(frame); } -Value ShiftRightExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ShiftRightExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) >> m_Operand2->Evaluate(frame); } -Value EqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value EqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) == m_Operand2->Evaluate(frame); } -Value NotEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value NotEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) != m_Operand2->Evaluate(frame); } -Value LessThanExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LessThanExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) < m_Operand2->Evaluate(frame); } -Value GreaterThanExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value GreaterThanExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) > m_Operand2->Evaluate(frame); } -Value LessThanOrEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LessThanOrEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) <= m_Operand2->Evaluate(frame); } -Value GreaterThanOrEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value GreaterThanOrEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame) >= m_Operand2->Evaluate(frame); } -Value InExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value InExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { Value right = m_Operand2->Evaluate(frame); @@ -197,7 +197,7 @@ Value InExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return arr->Contains(left); } -Value NotInExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value NotInExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { Value right = m_Operand2->Evaluate(frame); @@ -212,17 +212,17 @@ Value NotInExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return !arr->Contains(left); } -Value LogicalAndExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LogicalAndExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame).ToBool() && m_Operand2->Evaluate(frame).ToBool(); } -Value LogicalOrExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value LogicalOrExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Operand1->Evaluate(frame).ToBool() || m_Operand2->Evaluate(frame).ToBool(); } -Value FunctionCallExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { Value self, funcName; @@ -257,7 +257,7 @@ Value FunctionCallExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return VMOps::FunctionCall(frame, self, funcName, arguments); } -Value ArrayExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { Array::Ptr result = new Array(); @@ -268,10 +268,10 @@ Value ArrayExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return result; } -Value DictExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { - VMFrame *dframe; - VMFrame rframe; + ScriptFrame *dframe; + ScriptFrame rframe; if (!m_Inline) { dframe = &rframe; @@ -293,7 +293,7 @@ Value DictExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return dframe->Self; } -Value SetExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value SetExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { DebugHint *psdhint = dhint; DebugHint sdhint; @@ -396,7 +396,7 @@ Value SetExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return right; } -Value ConditionalExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ConditionalExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { if (m_Condition->Evaluate(frame, dhint).ToBool()) return m_TrueBranch->Evaluate(frame, dhint); @@ -406,17 +406,17 @@ Value ConditionalExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return Empty; } -Value ReturnExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ReturnExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { BOOST_THROW_EXCEPTION(InterruptExecutionError(m_Operand->Evaluate(frame))); } -Value IndexerExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value IndexerExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return VMOps::Indexer(frame, m_Indexer, GetDebugInfo()); } -Value ImportExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ImportExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { String type = VMOps::GetField(frame.Self, "type", GetDebugInfo()); Value name = m_Name->Evaluate(frame); @@ -431,23 +431,23 @@ Value ImportExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const return Empty; } -Value FunctionExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value FunctionExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return VMOps::NewFunction(frame, m_Name, m_Args, m_ClosedVars, m_Expression); } -Value SlotExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value SlotExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return VMOps::NewSlot(frame, m_Signal, m_Slot->Evaluate(frame)); } -Value ApplyExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return VMOps::NewApply(frame, m_Type, m_Target, m_Name->Evaluate(frame), m_Filter, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo); } -Value ObjectExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { String name; @@ -458,7 +458,7 @@ Value ObjectExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const m_ClosedVars, m_Expression, m_DebugInfo); } -Value ForExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const +Value ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { Value value = m_Value->Evaluate(frame, dhint); diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 830321507..444e974f1 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -21,12 +21,12 @@ #define EXPRESSION_H #include "config/i2-config.hpp" -#include "config/vmframe.hpp" #include "base/debuginfo.hpp" #include "base/array.hpp" #include "base/dictionary.hpp" #include "base/scriptfunction.hpp" #include "base/scripterror.hpp" +#include "base/scriptframe.hpp" #include "base/convert.hpp" #include #include @@ -135,9 +135,9 @@ class I2_CONFIG_API Expression public: virtual ~Expression(void); - Value Evaluate(VMFrame& frame, DebugHint *dhint = NULL) const; + Value Evaluate(ScriptFrame& frame, DebugHint *dhint = NULL) const; - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const = 0; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const = 0; virtual const DebugInfo& GetDebugInfo(void) const; }; @@ -151,7 +151,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Expression->DoEvaluate(frame, dhint); } @@ -173,7 +173,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const { return m_Future.get()->DoEvaluate(frame, dhint); } @@ -193,7 +193,7 @@ public: LiteralExpression(const Value& value = Value()); protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: Value m_Value; @@ -265,7 +265,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: String m_Variable; @@ -279,7 +279,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API LogicalNegateExpression : public UnaryExpression @@ -290,7 +290,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API AddExpression : public BinaryExpression @@ -301,7 +301,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API SubtractExpression : public BinaryExpression @@ -312,7 +312,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API MultiplyExpression : public BinaryExpression @@ -323,7 +323,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API DivideExpression : public BinaryExpression @@ -334,7 +334,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API ModuloExpression : public BinaryExpression @@ -345,7 +345,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API XorExpression : public BinaryExpression @@ -356,7 +356,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API BinaryAndExpression : public BinaryExpression @@ -367,7 +367,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API BinaryOrExpression : public BinaryExpression @@ -378,7 +378,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API ShiftLeftExpression : public BinaryExpression @@ -389,7 +389,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API ShiftRightExpression : public BinaryExpression @@ -400,7 +400,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API EqualExpression : public BinaryExpression @@ -411,7 +411,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API NotEqualExpression : public BinaryExpression @@ -422,7 +422,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API LessThanExpression : public BinaryExpression @@ -433,7 +433,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API GreaterThanExpression : public BinaryExpression @@ -444,7 +444,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API LessThanOrEqualExpression : public BinaryExpression @@ -455,7 +455,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API GreaterThanOrEqualExpression : public BinaryExpression @@ -466,7 +466,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API InExpression : public BinaryExpression @@ -477,7 +477,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API NotInExpression : public BinaryExpression @@ -488,7 +488,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API LogicalAndExpression : public BinaryExpression @@ -499,7 +499,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API LogicalOrExpression : public BinaryExpression @@ -510,7 +510,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API FunctionCallExpression : public DebuggableExpression @@ -532,7 +532,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; public: std::vector m_IName; @@ -554,7 +554,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: std::vector m_Expressions; @@ -576,7 +576,7 @@ public: void MakeInline(void); protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: std::vector m_Expressions; @@ -599,7 +599,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: CombinedSetOp m_Op; @@ -624,7 +624,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: Expression *m_Condition; @@ -640,7 +640,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; }; class I2_CONFIG_API IndexerExpression : public DebuggableExpression @@ -657,7 +657,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: std::vector m_Indexer; @@ -676,7 +676,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: Expression *m_Name; @@ -691,7 +691,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: String m_Name; @@ -708,7 +708,7 @@ public: { } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: String m_Signal; @@ -733,7 +733,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: String m_Type; @@ -763,7 +763,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: bool m_Abstract; @@ -789,7 +789,7 @@ public: } protected: - virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const; + virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const; private: String m_FKVar; diff --git a/lib/config/vmops.hpp b/lib/config/vmops.hpp index 6a69304fe..b81cab5ac 100644 --- a/lib/config/vmops.hpp +++ b/lib/config/vmops.hpp @@ -45,7 +45,7 @@ namespace icinga class VMOps { public: - static inline Value Variable(VMFrame& frame, const String& name, const DebugInfo& debugInfo = DebugInfo()) + static inline Value Variable(ScriptFrame& frame, const String& name, const DebugInfo& debugInfo = DebugInfo()) { if (name == "this") return frame.Self; @@ -58,7 +58,7 @@ public: return ScriptVariable::Get(name); } - static inline Value FunctionCall(VMFrame& frame, const Value& self, const Value& funcName, const std::vector& arguments) + static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Value& funcName, const std::vector& arguments) { ScriptFunction::Ptr func; @@ -70,17 +70,17 @@ public: if (!func) BOOST_THROW_EXCEPTION(ScriptError("Function '" + funcName + "' does not exist.")); - boost::shared_ptr vframe; + boost::shared_ptr vframe; if (!self.IsEmpty()) - vframe = boost::make_shared(self); /* passes self to the callee using a TLS variable */ + vframe = boost::make_shared(self); /* passes self to the callee using a TLS variable */ else - vframe = boost::make_shared(); + vframe = boost::make_shared(); return func->Invoke(arguments); } - static inline Value Indexer(VMFrame& frame, const std::vector& indexer, const DebugInfo& debugInfo = DebugInfo()) + static inline Value Indexer(ScriptFrame& frame, const std::vector& indexer, const DebugInfo& debugInfo = DebugInfo()) { Value result = indexer[0]->Evaluate(frame); @@ -95,7 +95,7 @@ public: return result; } - static inline Value NewFunction(VMFrame& frame, const String& name, const std::vector& args, + static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector& args, std::map *closedVars, const boost::shared_ptr& expression) { ScriptFunction::Ptr func = new ScriptFunction(boost::bind(&FunctionWrapper, _1, args, @@ -107,7 +107,7 @@ public: return func; } - static inline Value NewSlot(VMFrame& frame, const String& signal, const Value& slot) + static inline Value NewSlot(ScriptFrame& frame, const String& signal, const Value& slot) { ScriptSignal::Ptr sig = ScriptSignal::GetByName(signal); @@ -119,7 +119,7 @@ public: return Empty; } - static inline Value NewApply(VMFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr& filter, + static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr& fterm, std::map *closedVars, const boost::shared_ptr& expression, const DebugInfo& debugInfo = DebugInfo()) { @@ -129,7 +129,7 @@ public: return Empty; } - static inline Value NewObject(VMFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr& filter, + static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr& filter, const String& zone, std::map *closedVars, const boost::shared_ptr& expression, const DebugInfo& debugInfo = DebugInfo()) { ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo); @@ -175,7 +175,7 @@ public: return Empty; } - static inline Value For(VMFrame& frame, const String& fkvar, const String& fvvar, const Value& value, Expression *expression, const DebugInfo& debugInfo = DebugInfo()) + static inline Value For(ScriptFrame& frame, const String& fkvar, const String& fvvar, const Value& value, Expression *expression, const DebugInfo& debugInfo = DebugInfo()) { if (value.IsObjectType()) { if (!fvvar.IsEmpty()) @@ -336,8 +336,8 @@ private: if (arguments.size() < funcargs.size()) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function")); - VMFrame *vframe = VMFrame::GetCurrentFrame(); - VMFrame frame(vframe->Self); + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); + ScriptFrame frame(vframe->Self); if (closedVars) closedVars->CopyTo(frame.Locals); @@ -370,7 +370,7 @@ private: func->Invoke(arguments); } - static inline Dictionary::Ptr EvaluateClosedVars(VMFrame& frame, std::map *closedVars) + static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, std::map *closedVars) { Dictionary::Ptr locals; diff --git a/lib/icinga/dependency-apply.cpp b/lib/icinga/dependency-apply.cpp index 10227d9cf..3f7c8c824 100644 --- a/lib/icinga/dependency-apply.cpp +++ b/lib/icinga/dependency-apply.cpp @@ -42,7 +42,7 @@ void Dependency::RegisterApplyRuleHandler(void) ApplyRule::RegisterType("Dependency", targets); } -void Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule) +void Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule) { DebugInfo di = rule.GetDebugInfo(); @@ -87,7 +87,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR Service::Ptr service; tie(host, service) = GetHostService(checkable); - VMFrame frame; + ScriptFrame frame; if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/dependency.hpp b/lib/icinga/dependency.hpp index 27d0c5d8d..8c793f862 100644 --- a/lib/icinga/dependency.hpp +++ b/lib/icinga/dependency.hpp @@ -28,7 +28,7 @@ namespace icinga { class ApplyRule; -struct VMFrame; +struct ScriptFrame; class Host; class Service; @@ -66,7 +66,7 @@ private: Checkable::Ptr m_Parent; Checkable::Ptr m_Child; - static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule); + static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule); static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule); }; diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index 775ab8545..935be8bdc 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -44,7 +44,7 @@ bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr& CONTEXT("Evaluating rule for group '" + group_name + "'"); - VMFrame frame; + ScriptFrame frame; if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index c8ef7d788..ed829f1e5 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -42,7 +42,7 @@ void Notification::RegisterApplyRuleHandler(void) ApplyRule::RegisterType("Notification", targets); } -void Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule) +void Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule) { DebugInfo di = rule.GetDebugInfo(); @@ -86,7 +86,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl Service::Ptr service; tie(host, service) = GetHostService(checkable); - VMFrame frame; + ScriptFrame frame; if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/notification.hpp b/lib/icinga/notification.hpp index 3c1457e1f..d47314a9a 100644 --- a/lib/icinga/notification.hpp +++ b/lib/icinga/notification.hpp @@ -68,7 +68,7 @@ enum NotificationType class NotificationCommand; class Checkable; class ApplyRule; -struct VMFrame; +struct ScriptFrame; class Host; class Service; @@ -123,7 +123,7 @@ protected: private: void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = ""); - static void EvaluateApplyRuleInstance(const intrusive_ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule); + static void EvaluateApplyRuleInstance(const intrusive_ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule); static bool EvaluateApplyRule(const intrusive_ptr& checkable, const ApplyRule& rule); }; diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index f2c7ca304..16e4bd29f 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -41,7 +41,7 @@ void ScheduledDowntime::RegisterApplyRuleHandler(void) ApplyRule::RegisterType("ScheduledDowntime", targets); } -void ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule) +void ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule) { DebugInfo di = rule.GetDebugInfo(); @@ -85,7 +85,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const Service::Ptr service; tie(host, service) = GetHostService(checkable); - VMFrame frame; + ScriptFrame frame; if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp index 5a709686c..bc82d059c 100644 --- a/lib/icinga/scheduleddowntime.hpp +++ b/lib/icinga/scheduleddowntime.hpp @@ -29,7 +29,7 @@ namespace icinga { class ApplyRule; -struct VMFrame; +struct ScriptFrame; class Host; class Service; @@ -62,7 +62,7 @@ private: std::pair FindNextSegment(void); void CreateNextDowntime(void); - static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule); + static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule); static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule); }; diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index 74c9d5143..9ce9000dc 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -40,7 +40,7 @@ void Service::RegisterApplyRuleHandler(void) ApplyRule::RegisterType("Service", targets); } -void Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, VMFrame& frame, const ApplyRule& rule) +void Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, ScriptFrame& frame, const ApplyRule& rule) { DebugInfo di = rule.GetDebugInfo(); @@ -75,7 +75,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule) msgbuf << "Evaluating 'apply' rule (" << di << ")"; CONTEXT(msgbuf.str()); - VMFrame frame; + ScriptFrame frame; if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/service.hpp b/lib/icinga/service.hpp index 2c0ee86a6..53e82edf9 100644 --- a/lib/icinga/service.hpp +++ b/lib/icinga/service.hpp @@ -61,7 +61,7 @@ protected: private: Host::Ptr m_Host; - static void EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, VMFrame& frame, const ApplyRule& rule); + static void EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, ScriptFrame& frame, const ApplyRule& rule); static bool EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule); }; diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index 692c945bb..e205c7dd5 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -46,7 +46,7 @@ bool ServiceGroup::EvaluateObjectRule(const Service::Ptr& service, const ConfigI Host::Ptr host = service->GetHost(); - VMFrame frame; + ScriptFrame frame; if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/usergroup.cpp b/lib/icinga/usergroup.cpp index 38b4b1c94..29981f6dd 100644 --- a/lib/icinga/usergroup.cpp +++ b/lib/icinga/usergroup.cpp @@ -44,7 +44,7 @@ bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr& CONTEXT("Evaluating rule for group '" + group_name + "'"); - VMFrame frame; + ScriptFrame frame; if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("user", user);