aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4reflect.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-22 22:59:43 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-02 19:29:29 +0000
commitdb695c5b1d07275f208446dad178b1131b20bb0a (patch)
treec2175a065f4918d31249ca1ce46a2811733b8093 /src/qml/jsruntime/qv4reflect.cpp
parent98263a01373f5b225d64da216537165ae27d7ff1 (diff)
Unify the get and getIndexed vtable functions of QV4::Object
This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4reflect.cpp')
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 48920fd63c..7d8c8db089 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -78,7 +78,7 @@ static CallArgs createListFromArrayLike(Scope &scope, const Object *o)
Value *arguments = scope.alloc(len);
for (int i = 0; i < len; ++i) {
- arguments[i] = o->getIndexed(i);
+ arguments[i] = o->get(i);
if (scope.hasException())
return { nullptr, 0 };
}
@@ -148,7 +148,6 @@ ReturnedValue Reflect::method_deleteProperty(const FunctionObject *f, const Valu
ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- // ### Fix third receiver argument
Scope scope(f);
if (!argc || !argv[0].isObject())
return scope.engine->throwTypeError();
@@ -156,15 +155,12 @@ ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const
ScopedObject o(scope, static_cast<const Object *>(argv));
Value undef = Primitive::undefinedValue();
const Value *index = argc > 1 ? &argv[1] : &undef;
-
- uint n = index->asArrayIndex();
- if (n < UINT_MAX)
- return Encode(o->getIndexed(n));
-
ScopedStringOrSymbol name(scope, index->toPropertyKey(scope.engine));
- if (scope.engine->hasException)
- return false;
- return Encode(o->get(name));
+ if (scope.hasException())
+ return Encode::undefined();
+ ScopedValue receiver(scope, argc > 2 ? argv[2] : *o);
+
+ return Encode(o->get(name->toPropertyKey(), receiver));
}
ReturnedValue Reflect::method_getOwnPropertyDescriptor(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
@@ -198,7 +194,7 @@ ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const
bool hasProperty = false;
uint n = index->asArrayIndex();
if (n < UINT_MAX) {
- (void) o->getIndexed(n, &hasProperty);
+ (void) o->get(n, &hasProperty);
return Encode(hasProperty);
}
@@ -239,7 +235,6 @@ ReturnedValue Reflect::method_preventExtensions(const FunctionObject *f, const V
ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- // ### Fix third receiver argument
Scope scope(f);
if (!argc || !argv[0].isObject())
return scope.engine->throwTypeError();