diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-17 22:27:04 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-25 07:36:30 +0000 |
commit | 53bbda2dfeac39f6f28e507ea9a92965076b65e6 (patch) | |
tree | 7886b3f809dfbee9d16878ccc34f1d07a7f83646 /src/qml/jsruntime/qv4object.cpp | |
parent | 6f98978ef1a79da65dba8c5cf2c1d3d434c13690 (diff) |
Add virtual interface for hasProperty
This is required to correctly support Proxy
Change-Id: I95ec17e919915290a05ad9501cd649452ab82135
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 50ffd6fae0..618970b940 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -325,38 +325,6 @@ PropertyIndex Object::getValueOrSetter(uint index, PropertyAttributes *attrs) return { nullptr, 0 }; } -bool Object::hasProperty(StringOrSymbol *name) const -{ - uint idx = name->asArrayIndex(); - if (idx != UINT_MAX) - return hasProperty(idx); - - Scope scope(engine()); - ScopedObject o(scope, d()); - while (o) { - if (o->getOwnProperty(name->toPropertyKey()) != Attr_Invalid) - return true; - - o = o->prototype(); - } - - return false; -} - -bool Object::hasProperty(uint index) const -{ - Scope scope(engine()); - ScopedObject o(scope, d()); - while (o) { - if (o->getOwnProperty(Identifier::fromArrayIndex(index)) != Attr_Invalid) - return true; - - o = o->prototype(); - } - - return false; -} - ReturnedValue Object::callAsConstructor(const FunctionObject *f, const Value *, int) { return f->engine()->throwTypeError(); @@ -1001,6 +969,21 @@ ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var) return Encode(false); } +bool Object::hasProperty(const Managed *m, Identifier id) +{ + Scope scope(m->engine()); + ScopedObject o(scope, m); + ScopedProperty p(scope); + while (o) { + if (o->getOwnProperty(id, p) != Attr_Invalid) + return true; + + o = o->prototype(); + } + + return false; +} + PropertyAttributes Object::getOwnProperty(Managed *m, Identifier id, Property *p) { PropertyAttributes attrs; |