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);
|
||||
}
|
||||
|
||||
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 void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
||||
virtual bool HasOwnField(const String& field) const override;
|
||||
virtual bool GetOwnField(const String& field, Value *result) const override;
|
||||
|
||||
private:
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
Type::Ptr type = GetReflectionType();
|
||||
|
|
|
@ -127,6 +127,7 @@ public:
|
|||
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 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 NotifyField(int id, const Value& cookie = Empty);
|
||||
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))
|
||||
return value;
|
||||
else if (frame.Self.IsObject() && frame.Locals != static_cast<Object::Ptr>(frame.Self) && static_cast<Object::Ptr>(frame.Self)->HasOwnField(m_Variable))
|
||||
return VMOps::GetField(frame.Self, m_Variable, frame.Sandboxed, m_DebugInfo);
|
||||
else if (frame.Self.IsObject() && frame.Locals != frame.Self.Get<Object::Ptr>() && frame.Self.Get<Object::Ptr>()->GetOwnField(m_Variable, &value))
|
||||
return value;
|
||||
else if (VMOps::FindVarImport(frame, m_Variable, &value, m_DebugInfo))
|
||||
return value;
|
||||
else
|
||||
|
@ -138,7 +138,7 @@ bool VariableExpression::GetReference(ScriptFrame& frame, bool init_dict, Value
|
|||
|
||||
if (dhint)
|
||||
*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;
|
||||
|
||||
if (dhint && *dhint)
|
||||
|
|
Loading…
Reference in New Issue