From: Gunnar Beutner Date: Wed, 15 Apr 2015 06:36:17 +0000 (+0200) Subject: Remove the ScopeCurrent constant X-Git-Tag: v2.4.0~729 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f69c0bd5a200ea40139d2c7704e8170346ff3f8f;p=icinga2 Remove the ScopeCurrent constant fixes #9044 --- diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index b262f7594..cf1a03a30 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -521,7 +521,7 @@ lterm: library FunctionExpression *fexpr = new FunctionExpression(*$4, $6, $7, @$); delete $4; - $$ = new SetExpression(MakeIndexer(ScopeCurrent, $2), OpSetLiteral, fexpr, @$); + $$ = new SetExpression(MakeIndexer(ScopeThis, $2), OpSetLiteral, fexpr, @$); free($2); } | T_CONST T_IDENTIFIER T_SET rterm @@ -780,7 +780,7 @@ rterm_no_side_effect: T_STRING | rterm_scope_require_side_effect { Expression *expr = $1; - BindToScope(expr, ScopeCurrent); + BindToScope(expr, ScopeThis); $$ = expr; } | '(' diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index 542c56aab..02f244660 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -94,7 +94,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void) Array::Ptr templateArray = new Array(); templateArray->Add(m_Name); - exprs.push_back(new SetExpression(MakeIndexer(ScopeCurrent, "templates"), OpSetAdd, + exprs.push_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd, new LiteralExpression(templateArray), m_DebugInfo)); DictExpression *dexpr = new DictExpression(m_Expressions, m_DebugInfo); diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 529ec559a..f690c3b56 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -473,8 +473,6 @@ ExpressionResult GetScopeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *d { if (m_ScopeSpec == ScopeLocal) return frame.Locals; - else if (m_ScopeSpec == ScopeCurrent) - return frame.Self; else if (m_ScopeSpec == ScopeThis) return frame.Self; else if (m_ScopeSpec == ScopeGlobal) diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 6f7dbfe53..a9bc37951 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -123,7 +123,6 @@ enum CombinedSetOp enum ScopeSpecifier { ScopeLocal, - ScopeCurrent, ScopeThis, ScopeGlobal }; diff --git a/lib/icinga/dependency-apply.cpp b/lib/icinga/dependency-apply.cpp index 14d2b84bf..9f86befc5 100644 --- a/lib/icinga/dependency-apply.cpp +++ b/lib/icinga/dependency-apply.cpp @@ -60,16 +60,16 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons Service::Ptr service; tie(host, service) = GetHostService(checkable); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "parent_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "parent_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "child_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); if (service) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); String zone = checkable->GetZoneName(); if (!zone.IsEmpty()) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di)); builder->AddExpression(new OwnedExpression(rule.GetExpression())); diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index fd8e5a3b3..707cf59d7 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -60,15 +60,15 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co Service::Ptr service; tie(host, service) = GetHostService(checkable); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); if (service) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); String zone = checkable->GetZoneName(); if (!zone.IsEmpty()) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di)); builder->AddExpression(new OwnedExpression(rule.GetExpression())); diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index af5812304..ebbb631da 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -59,15 +59,15 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl Service::Ptr service; tie(host, service) = GetHostService(checkable); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); if (service) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di)); String zone = checkable->GetZoneName(); if (!zone.IsEmpty()) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di)); builder->AddExpression(new OwnedExpression(rule.GetExpression())); diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index 6af43204b..00baa5e65 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -54,14 +54,14 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam builder->SetName(name); builder->SetScope(frame.Locals->ShallowClone()); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di)); - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "name"), OpSetLiteral, MakeLiteral(name), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "name"), OpSetLiteral, MakeLiteral(name), di)); String zone = host->GetZoneName(); if (!zone.IsEmpty()) - builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di)); + builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di)); builder->AddExpression(new OwnedExpression(rule.GetExpression()));