mirror of https://github.com/Icinga/icinga2.git
parent
5304b08c2d
commit
7879c09789
|
@ -228,3 +228,8 @@ bool Dictionary::HasOwnField(const String& field) const
|
||||||
{
|
{
|
||||||
return Contains(field);
|
return Contains(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Dictionary::GetOwnField(const String& field, Value *result) const
|
||||||
|
{
|
||||||
|
return Get(field, result);
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
||||||
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
||||||
virtual bool HasOwnField(const String& field) const override;
|
virtual bool HasOwnField(const String& field) const override;
|
||||||
|
virtual bool GetOwnField(const String& field, Value *result) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<String, Value> m_Data; /**< The data for the dictionary. */
|
std::map<String, Value> m_Data; /**< The data for the dictionary. */
|
||||||
|
|
|
@ -109,6 +109,22 @@ bool Object::HasOwnField(const String& field) const
|
||||||
return type->GetFieldId(field) != -1;
|
return type->GetFieldId(field) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Object::GetOwnField(const String& field, Value *result) const
|
||||||
|
{
|
||||||
|
Type::Ptr type = GetReflectionType();
|
||||||
|
|
||||||
|
if (!type)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int tid = type->GetFieldId(field);
|
||||||
|
|
||||||
|
if (tid == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*result = GetField(tid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Value Object::GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const
|
Value Object::GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const
|
||||||
{
|
{
|
||||||
Type::Ptr type = GetReflectionType();
|
Type::Ptr type = GetReflectionType();
|
||||||
|
|
|
@ -127,6 +127,7 @@ public:
|
||||||
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const;
|
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const;
|
||||||
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo);
|
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo);
|
||||||
virtual bool HasOwnField(const String& field) const;
|
virtual bool HasOwnField(const String& field) const;
|
||||||
|
virtual bool GetOwnField(const String& field, Value *result) const;
|
||||||
virtual void ValidateField(int id, const Value& value, const ValidationUtils& utils);
|
virtual void ValidateField(int id, const Value& value, const ValidationUtils& utils);
|
||||||
virtual void NotifyField(int id, const Value& cookie = Empty);
|
virtual void NotifyField(int id, const Value& cookie = Empty);
|
||||||
virtual Object::Ptr NavigateField(int id) const;
|
virtual Object::Ptr NavigateField(int id) const;
|
||||||
|
|
|
@ -121,8 +121,8 @@ ExpressionResult VariableExpression::DoEvaluate(ScriptFrame& frame, DebugHint *d
|
||||||
|
|
||||||
if (frame.Locals && frame.Locals->Get(m_Variable, &value))
|
if (frame.Locals && frame.Locals->Get(m_Variable, &value))
|
||||||
return value;
|
return value;
|
||||||
else if (frame.Self.IsObject() && frame.Locals != static_cast<Object::Ptr>(frame.Self) && static_cast<Object::Ptr>(frame.Self)->HasOwnField(m_Variable))
|
else if (frame.Self.IsObject() && frame.Locals != frame.Self.Get<Object::Ptr>() && frame.Self.Get<Object::Ptr>()->GetOwnField(m_Variable, &value))
|
||||||
return VMOps::GetField(frame.Self, m_Variable, frame.Sandboxed, m_DebugInfo);
|
return value;
|
||||||
else if (VMOps::FindVarImport(frame, m_Variable, &value, m_DebugInfo))
|
else if (VMOps::FindVarImport(frame, m_Variable, &value, m_DebugInfo))
|
||||||
return value;
|
return value;
|
||||||
else
|
else
|
||||||
|
@ -138,7 +138,7 @@ bool VariableExpression::GetReference(ScriptFrame& frame, bool init_dict, Value
|
||||||
|
|
||||||
if (dhint)
|
if (dhint)
|
||||||
*dhint = NULL;
|
*dhint = NULL;
|
||||||
} else if (frame.Self.IsObject() && frame.Locals != static_cast<Object::Ptr>(frame.Self) && static_cast<Object::Ptr>(frame.Self)->HasOwnField(m_Variable)) {
|
} else if (frame.Self.IsObject() && frame.Locals != frame.Self.Get<Object::Ptr>() && frame.Self.Get<Object::Ptr>()->HasOwnField(m_Variable)) {
|
||||||
*parent = frame.Self;
|
*parent = frame.Self;
|
||||||
|
|
||||||
if (dhint && *dhint)
|
if (dhint && *dhint)
|
||||||
|
|
Loading…
Reference in New Issue