mirror of https://github.com/Icinga/icinga2.git
parent
4438ccbf9e
commit
aa4cad7482
|
@ -9,8 +9,8 @@ using namespace icinga;
|
|||
ApplyRule::RuleMap ApplyRule::m_Rules;
|
||||
ApplyRule::TypeMap ApplyRule::m_Types;
|
||||
|
||||
ApplyRule::ApplyRule(String targetType, String name, std::shared_ptr<Expression> expression,
|
||||
std::shared_ptr<Expression> filter, String package, String fkvar, String fvvar, std::shared_ptr<Expression> fterm,
|
||||
ApplyRule::ApplyRule(String targetType, String name, Expression::Ptr expression,
|
||||
Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope)
|
||||
: m_TargetType(std::move(targetType)), m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)),
|
||||
m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_DebugInfo(std::move(di)), m_Scope(std::move(scope)), m_HasMatches(false)
|
||||
|
@ -26,12 +26,12 @@ String ApplyRule::GetName() const
|
|||
return m_Name;
|
||||
}
|
||||
|
||||
std::shared_ptr<Expression> ApplyRule::GetExpression() const
|
||||
Expression::Ptr ApplyRule::GetExpression() const
|
||||
{
|
||||
return m_Expression;
|
||||
}
|
||||
|
||||
std::shared_ptr<Expression> ApplyRule::GetFilter() const
|
||||
Expression::Ptr ApplyRule::GetFilter() const
|
||||
{
|
||||
return m_Filter;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ String ApplyRule::GetFVVar() const
|
|||
return m_FVVar;
|
||||
}
|
||||
|
||||
std::shared_ptr<Expression> ApplyRule::GetFTerm() const
|
||||
Expression::Ptr ApplyRule::GetFTerm() const
|
||||
{
|
||||
return m_FTerm;
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ Dictionary::Ptr ApplyRule::GetScope() const
|
|||
}
|
||||
|
||||
void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
|
||||
const std::shared_ptr<Expression>& expression, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
|
||||
const String& fvvar, const std::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
|
||||
const Expression::Ptr& expression, const Expression::Ptr& filter, const String& package, const String& fkvar,
|
||||
const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
|
||||
{
|
||||
m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope));
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ public:
|
|||
|
||||
String GetTargetType() const;
|
||||
String GetName() const;
|
||||
std::shared_ptr<Expression> GetExpression() const;
|
||||
std::shared_ptr<Expression> GetFilter() const;
|
||||
Expression::Ptr GetExpression() const;
|
||||
Expression::Ptr GetFilter() const;
|
||||
String GetPackage() const;
|
||||
String GetFKVar() const;
|
||||
String GetFVVar() const;
|
||||
std::shared_ptr<Expression> GetFTerm() const;
|
||||
Expression::Ptr GetFTerm() const;
|
||||
bool GetIgnoreOnError() const;
|
||||
DebugInfo GetDebugInfo() const;
|
||||
Dictionary::Ptr GetScope() const;
|
||||
|
@ -35,8 +35,8 @@ public:
|
|||
|
||||
bool EvaluateFilter(ScriptFrame& frame) const;
|
||||
|
||||
static void AddRule(const String& sourceType, const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
|
||||
const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
|
||||
static void AddRule(const String& sourceType, const String& targetType, const String& name, const Expression::Ptr& expression,
|
||||
const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm,
|
||||
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
|
||||
static std::vector<ApplyRule>& GetRules(const String& type);
|
||||
|
||||
|
@ -50,12 +50,12 @@ public:
|
|||
private:
|
||||
String m_TargetType;
|
||||
String m_Name;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
Expression::Ptr m_Expression;
|
||||
Expression::Ptr m_Filter;
|
||||
String m_Package;
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
std::shared_ptr<Expression> m_FTerm;
|
||||
Expression::Ptr m_FTerm;
|
||||
bool m_IgnoreOnError;
|
||||
DebugInfo m_DebugInfo;
|
||||
Dictionary::Ptr m_Scope;
|
||||
|
@ -64,8 +64,8 @@ private:
|
|||
static TypeMap m_Types;
|
||||
static RuleMap m_Rules;
|
||||
|
||||
ApplyRule(String targetType, String name, std::shared_ptr<Expression> expression,
|
||||
std::shared_ptr<Expression> filter, String package, String fkvar, String fvvar, std::shared_ptr<Expression> fterm,
|
||||
ApplyRule(String targetType, String name, Expression::Ptr expression,
|
||||
Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope);
|
||||
};
|
||||
|
||||
|
|
|
@ -596,7 +596,7 @@ lterm: T_LIBRARY rterm
|
|||
}
|
||||
| T_USING rterm
|
||||
{
|
||||
std::shared_ptr<Expression> expr{$2};
|
||||
Expression::Ptr expr{$2};
|
||||
context->AddImport(expr);
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
|
|
|
@ -345,12 +345,12 @@ bool ConfigCompiler::IsAbsolutePath(const String& path)
|
|||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
void ConfigCompiler::AddImport(const std::shared_ptr<Expression>& import)
|
||||
void ConfigCompiler::AddImport(const Expression::Ptr& import)
|
||||
{
|
||||
m_Imports.push_back(import);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Expression> > ConfigCompiler::GetImports() const
|
||||
std::vector<Expression::Ptr> ConfigCompiler::GetImports() const
|
||||
{
|
||||
return m_Imports;
|
||||
}
|
||||
|
|
|
@ -92,8 +92,8 @@ public:
|
|||
void SetPackage(const String& package);
|
||||
String GetPackage() const;
|
||||
|
||||
void AddImport(const std::shared_ptr<Expression>& import);
|
||||
std::vector<std::shared_ptr<Expression> > GetImports() const;
|
||||
void AddImport(const Expression::Ptr& import);
|
||||
std::vector<Expression::Ptr> GetImports() const;
|
||||
|
||||
static void CollectIncludes(std::vector<std::unique_ptr<Expression> >& expressions,
|
||||
const String& file, const String& zone, const String& package);
|
||||
|
@ -114,13 +114,13 @@ public:
|
|||
static bool HasZoneConfigAuthority(const String& zoneName);
|
||||
|
||||
private:
|
||||
std::promise<std::shared_ptr<Expression> > m_Promise;
|
||||
std::promise<Expression::Ptr> m_Promise;
|
||||
|
||||
String m_Path;
|
||||
std::istream *m_Input;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
std::vector<std::shared_ptr<Expression> > m_Imports;
|
||||
std::vector<Expression::Ptr> m_Imports;
|
||||
|
||||
void *m_Scanner;
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ REGISTER_FUNCTION(Internal, run_with_activation_context, &ConfigItem::RunWithAct
|
|||
* @param debuginfo Debug information.
|
||||
*/
|
||||
ConfigItem::ConfigItem(Type::Ptr type, String name,
|
||||
bool abstract, std::shared_ptr<Expression> exprl,
|
||||
std::shared_ptr<Expression> filter, bool defaultTmpl, bool ignoreOnError,
|
||||
bool abstract, Expression::Ptr exprl,
|
||||
Expression::Ptr filter, bool defaultTmpl, bool ignoreOnError,
|
||||
DebugInfo debuginfo, Dictionary::Ptr scope,
|
||||
String zone, String package)
|
||||
: m_Type(std::move(type)), m_Name(std::move(name)), m_Abstract(abstract),
|
||||
|
@ -124,7 +124,7 @@ ConfigObject::Ptr ConfigItem::GetObject() const
|
|||
*
|
||||
* @returns The expression list.
|
||||
*/
|
||||
std::shared_ptr<Expression> ConfigItem::GetExpression() const
|
||||
Expression::Ptr ConfigItem::GetExpression() const
|
||||
{
|
||||
return m_Expression;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ std::shared_ptr<Expression> ConfigItem::GetExpression() const
|
|||
*
|
||||
* @returns The filter expression.
|
||||
*/
|
||||
std::shared_ptr<Expression> ConfigItem::GetFilter() const
|
||||
Expression::Ptr ConfigItem::GetFilter() const
|
||||
{
|
||||
return m_Filter;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public:
|
|||
DECLARE_PTR_TYPEDEFS(ConfigItem);
|
||||
|
||||
ConfigItem(Type::Ptr type, String name, bool abstract,
|
||||
std::shared_ptr<Expression> exprl,
|
||||
std::shared_ptr<Expression> filter,
|
||||
Expression::Ptr exprl,
|
||||
Expression::Ptr filter,
|
||||
bool defaultTmpl, bool ignoreOnError, DebugInfo debuginfo,
|
||||
Dictionary::Ptr scope, String zone,
|
||||
String package);
|
||||
|
@ -38,8 +38,8 @@ public:
|
|||
|
||||
std::vector<ConfigItem::Ptr> GetParents() const;
|
||||
|
||||
std::shared_ptr<Expression> GetExpression() const;
|
||||
std::shared_ptr<Expression> GetFilter() const;
|
||||
Expression::Ptr GetExpression() const;
|
||||
Expression::Ptr GetFilter() const;
|
||||
|
||||
void Register();
|
||||
void Unregister();
|
||||
|
@ -68,8 +68,8 @@ private:
|
|||
String m_Name; /**< The name. */
|
||||
bool m_Abstract; /**< Whether this is a template. */
|
||||
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
Expression::Ptr m_Expression;
|
||||
Expression::Ptr m_Filter;
|
||||
bool m_DefaultTmpl;
|
||||
bool m_IgnoreOnError;
|
||||
DebugInfo m_DebugInfo; /**< Debug information. */
|
||||
|
|
|
@ -48,7 +48,7 @@ void ConfigItemBuilder::AddExpression(Expression *expr)
|
|||
m_Expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
void ConfigItemBuilder::SetFilter(const std::shared_ptr<Expression>& filter)
|
||||
void ConfigItemBuilder::SetFilter(const Expression::Ptr& filter)
|
||||
{
|
||||
m_Filter = filter;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
|
|||
dexpr->MakeInline();
|
||||
exprs.emplace_back(dexpr);
|
||||
|
||||
std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(std::move(exprs), m_DebugInfo);
|
||||
auto exprl = new DictExpression(std::move(exprs), m_DebugInfo);
|
||||
exprl->MakeInline();
|
||||
|
||||
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
void SetIgnoreOnError(bool ignoreOnError);
|
||||
|
||||
void AddExpression(Expression *expr);
|
||||
void SetFilter(const std::shared_ptr<Expression>& filter);
|
||||
void SetFilter(const Expression::Ptr& filter);
|
||||
|
||||
ConfigItem::Ptr Compile();
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
String m_Name; /**< The name. */
|
||||
bool m_Abstract{false}; /**< Whether the item is abstract. */
|
||||
std::vector<std::unique_ptr<Expression> > m_Expressions; /**< Expressions for this item. */
|
||||
std::shared_ptr<Expression> m_Filter; /**< Filter expression. */
|
||||
Expression::Ptr m_Filter; /**< Filter expression. */
|
||||
DebugInfo m_DebugInfo; /**< Debug information. */
|
||||
Dictionary::Ptr m_Scope; /**< variable scope. */
|
||||
String m_Zone; /**< The zone. */
|
||||
|
|
|
@ -100,13 +100,13 @@ const DebugInfo& DebuggableExpression::GetDebugInfo() const
|
|||
return m_DebugInfo;
|
||||
}
|
||||
|
||||
VariableExpression::VariableExpression(String variable, std::vector<std::shared_ptr<Expression> > imports, const DebugInfo& debugInfo)
|
||||
VariableExpression::VariableExpression(String variable, std::vector<Expression::Ptr> imports, const DebugInfo& debugInfo)
|
||||
: DebuggableExpression(debugInfo), m_Variable(std::move(variable)), m_Imports(std::move(imports))
|
||||
{
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "System"));
|
||||
m_Imports.push_back(std::unique_ptr<Expression>(new IndexerExpression(MakeIndexer(ScopeGlobal, "System"), MakeLiteral("Configuration"))));
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "Types"));
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "Icinga"));
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "System").release());
|
||||
m_Imports.push_back(new IndexerExpression(MakeIndexer(ScopeGlobal, "System"), MakeLiteral("Configuration")));
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "Types").release());
|
||||
m_Imports.push_back(MakeIndexer(ScopeGlobal, "Icinga").release());
|
||||
}
|
||||
|
||||
ExpressionResult VariableExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "base/function.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/scriptframe.hpp"
|
||||
#include "base/shared-object.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include <map>
|
||||
|
||||
|
@ -178,9 +179,11 @@ private:
|
|||
/**
|
||||
* @ingroup config
|
||||
*/
|
||||
class Expression
|
||||
class Expression : public SharedObject
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(Expression);
|
||||
|
||||
Expression() = default;
|
||||
Expression(const Expression&) = delete;
|
||||
virtual ~Expression();
|
||||
|
@ -203,7 +206,7 @@ std::unique_ptr<Expression> MakeIndexer(ScopeSpecifier scopeSpec, const String&
|
|||
class OwnedExpression final : public Expression
|
||||
{
|
||||
public:
|
||||
OwnedExpression(std::shared_ptr<Expression> expression)
|
||||
OwnedExpression(Expression::Ptr expression)
|
||||
: m_Expression(std::move(expression))
|
||||
{ }
|
||||
|
||||
|
@ -219,7 +222,7 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
Expression::Ptr m_Expression;
|
||||
};
|
||||
|
||||
class LiteralExpression final : public Expression
|
||||
|
@ -288,7 +291,7 @@ protected:
|
|||
class VariableExpression final : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
VariableExpression(String variable, std::vector<std::shared_ptr<Expression> > imports, const DebugInfo& debugInfo = DebugInfo());
|
||||
VariableExpression(String variable, std::vector<Expression::Ptr> imports, const DebugInfo& debugInfo = DebugInfo());
|
||||
|
||||
String GetVariable() const
|
||||
{
|
||||
|
@ -301,7 +304,7 @@ protected:
|
|||
|
||||
private:
|
||||
String m_Variable;
|
||||
std::vector<std::shared_ptr<Expression> > m_Imports;
|
||||
std::vector<Expression::Ptr> m_Imports;
|
||||
|
||||
friend void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
};
|
||||
|
@ -795,7 +798,7 @@ class FunctionExpression final : public DebuggableExpression
|
|||
public:
|
||||
FunctionExpression(String name, std::vector<String> args,
|
||||
std::map<String, std::unique_ptr<Expression> >&& closedVars, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(std::move(name)), m_Args(std::move(args)), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
|
||||
: DebuggableExpression(debugInfo), m_Name(std::move(name)), m_Args(std::move(args)), m_ClosedVars(std::move(closedVars)), m_Expression(expression.release())
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -805,7 +808,7 @@ private:
|
|||
String m_Name;
|
||||
std::vector<String> m_Args;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
Expression::Ptr m_Expression;
|
||||
};
|
||||
|
||||
class ApplyExpression final : public DebuggableExpression
|
||||
|
@ -816,9 +819,9 @@ public:
|
|||
std::unique_ptr<Expression> fterm, std::map<String, std::unique_ptr<Expression> >&& closedVars, bool ignoreOnError,
|
||||
std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Type(std::move(type)), m_Target(std::move(target)),
|
||||
m_Name(std::move(name)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
|
||||
m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
|
||||
m_Expression(std::move(expression))
|
||||
m_Name(std::move(name)), m_Filter(filter.release()), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
|
||||
m_FTerm(fterm.release()), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
|
||||
m_Expression(expression.release())
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -828,28 +831,28 @@ private:
|
|||
String m_Type;
|
||||
String m_Target;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
Expression::Ptr m_Filter;
|
||||
String m_Package;
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
std::shared_ptr<Expression> m_FTerm;
|
||||
Expression::Ptr m_FTerm;
|
||||
bool m_IgnoreOnError;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
Expression::Ptr m_Expression;
|
||||
};
|
||||
|
||||
class NamespaceExpression final : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
NamespaceExpression(std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Expression(std::move(expression))
|
||||
: DebuggableExpression(debugInfo), m_Expression(expression.release())
|
||||
{ }
|
||||
|
||||
protected:
|
||||
ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
Expression::Ptr m_Expression;
|
||||
};
|
||||
|
||||
class ObjectExpression final : public DebuggableExpression
|
||||
|
@ -859,8 +862,8 @@ public:
|
|||
String zone, String package, std::map<String, std::unique_ptr<Expression> >&& closedVars,
|
||||
bool defaultTmpl, bool ignoreOnError, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(std::move(type)),
|
||||
m_Name(std::move(name)), m_Filter(std::move(filter)), m_Zone(std::move(zone)), m_Package(std::move(package)), m_DefaultTmpl(defaultTmpl),
|
||||
m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
|
||||
m_Name(std::move(name)), m_Filter(filter.release()), m_Zone(std::move(zone)), m_Package(std::move(package)), m_DefaultTmpl(defaultTmpl),
|
||||
m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(expression.release())
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -870,13 +873,13 @@ private:
|
|||
bool m_Abstract;
|
||||
std::unique_ptr<Expression> m_Type;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
Expression::Ptr m_Filter;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
bool m_DefaultTmpl;
|
||||
bool m_IgnoreOnError;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
Expression::Ptr m_Expression;
|
||||
};
|
||||
|
||||
class ForExpression final : public DebuggableExpression
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace icinga
|
|||
class VMOps
|
||||
{
|
||||
public:
|
||||
static inline bool FindVarImportRef(ScriptFrame& frame, const std::vector<std::shared_ptr<Expression> >& imports, const String& name, Value *result, const 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) {
|
||||
ExpressionResult res = import->Evaluate(frame);
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline bool FindVarImport(ScriptFrame& frame, const std::vector<std::shared_ptr<Expression> >& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
|
||||
static inline bool FindVarImport(ScriptFrame& frame, const std::vector<Expression::Ptr>& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
Value parent;
|
||||
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
}
|
||||
|
||||
static inline Value NewFunction(ScriptFrame& frame, const String& name, const 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);
|
||||
|
||||
|
@ -115,9 +115,9 @@ public:
|
|||
return new Function(name, wrapper, argNames);
|
||||
}
|
||||
|
||||
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const std::shared_ptr<Expression>& filter,
|
||||
const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
|
||||
bool ignoreOnError, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter,
|
||||
const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
|
||||
bool ignoreOnError, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
|
||||
fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars));
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
return Empty;
|
||||
}
|
||||
|
||||
static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter,
|
||||
const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const Expression::Ptr& filter,
|
||||
const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
ConfigItemBuilder item{debugInfo};
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ EventQueueRegistry *EventQueueRegistry::GetInstance()
|
|||
}
|
||||
|
||||
std::mutex EventsInbox::m_FiltersMutex;
|
||||
std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox::Filter{1, nullptr}}});
|
||||
std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox::Filter{1, Expression::Ptr()}}});
|
||||
|
||||
EventsRouter EventsRouter::m_Instance;
|
||||
|
||||
|
@ -146,7 +146,7 @@ EventsInbox::EventsInbox(String filter, const String& filterSource)
|
|||
m_Filter = m_Filters.find(filter);
|
||||
|
||||
if (m_Filter == m_Filters.end()) {
|
||||
m_Filter = m_Filters.emplace(std::move(filter), Filter{1, std::shared_ptr<Expression>(expr.release())}).first;
|
||||
m_Filter = m_Filters.emplace(std::move(filter), Filter{1, Expression::Ptr(expr.release())}).first;
|
||||
} else {
|
||||
++m_Filter->second.Refs;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ EventsInbox::~EventsInbox()
|
|||
}
|
||||
}
|
||||
|
||||
const std::shared_ptr<Expression>& EventsInbox::GetFilter()
|
||||
const Expression::Ptr& EventsInbox::GetFilter()
|
||||
{
|
||||
return m_Filter->second.Expr;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ const EventsInbox::Ptr& EventsSubscriber::GetInbox()
|
|||
return m_Inbox;
|
||||
}
|
||||
|
||||
EventsFilter::EventsFilter(std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> inboxes)
|
||||
EventsFilter::EventsFilter(std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> inboxes)
|
||||
: m_Inboxes(std::move(inboxes))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
EventsInbox& operator=(EventsInbox&&) = delete;
|
||||
~EventsInbox();
|
||||
|
||||
const std::shared_ptr<Expression>& GetFilter();
|
||||
const Expression::Ptr& GetFilter();
|
||||
|
||||
void Push(Dictionary::Ptr event);
|
||||
Dictionary::Ptr Shift(boost::asio::yield_context yc, double timeout = 5);
|
||||
|
@ -103,7 +103,7 @@ private:
|
|||
struct Filter
|
||||
{
|
||||
std::size_t Refs;
|
||||
std::shared_ptr<Expression> Expr;
|
||||
Expression::Ptr Expr;
|
||||
};
|
||||
|
||||
static std::mutex m_FiltersMutex;
|
||||
|
@ -135,14 +135,14 @@ private:
|
|||
class EventsFilter
|
||||
{
|
||||
public:
|
||||
EventsFilter(std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> inboxes);
|
||||
EventsFilter(std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> inboxes);
|
||||
|
||||
operator bool();
|
||||
|
||||
void Push(Dictionary::Ptr event);
|
||||
|
||||
private:
|
||||
std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> m_Inboxes;
|
||||
std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> m_Inboxes;
|
||||
};
|
||||
|
||||
class EventsRouter
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
~EventsRouter() = default;
|
||||
|
||||
std::mutex m_Mutex;
|
||||
std::map<EventType, std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>>> m_Subscribers;
|
||||
std::map<EventType, std::map<Expression::Ptr, std::set<EventsInbox::Ptr>>> m_Subscribers;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue