aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
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
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')
-rw-r--r--src/qml/jsapi/qjsvalue.cpp2
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp2
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp20
-rw-r--r--src/qml/jsruntime/qv4argumentsobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp2
-rw-r--r--src/qml/jsruntime/qv4arrayiterator.cpp2
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp58
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp2
-rw-r--r--src/qml/jsruntime/qv4object.cpp29
-rw-r--r--src/qml/jsruntime/qv4object_p.h23
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp2
-rw-r--r--src/qml/jsruntime/qv4proxy.cpp17
-rw-r--r--src/qml/jsruntime/qv4proxy_p.h4
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp16
-rw-r--r--src/qml/jsruntime/qv4qmlcontext_p.h2
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp14
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h2
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp19
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4regexpobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp10
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp6
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp10
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h3
-rw-r--r--src/qml/qml/qqmldelayedcallqueue.cpp2
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp47
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h3
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp20
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp13
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp73
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp6
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h2
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp51
-rw-r--r--src/qml/types/qqmllistmodel.cpp21
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h2
41 files changed, 241 insertions, 282 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 73e6243520..b68f2bd600 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -1110,7 +1110,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
if (!o)
return QJSValue();
- QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->getIndexed(arrayIndex));
+ QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->get(arrayIndex));
if (engine->hasException)
engine->catchException();
return QJSValue(engine, result->asReturnedValue());
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index 222f63ed4a..35c6ecc668 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -200,7 +200,7 @@ QJSValue QJSValueIterator::value() const
if (!d_ptr->currentName.as<QV4::String>() && d_ptr->currentIndex == UINT_MAX)
return QJSValue();
- QV4::ScopedValue v(scope, d_ptr->currentIndex == UINT_MAX ? obj->get(d_ptr->currentName.as<QV4::String>()) : obj->getIndexed(d_ptr->currentIndex));
+ QV4::ScopedValue v(scope, d_ptr->currentIndex == UINT_MAX ? obj->get(d_ptr->currentName.as<QV4::String>()) : obj->get(d_ptr->currentIndex));
if (scope.hasException()) {
engine->catchException();
return QJSValue();
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index c2a50a49ec..7a914a9c13 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -169,20 +169,18 @@ bool ArgumentsObject::defineOwnProperty(Managed *m, Identifier id, const Propert
return result;
}
-ReturnedValue ArgumentsObject::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue ArgumentsObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
const ArgumentsObject *args = static_cast<const ArgumentsObject *>(m);
- if (args->fullyCreated())
- return Object::getIndexed(m, index, hasProperty);
-
- if (index < static_cast<uint>(args->context()->argc())) {
- if (hasProperty)
- *hasProperty = true;
- return args->context()->args()[index].asReturnedValue();
+ if (id.isArrayIndex() && !args->fullyCreated()) {
+ uint index = id.asArrayIndex();
+ if (index < static_cast<uint>(args->context()->argc())) {
+ if (hasProperty)
+ *hasProperty = true;
+ return args->context()->args()[index].asReturnedValue();
+ }
}
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
+ return Object::get(m, id, receiver, hasProperty);
}
bool ArgumentsObject::put(Managed *m, Identifier id, const Value &value, Value *receiver)
diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h
index 69d136674b..07ff44028b 100644
--- a/src/qml/jsruntime/qv4argumentsobject_p.h
+++ b/src/qml/jsruntime/qv4argumentsobject_p.h
@@ -147,7 +147,7 @@ struct ArgumentsObject: Object {
}
static bool defineOwnProperty(Managed *m, Identifier id, const Property *desc, PropertyAttributes attrs);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static bool deleteProperty(Managed *m, Identifier id);
static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index ecc0b138c0..74ff1e2fc3 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -585,7 +585,7 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
if (!other || ArgumentsObject::isNonStrictArgumentsObject(otherObj)) {
ScopedValue v(scope);
for (uint i = 0; i < n; ++i)
- obj->arraySet(oldSize + i, (v = otherObj->getIndexed(i)));
+ obj->arraySet(oldSize + i, (v = otherObj->get(i)));
} else if (other && other->isSparse()) {
Heap::SparseArrayData *os = static_cast<Heap::SparseArrayData *>(other->d());
if (other->hasAttributes()) {
diff --git a/src/qml/jsruntime/qv4arrayiterator.cpp b/src/qml/jsruntime/qv4arrayiterator.cpp
index d6f787c01d..650f58463e 100644
--- a/src/qml/jsruntime/qv4arrayiterator.cpp
+++ b/src/qml/jsruntime/qv4arrayiterator.cpp
@@ -86,7 +86,7 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const
return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), false);
}
- ReturnedValue elementValue = a->getIndexed(index);
+ ReturnedValue elementValue = a->get(index);
CHECK_EXCEPTION();
if (itemKind == ValueIteratorKind) {
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 9efb315b50..0016244232 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -277,7 +277,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V
ScopedValue mappedValue(scope, Primitive::undefinedValue());
ScopedValue kValue(scope);
while (k < len) {
- kValue = arrayLike->getIndexed(k);
+ kValue = arrayLike->get(k);
CHECK_EXCEPTION();
if (mapfn) {
@@ -383,7 +383,7 @@ ReturnedValue ArrayPrototype::method_concat(const FunctionObject *b, const Value
} else if (eltAsObj && eltAsObj->isListType()) {
const uint startIndex = result->getLength();
for (int i = 0, len = eltAsObj->getLength(); i < len; ++i) {
- entry = eltAsObj->getIndexed(i);
+ entry = eltAsObj->get(i);
// spec says not to throw if this fails
result->put(startIndex + i, entry);
}
@@ -444,7 +444,7 @@ ReturnedValue ArrayPrototype::method_copyWithin(const FunctionObject *b, const V
while (count > 0) {
bool fromPresent = false;
- ScopedValue fromVal(scope, instance->getIndexed(from, &fromPresent));
+ ScopedValue fromVal(scope, instance->get(from, &fromPresent));
if (fromPresent) {
instance->setIndexed(to, fromVal, QV4::Object::DoThrowOnRejection);
@@ -496,7 +496,7 @@ ReturnedValue ArrayPrototype::method_find(const FunctionObject *b, const Value *
ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
for (uint k = 0; k < len; ++k) {
- arguments[0] = instance->getIndexed(k);
+ arguments[0] = instance->get(k);
CHECK_EXCEPTION();
arguments[1] = Primitive::fromDouble(k);
@@ -530,7 +530,7 @@ ReturnedValue ArrayPrototype::method_findIndex(const FunctionObject *b, const Va
ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
for (uint k = 0; k < len; ++k) {
- arguments[0] = instance->getIndexed(k);
+ arguments[0] = instance->get(k);
CHECK_EXCEPTION();
arguments[1] = Primitive::fromDouble(k);
@@ -576,7 +576,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
if (i)
R += r4;
- e = a->getIndexed(i);
+ e = a->get(i);
CHECK_EXCEPTION();
if (!e->isNullOrUndefined())
R += e->toQString();
@@ -621,7 +621,7 @@ ReturnedValue ArrayPrototype::method_pop(const FunctionObject *b, const Value *t
RETURN_UNDEFINED();
}
- ScopedValue result(scope, instance->getIndexed(len - 1));
+ ScopedValue result(scope, instance->get(len - 1));
CHECK_EXCEPTION();
if (!instance->deleteProperty(Identifier::fromArrayIndex(len - 1)))
@@ -708,8 +708,8 @@ ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Valu
ScopedValue hval(scope);
for (; lo < hi; ++lo, --hi) {
bool loExists, hiExists;
- lval = instance->getIndexed(lo, &loExists);
- hval = instance->getIndexed(hi, &hiExists);
+ lval = instance->get(lo, &loExists);
+ hval = instance->get(hi, &hiExists);
CHECK_EXCEPTION();
bool ok;
if (hiExists)
@@ -751,13 +751,13 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (!instance->protoHasArray() && !instance->arrayData()->attrs && instance->arrayData()->length() <= len && instance->arrayData()->type != Heap::ArrayData::Custom) {
result = instance->arrayData()->vtable()->pop_front(instance);
} else {
- result = instance->getIndexed(0);
+ result = instance->get(uint(0));
CHECK_EXCEPTION();
ScopedValue v(scope);
// do it the slow way
for (uint k = 1; k < len; ++k) {
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
@@ -815,7 +815,7 @@ ReturnedValue ArrayPrototype::method_slice(const FunctionObject *b, const Value
uint n = 0;
for (uint i = start; i < end; ++i) {
bool exists;
- v = o->getIndexed(i, &exists);
+ v = o->get(i, &exists);
CHECK_EXCEPTION();
if (exists)
result->arraySet(n, v);
@@ -874,7 +874,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
ScopedValue v(scope);
for (uint i = 0; i < deleteCount; ++i) {
bool exists;
- v = instance->getIndexed(start + i, &exists);
+ v = instance->get(start + i, &exists);
CHECK_EXCEPTION();
if (exists)
newArray->arrayPut(i, v);
@@ -885,7 +885,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
if (itemCount < deleteCount) {
for (uint k = start; k < len - deleteCount; ++k) {
bool exists;
- v = instance->getIndexed(k + deleteCount, &exists);
+ v = instance->get(k + deleteCount, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
@@ -903,7 +903,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
uint k = len - deleteCount;
while (k > start) {
bool exists;
- v = instance->getIndexed(k + deleteCount - 1, &exists);
+ v = instance->get(k + deleteCount - 1, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
@@ -944,7 +944,7 @@ ReturnedValue ArrayPrototype::method_unshift(const FunctionObject *b, const Valu
ScopedValue v(scope);
for (uint k = len; k > 0; --k) {
bool exists;
- v = instance->getIndexed(k - 1, &exists);
+ v = instance->get(k - 1, &exists);
bool ok;
if (exists)
ok = instance->put(k + argc - 1, v);
@@ -999,7 +999,7 @@ ReturnedValue ArrayPrototype::method_includes(const FunctionObject *b, const Val
}
while (k < len) {
- ScopedValue val(scope, instance->getIndexed(k));
+ ScopedValue val(scope, instance->get(k));
if (val->sameValueZero(argv[0])) {
return Encode(true);
}
@@ -1037,7 +1037,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
ScopedValue v(scope);
for (uint k = fromIndex; k < len; ++k) {
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
if (exists && RuntimeHelpers::strictEqual(v, searchValue))
return Encode(k);
}
@@ -1051,7 +1051,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
// lets be safe and slow
for (uint i = fromIndex; i < len; ++i) {
bool exists;
- value = instance->getIndexed(i, &exists);
+ value = instance->get(i, &exists);
CHECK_EXCEPTION();
if (exists && RuntimeHelpers::strictEqual(value, searchValue))
return Encode(i);
@@ -1123,7 +1123,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(const FunctionObject *b, const
for (uint k = fromIndex; k > 0;) {
--k;
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
CHECK_EXCEPTION();
if (exists && RuntimeHelpers::strictEqual(v, searchValue))
return Encode(k);
@@ -1151,7 +1151,7 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
bool ok = true;
for (uint k = 0; ok && k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
@@ -1218,7 +1218,7 @@ ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
@@ -1249,7 +1249,7 @@ ReturnedValue ArrayPrototype::method_forEach(const FunctionObject *b, const Valu
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
@@ -1287,7 +1287,7 @@ ReturnedValue ArrayPrototype::method_map(const FunctionObject *b, const Value *t
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
@@ -1322,7 +1322,7 @@ ReturnedValue ArrayPrototype::method_filter(const FunctionObject *b, const Value
uint to = 0;
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
@@ -1359,7 +1359,7 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
} else {
bool kPresent = false;
while (k < len && !kPresent) {
- v = instance->getIndexed(k, &kPresent);
+ v = instance->get(k, &kPresent);
if (kPresent)
acc = v;
++k;
@@ -1372,7 +1372,7 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
while (k < len) {
bool kPresent;
- v = instance->getIndexed(k, &kPresent);
+ v = instance->get(k, &kPresent);
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
@@ -1412,7 +1412,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
} else {
bool kPresent = false;
while (k > 0 && !kPresent) {
- v = instance->getIndexed(k - 1, &kPresent);
+ v = instance->get(k - 1, &kPresent);
if (kPresent)
acc = v;
--k;
@@ -1425,7 +1425,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
while (k > 0) {
bool kPresent;
- v = instance->getIndexed(k - 1, &kPresent);
+ v = instance->get(k - 1, &kPresent);
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index bdf1c93d0c..d5b48afc92 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1260,7 +1260,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
uint length = a->getLength();
QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope);
for (uint ii = 0; ii < length; ++ii) {
- qobjectWrapper = a->getIndexed(ii);
+ qobjectWrapper = a->get(ii);
if (!!qobjectWrapper) {
list << qobjectWrapper->object();
} else {
@@ -1347,7 +1347,7 @@ static QVariant objectToVariant(QV4::ExecutionEngine *e, const QV4::Object *o, V
int length = a->getLength();
for (int ii = 0; ii < length; ++ii) {
- v = a->getIndexed(ii);
+ v = a->get(ii);
list << ::toVariant(e, v, -1, /*createJSValueForObjects*/false, visitedObjects);
}
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 68a197e11a..772cc22a68 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -377,7 +377,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
arguments[i] = Primitive::undefinedValue();
} else {
for (quint32 i = 0; i < len; ++i)
- arguments[i] = arr->getIndexed(i);
+ arguments[i] = arr->get(i);
}
}
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index ed7d8611ee..58c17b54cc 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -847,7 +847,7 @@ QString Stringify::JA(Object *a)
ScopedValue v(scope);
for (uint i = 0; i < len; ++i) {
bool exists;
- v = a->getIndexed(i, &exists);
+ v = a->get(i, &exists);
if (!exists) {
partial += QStringLiteral("null");
continue;
@@ -919,7 +919,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
stringify.propertyList = static_cast<QV4::String *>(scope.alloc(arrayLen));
for (uint i = 0; i < arrayLen; ++i) {
Value *v = stringify.propertyList + i;
- *v = o->getIndexed(i);
+ *v = o->get(i);
if (v->as<NumberObject>() || v->as<StringObject>() || v->isNumber())
*v = v->toString(scope.engine);
if (!v->isString()) {
@@ -1081,7 +1081,7 @@ QJsonArray JsonObject::toJsonArray(const ArrayObject *a, V4ObjectSet &visitedObj
ScopedValue v(scope);
quint32 length = a->getLength();
for (quint32 i = 0; i < length; ++i) {
- v = a->getIndexed(i);
+ v = a->get(i);
if (v->as<FunctionObject>())
v = Encode::null();
result.append(toJsonValue(v, visitedObjects));
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 67b4b9dc38..594648373a 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -389,7 +389,7 @@ ReturnedValue Lookup::getterIndexed(Lookup *l, ExecutionEngine *engine, const Va
if (!s->data(l->indexedLookup.index).isEmpty())
return s->data(l->indexedLookup.index).asReturnedValue();
}
- return o->getIndexed(l->indexedLookup.index);
+ return o->get(l->indexedLookup.index);
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 7c375db1e1..948db67c29 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -317,14 +317,13 @@ ReturnedValue Object::call(const FunctionObject *f, const Value *, const Value *
return f->engine()->throwTypeError();
}
-ReturnedValue Object::get(const Managed *m, StringOrSymbol *name, bool *hasProperty)
+ReturnedValue Object::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
- return static_cast<const Object *>(m)->internalGet(name, hasProperty);
-}
-
-ReturnedValue Object::getIndexed(const Managed *m, uint index, bool *hasProperty)
-{
- return static_cast<const Object *>(m)->internalGetIndexed(index, hasProperty);
+ if (id.isArrayIndex())
+ return static_cast<const Object *>(m)->internalGetIndexed(id.asArrayIndex(), receiver, hasProperty);
+ Scope scope(m);
+ Scoped<StringOrSymbol> name(scope, id.asHeapObject());
+ return static_cast<const Object *>(m)->internalGet(name, receiver, hasProperty);
}
bool Object::put(Managed *m, Identifier id, const Value &value, Value *receiver)
@@ -409,11 +408,9 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *
}
// Section 8.12.3
-ReturnedValue Object::internalGet(StringOrSymbol *name, bool *hasProperty) const
+ReturnedValue Object::internalGet(StringOrSymbol *name, const Value *receiver, bool *hasProperty) const
{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return getIndexed(idx, hasProperty);
+ Q_ASSERT(name->asArrayIndex() == UINT_MAX);
name->makeIdentifier();
Identifier id = name->identifier();
@@ -424,7 +421,7 @@ ReturnedValue Object::internalGet(StringOrSymbol *name, bool *hasProperty) const
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
- return getValue(*o->propertyData(idx), o->internalClass->propertyData.at(idx));
+ return Object::getValue(*receiver, *o->propertyData(idx), o->internalClass->propertyData.at(idx));
}
o = o->prototype();
@@ -435,7 +432,7 @@ ReturnedValue Object::internalGet(StringOrSymbol *name, bool *hasProperty) const
return Encode::undefined();
}
-ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
+ReturnedValue Object::internalGetIndexed(uint index, const Value *receiver, bool *hasProperty) const
{
PropertyAttributes attrs;
Scope scope(engine());
@@ -462,7 +459,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
if (exists) {
if (hasProperty)
*hasProperty = true;
- return getValue(pd->value, attrs);
+ return Object::getValue(*receiver, pd->value, attrs);
}
if (hasProperty)
@@ -696,7 +693,7 @@ void Object::copyArrayData(Object *other)
ScopedValue v(scope);
for (uint i = 0; i < len; ++i) {
- arraySet(i, (v = other->getIndexed(i)));
+ arraySet(i, (v = other->get(i)));
}
} else if (!other->arrayData()) {
;
@@ -973,7 +970,7 @@ QStringList ArrayObject::toQStringList() const
uint length = getLength();
for (uint i = 0; i < length; ++i) {
- v = const_cast<ArrayObject *>(this)->getIndexed(i);
+ v = const_cast<ArrayObject *>(this)->get(i);
result.append(v->toQStringNoThrow());
}
return result;
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 88d07ef3f1..00ec790692 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -169,8 +169,7 @@ struct ObjectVTable
VTable vTable;
ReturnedValue (*call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
ReturnedValue (*callAsConstructor)(const FunctionObject *, const Value *argv, int argc);
- ReturnedValue (*get)(const Managed *, StringOrSymbol *name, bool *hasProperty);
- ReturnedValue (*getIndexed)(const Managed *, uint index, bool *hasProperty);
+ ReturnedValue (*get)(const Managed *, Identifier id, const Value *receiver, bool *hasProperty);
bool (*put)(Managed *, Identifier id, const Value &value, Value *receiver);
bool (*deleteProperty)(Managed *m, Identifier id);
bool (*hasProperty)(const Managed *m, Identifier id);
@@ -192,7 +191,6 @@ const QV4::ObjectVTable classname::static_vtbl = \
call, \
callAsConstructor, \
get, \
- getIndexed, \
put, \
deleteProperty, \
hasProperty, \
@@ -373,10 +371,14 @@ public:
return false;
}
- inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr) const
- { return vtable()->get(this, name, hasProperty); }
- inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
- { return vtable()->getIndexed(this, idx, hasProperty); }
+ inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, name->toPropertyKey(), receiver, hasProperty); }
+ inline ReturnedValue get(uint idx, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, Identifier::fromArrayIndex(idx), receiver, hasProperty); }
+ QT_DEPRECATED inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
+ { return get(idx, hasProperty); }
+ inline ReturnedValue get(Identifier id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, id, receiver, hasProperty); }
// use the set variants instead, to customize throw behavior
inline bool put(StringOrSymbol *name, const Value &v, Value *receiver = nullptr)
@@ -437,8 +439,7 @@ public:
protected:
static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver,bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static bool deleteProperty(Managed *m, Identifier id);
static bool hasProperty(const Managed *m, Identifier id);
@@ -454,8 +455,8 @@ protected:
private:
bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, StringOrSymbol *member, const Property *p, PropertyAttributes attrs);
- ReturnedValue internalGet(StringOrSymbol *name, bool *hasProperty) const;
- ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const;
+ ReturnedValue internalGet(StringOrSymbol *name, const Value *receiver, bool *hasProperty) const;
+ ReturnedValue internalGetIndexed(uint index, const Value *receiver, bool *hasProperty) const;
bool internalPut(Identifier id, const Value &value, Value *receiver);
bool internalDeleteProperty(Identifier id);
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index ef3e4268c0..290c5a7a5b 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -234,7 +234,7 @@ ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Valu
ScopedString nextKey(scope);
ScopedValue propValue(scope);
for (quint32 i = 0; i < length; ++i) {
- nextKey = Value::fromReturnedValue(keys->getIndexed(i)).toString(scope.engine);
+ nextKey = Value::fromReturnedValue(keys->get(i)).toString(scope.engine);
ScopedProperty prop(scope);
PropertyAttributes attrs = from->getOwnProperty(nextKey->toPropertyKey(), prop);
diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp
index 11914e4feb..a17b6085f9 100644
--- a/src/qml/jsruntime/qv4proxy.cpp
+++ b/src/qml/jsruntime/qv4proxy.cpp
@@ -55,7 +55,7 @@ void Heap::ProxyObject::init(const QV4::Object *target, const QV4::Object *handl
this->handler.set(e, handler->d());
}
-ReturnedValue ProxyObject::get(const Managed *m, StringOrSymbol *name, bool *hasProperty)
+ReturnedValue ProxyObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Scope scope(m);
const ProxyObject *o = static_cast<const ProxyObject *>(m);
@@ -69,7 +69,7 @@ ReturnedValue ProxyObject::get(const Managed *m, StringOrSymbol *name, bool *has
if (scope.hasException())
return Encode::undefined();
if (trap->isNullOrUndefined())
- return target->get(name, hasProperty);
+ return target->get(id, receiver, hasProperty);
if (!trap->isFunctionObject())
return scope.engine->throwTypeError();
if (hasProperty)
@@ -77,12 +77,12 @@ ReturnedValue ProxyObject::get(const Managed *m, StringOrSymbol *name, bool *has
JSCallData cdata(scope, 3, nullptr, handler);
cdata.args[0] = target;
- cdata.args[1] = name;
- cdata.args[2] = o->d(); // ### fix receiver handling
+ cdata.args[1] = id.toStringOrSymbol(scope.engine);
+ cdata.args[2] = *receiver;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
ScopedProperty targetDesc(scope);
- PropertyAttributes attributes = target->getOwnProperty(name->toPropertyKey(), targetDesc);
+ PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
if (attributes != Attr_Invalid && !attributes.isConfigurable()) {
if (attributes.isData() && !attributes.isWritable()) {
if (!trapResult->sameValue(targetDesc->value))
@@ -96,13 +96,6 @@ ReturnedValue ProxyObject::get(const Managed *m, StringOrSymbol *name, bool *has
return trapResult->asReturnedValue();
}
-ReturnedValue ProxyObject::getIndexed(const Managed *m, uint index, bool *hasProperty)
-{
- Scope scope(m);
- ScopedString name(scope, Primitive::fromUInt32(index).toString(scope.engine));
- return get(m, name, hasProperty);
-}
-
bool ProxyObject::put(Managed *m, Identifier id, const Value &value, Value *receiver)
{
Scope scope(m);
diff --git a/src/qml/jsruntime/qv4proxy_p.h b/src/qml/jsruntime/qv4proxy_p.h
index f605621210..626aef0624 100644
--- a/src/qml/jsruntime/qv4proxy_p.h
+++ b/src/qml/jsruntime/qv4proxy_p.h
@@ -85,8 +85,8 @@ struct ProxyObject: Object {
Q_MANAGED_TYPE(ProxyObject)
V4_INTERNALCLASS(ProxyObject)
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, uint index, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static bool deleteProperty(Managed *m, Identifier id);
static bool hasProperty(const Managed *m, Identifier id);
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index a3e761050c..bbf2ff6352 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -78,26 +78,25 @@ void Heap::QQmlContextWrapper::destroy()
Object::destroy();
}
-ReturnedValue QQmlContextWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue QQmlContextWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlContextWrapper>());
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
const QQmlContextWrapper *resource = static_cast<const QQmlContextWrapper *>(m);
QV4::ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
if (resource->d()->isNullWrapper)
- return Object::get(m, name, hasProperty);
+ return Object::get(m, id, receiver, hasProperty);
if (v4->callingQmlContext() != *resource->d()->context)
- return Object::get(m, name, hasProperty);
+ return Object::get(m, id, receiver, hasProperty);
bool hasProp = false;
- ScopedValue result(scope, Object::get(m, name, &hasProp));
+ ScopedValue result(scope, Object::get(m, id, receiver, &hasProp));
if (hasProp) {
if (hasProperty)
*hasProperty = hasProp;
@@ -125,6 +124,7 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, StringOrSymbol *n, bool
QObject *scopeObject = resource->getScopeObject();
+ ScopedString name(scope, id.asHeapObject());
if (context->imports && name->startsWithUpper()) {
// Search for attached properties, enums and imported scripts
QQmlTypeNameCache::Result r = context->imports->query(name, QQmlImport::AllowRecursion);
@@ -135,7 +135,7 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, StringOrSymbol *n, bool
if (r.scriptIndex != -1) {
QV4::ScopedObject scripts(scope, context->importedScripts.valueRef());
if (scripts)
- return scripts->getIndexed(r.scriptIndex);
+ return scripts->get(r.scriptIndex);
return QV4::Encode::null();
} else if (r.type.isValid()) {
return QQmlTypeWrapper::create(v4, scopeObject, r.type);
diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h
index 2dc0e57008..737a0d9b6e 100644
--- a/src/qml/jsruntime/qv4qmlcontext_p.h
+++ b/src/qml/jsruntime/qv4qmlcontext_p.h
@@ -98,7 +98,7 @@ struct Q_QML_EXPORT QQmlContextWrapper : Object
void setReadOnly(bool b) { d()->readOnly = b; }
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
};
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 8476d01f67..cd8563d06a 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -314,7 +314,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
}
}
}
- return QV4::Object::get(this, name, hasProperty);
+ return QV4::Object::get(this, name->identifier(), this, hasProperty);
}
QQmlData *ddata = QQmlData::get(d()->object(), false);
@@ -693,12 +693,14 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
return (engine->memoryManager->allocate<QV4::QObjectWrapper>(object))->asReturnedValue();
}
-QV4::ReturnedValue QObjectWrapper::get(const Managed *m, StringOrSymbol *name, bool *hasProperty)
+QV4::ReturnedValue QObjectWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
- if (name->isSymbol())
- return Object::get(m, name, hasProperty);
- String *n = static_cast<String *>(name);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
+
const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
+ Scope scope(that);
+ ScopedString n(scope, id.asHeapObject());
QQmlContextData *qmlContext = that->engine()->callingQmlContext();
return that->getQmlProperty(qmlContext, n, IgnoreRevision, hasProperty, /*includeImports*/ true);
}
@@ -1708,7 +1710,7 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q
uint length = array->getLength();
for (uint ii = 0; ii < length; ++ii) {
QObject *o = nullptr;
- qobjectWrapper = array->getIndexed(ii);
+ qobjectWrapper = array->get(ii);
if (!!qobjectWrapper)
o = qobjectWrapper->object();
qlistPtr->append(o);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 5d1f79fd39..9471f72b80 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -193,7 +193,7 @@ protected:
static QQmlPropertyData *findProperty(ExecutionEngine *engine, QObject *o, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local);
QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
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();
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 4fce63c5cf..2978a5e913 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -439,12 +439,12 @@ ReturnedValue RegExpPrototype::method_compile(const FunctionObject *b, const Val
return Encode::undefined();
}
-template <int index>
+template <uint index>
ReturnedValue RegExpPrototype::method_get_lastMatch_n(const FunctionObject *b, const Value *, const Value *, int)
{
Scope scope(b);
ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch());
- ScopedValue res(scope, lastMatch ? lastMatch->getIndexed(index) : Encode::undefined());
+ ScopedValue res(scope, lastMatch ? lastMatch->get(index) : Encode::undefined());
if (res->isUndefined())
res = scope.engine->newString();
return res->asReturnedValue();
@@ -454,7 +454,7 @@ ReturnedValue RegExpPrototype::method_get_lastParen(const FunctionObject *b, con
{
Scope scope(b);
ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch());
- ScopedValue res(scope, lastMatch ? lastMatch->getIndexed(lastMatch->getLength() - 1) : Encode::undefined());
+ ScopedValue res(scope, lastMatch ? lastMatch->get(lastMatch->getLength() - 1) : Encode::undefined());
if (res->isUndefined())
res = scope.engine->newString();
return res->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h
index a9ebe8384f..bf369c3999 100644
--- a/src/qml/jsruntime/qv4regexpobject_p.h
+++ b/src/qml/jsruntime/qv4regexpobject_p.h
@@ -165,7 +165,7 @@ struct RegExpPrototype: RegExpObject
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_compile(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- template <int index>
+ template <uint index>
static ReturnedValue method_get_lastMatch_n(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_lastParen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_input(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 948a002e46..87a1f665b5 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -619,7 +619,7 @@ static Q_NEVER_INLINE ReturnedValue getElementIntFallback(ExecutionEngine *engin
return v->asReturnedValue();
}
- return o->getIndexed(idx);
+ return o->get(idx);
}
static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine, const Value &object, const Value &index)
@@ -644,14 +644,6 @@ static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine,
return o->get(name);
}
-/* load element:
-
- Managed *m = object.heapObject();
- if (m)
- return m->internalClass->getIndexed(m, index);
- return getIndexedFallback(object, index);
-*/
-
ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &object, const Value &index)
{
uint idx = 0;
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 74964916ee..0826384614 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -538,7 +538,7 @@ public:
quint32 length = array->getLength();
QV4::ScopedValue v(scope);
for (quint32 i = 0; i < length; ++i)
- result.push_back(convertValueToElement<typename Container::value_type>((v = array->getIndexed(i))));
+ result.push_back(convertValueToElement<typename Container::value_type>((v = array->get(i))));
return QVariant::fromValue(result);
}
@@ -563,8 +563,12 @@ public:
QMetaObject::metacall(d()->object, QMetaObject::WriteProperty, d()->propertyIndex, a);
}
- static QV4::ReturnedValue getIndexed(const QV4::Managed *that, uint index, bool *hasProperty)
- { return static_cast<const QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty); }
+ static QV4::ReturnedValue get(const QV4::Managed *that, Identifier id, const Value *receiver, bool *hasProperty)
+ {
+ if (!id.isArrayIndex())
+ return Object::get(that, id, receiver, hasProperty);
+ return static_cast<const QQmlSequence<Container> *>(that)->containerGetIndexed(id.asArrayIndex(), hasProperty);
+ }
static bool put(Managed *that, Identifier id, const QV4::Value &value, Value *receiver)
{
if (id.isArrayIndex())
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index 0fb6044e7d..e151966306 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -197,7 +197,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
push(data, valueheader(WorkerArray, length));
ScopedValue val(scope);
for (uint ii = 0; ii < length; ++ii)
- serialize(data, (val = array->getIndexed(ii)), engine);
+ serialize(data, (val = array->get(ii)), engine);
} else if (v.isInteger()) {
reserve(data, 2 * sizeof(quint32));
push(data, valueheader(WorkerInt32));
@@ -265,7 +265,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
serialize(data, QV4::Primitive::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type
ScopedValue val(scope);
for (uint ii = 0; ii < seqLength; ++ii)
- serialize(data, (val = o->getIndexed(ii)), engine); // sequence elements
+ serialize(data, (val = o->get(ii)), engine); // sequence elements
return;
}
@@ -283,7 +283,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
QV4::ScopedValue s(scope);
for (quint32 ii = 0; ii < length; ++ii) {
- s = properties->getIndexed(ii);
+ s = properties->get(ii);
serialize(data, s, engine);
QV4::String *str = s->as<String>();
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index bb679f7ea0..ec319524a2 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -336,7 +336,7 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
char *b = newBuffer->d()->data->data();
ScopedValue val(scope);
while (idx < l) {
- val = o->getIndexed(idx);
+ val = o->get(idx);
array->d()->type->write(scope.engine, b, 0, val);
if (scope.engine->hasException)
return Encode::undefined();
@@ -367,8 +367,12 @@ Heap::TypedArray *TypedArray::create(ExecutionEngine *e, Heap::TypedArray::Type
return e->memoryManager->allocObject<TypedArray>(ic->d(), t);
}
-ReturnedValue TypedArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue TypedArray::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
+ if (!id.isArrayIndex())
+ return Object::get(m, id, receiver, hasProperty);
+
+ uint index = id.asArrayIndex();
Scope scope(static_cast<const Object *>(m)->engine());
Scoped<TypedArray> a(scope, static_cast<const TypedArray *>(m));
@@ -535,7 +539,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b,
char *b = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize;
ScopedValue val(scope);
while (idx < l) {
- val = o->getIndexed(idx);
+ val = o->get(idx);
a->d()->type->write(scope.engine, b, 0, val);
if (scope.engine->hasException)
RETURN_UNDEFINED();
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index cbc449471b..5171bcb83c 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -138,8 +138,9 @@ struct Q_QML_PRIVATE_EXPORT TypedArray : Object
Heap::TypedArray::Type arrayType() const {
return static_cast<Heap::TypedArray::Type>(d()->arrayType);
}
+ using Object::get;
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
};
diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp
index d1f2286534..61cb0a9065 100644
--- a/src/qml/qml/qqmldelayedcallqueue.cpp
+++ b/src/qml/qml/qqmldelayedcallqueue.cpp
@@ -71,7 +71,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en
*jsCallData->thisObject = QV4::Encode::undefined();
for (int i = 0; i < argCount; i++) {
- jsCallData->args[i] = array->getIndexed(i);
+ jsCallData->args[i] = array->get(i);
}
callback->call(jsCallData);
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index c2c8b796c3..5c88d4c2a5 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -102,47 +102,32 @@ QVariant QmlListWrapper::toVariant() const
}
-ReturnedValue QmlListWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue QmlListWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QmlListWrapper>());
-
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
-
const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
QV4::ExecutionEngine *v4 = w->engine();
- if (name->equals(v4->id_length()) && !w->d()->object.isNull()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- return Primitive::fromUInt32(count).asReturnedValue();
- }
-
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return getIndexed(m, idx, hasProperty);
+ if (index < count && w->d()->property().at) {
+ if (hasProperty)
+ *hasProperty = true;
+ return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index));
+ }
- return Object::get(m, name, hasProperty);
-}
-
-ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
-{
- Q_UNUSED(hasProperty);
-
- Q_ASSERT(m->as<QmlListWrapper>());
- const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
- QV4::ExecutionEngine *v4 = w->engine();
-
- quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- if (index < count && w->d()->property().at) {
if (hasProperty)
- *hasProperty = true;
- return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index));
+ *hasProperty = false;
+ return Primitive::undefinedValue().asReturnedValue();
+ } else if (id.isString()) {
+ if (id == v4->id_length()->identifier() && !w->d()->object.isNull()) {
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
+ return Primitive::fromUInt32(count).asReturnedValue();
+ }
}
- if (hasProperty)
- *hasProperty = false;
- return Primitive::undefinedValue().asReturnedValue();
+ return Object::get(m, id, receiver, hasProperty);
}
bool QmlListWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver)
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 3b80de473e..0c57fe1f47 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -93,8 +93,7 @@ struct Q_QML_EXPORT QmlListWrapper : Object
QVariant toVariant() const;
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
};
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 943cbc80d3..a1bfc109da 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -167,16 +167,16 @@ static ReturnedValue throwLowercaseEnumError(QV4::ExecutionEngine *v4, String *n
return v4->throwTypeError(message);
}
-ReturnedValue QQmlTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue QQmlTypeWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlTypeWrapper>());
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
QV4::ExecutionEngine *v4 = static_cast<const QQmlTypeWrapper *>(m)->engine();
QV4::Scope scope(v4);
+ ScopedString name(scope, id.asHeapObject());
Scoped<QQmlTypeWrapper> w(scope, static_cast<const QQmlTypeWrapper *>(m));
@@ -272,7 +272,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *ha
return create(scope.engine, object, r.type, w->d()->mode);
} else if (r.scriptIndex != -1) {
QV4::ScopedObject scripts(scope, context->importedScripts.valueRef());
- return scripts->getIndexed(r.scriptIndex);
+ return scripts->get(r.scriptIndex);
} else if (r.importNamespace) {
return create(scope.engine, object, context->imports, r.importNamespace);
}
@@ -288,7 +288,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *ha
}
bool ok = false;
- const ReturnedValue result = Object::get(m, name, &ok);
+ const ReturnedValue result = Object::get(m, id, receiver, &ok);
if (hasProperty)
*hasProperty = ok;
@@ -428,16 +428,16 @@ QQmlType Heap::QQmlScopedEnumWrapper::type() const
return QQmlType(typePrivate);
}
-ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlScopedEnumWrapper>());
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
const QQmlScopedEnumWrapper *resource = static_cast<const QQmlScopedEnumWrapper *>(m);
QV4::ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
+ ScopedString name(scope, id.asHeapObject());
QQmlType type = resource->d()->type();
int index = resource->d()->scopeEnumIndex;
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index e2684e438f..d14f128bfb 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -112,7 +112,7 @@ struct Q_QML_EXPORT QQmlTypeWrapper : Object
Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums);
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
static bool isEqualTo(Managed *that, Managed *o);
@@ -124,7 +124,7 @@ struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object
V4_OBJECT2(QQmlScopedEnumWrapper, Object)
V4_NEEDS_DESTROY
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
};
}
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 190d76c1a1..b1993da0a2 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -359,16 +359,17 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con
return Encode(b->engine()->newString(result));
}
-ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlValueTypeWrapper>());
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
QV4::ExecutionEngine *v4 = r->engine();
+ Scope scope(v4);
+ ScopedString name(scope, id.asHeapObject());
// Note: readReferenceValue() can change the reference->type.
if (const QQmlValueTypeReference *reference = r->as<QQmlValueTypeReference>()) {
@@ -376,9 +377,9 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, StringOrSymbol *n, boo
return Primitive::undefinedValue().asReturnedValue();
}
- QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(name.getPointer(), nullptr, nullptr);
if (!result)
- return Object::get(m, name, hasProperty);
+ return Object::get(m, id, receiver, hasProperty);
if (hasProperty)
*hasProperty = true;
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 6270fa7c63..9966671baa 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -106,7 +106,7 @@ public:
int typeId() const;
bool write(QObject *target, int propertyIndex) const;
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static bool isEqualTo(Managed *m, Managed *other);
static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index a8faac4b0d..2ed4743862 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -228,8 +228,7 @@ public:
static ReturnedValue create(ExecutionEngine *, NodeImpl *, const QList<NodeImpl *> &);
// JS API
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
};
void Heap::NamedNodeMap::init(NodeImpl *data, const QList<NodeImpl *> &list)
@@ -250,8 +249,7 @@ public:
V4_NEEDS_DESTROY
// JS API
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
// C++ API
static ReturnedValue create(ExecutionEngine *, NodeImpl *);
@@ -888,38 +886,33 @@ bool Node::isNull() const
return d()->d == nullptr;
}
-ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue NamedNodeMap::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<NamedNodeMap>());
+
const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
QV4::ExecutionEngine *v4 = r->engine();
- if ((int)index < r->d()->list().count()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+
+ if ((int)index < r->d()->list().count()) {
+ if (hasProperty)
+ *hasProperty = true;
+ return Node::create(v4, r->d()->list().at(index));
+ }
if (hasProperty)
- *hasProperty = true;
- return Node::create(v4, r->d()->list().at(index));
+ *hasProperty = false;
+ return Encode::undefined();
}
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
-}
-ReturnedValue NamedNodeMap::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
-{
- Q_ASSERT(m->as<NamedNodeMap>());
-
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
-
- const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
- QV4::ExecutionEngine *v4 = r->engine();
+ if (id.isSymbol())
+ return Object::get(m, id, receiver, hasProperty);
- name->makeIdentifier();
- if (name->equals(v4->id_length()))
+ if (id == v4->id_length()->identifier())
return Primitive::fromInt32(r->d()->list().count()).asReturnedValue();
- QString str = name->toQString();
+ QString str = id.toQString();
for (int ii = 0; ii < r->d()->list().count(); ++ii) {
if (r->d()->list().at(ii)->name == str) {
if (hasProperty)
@@ -938,33 +931,27 @@ ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QL
return (v4->memoryManager->allocate<NamedNodeMap>(data, list))->asReturnedValue();
}
-ReturnedValue NodeList::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue NodeList::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<NodeList>());
const NodeList *r = static_cast<const NodeList *>(m);
QV4::ExecutionEngine *v4 = r->engine();
- if ((int)index < r->d()->d->children.count()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ if ((int)index < r->d()->d->children.count()) {
+ if (hasProperty)
+ *hasProperty = true;
+ return Node::create(v4, r->d()->d->children.at(index));
+ }
if (hasProperty)
- *hasProperty = true;
- return Node::create(v4, r->d()->d->children.at(index));
+ *hasProperty = false;
+ return Encode::undefined();
}
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
-}
-
-ReturnedValue NodeList::get(const Managed *m, StringOrSymbol *name, bool *hasProperty)
-{
- Q_ASSERT(m->as<NodeList>());
- const NodeList *r = static_cast<const NodeList *>(m);
- QV4::ExecutionEngine *v4 = r->engine();
-
- name->makeIdentifier();
- if (name->identifier() == v4->id_length()->identifier())
+ if (id == v4->id_length()->identifier())
return Primitive::fromInt32(r->d()->d->children.count()).asReturnedValue();
- return Object::get(m, name, hasProperty);
+ return Object::get(m, id, receiver, hasProperty);
}
ReturnedValue NodeList::create(ExecutionEngine *v4, NodeImpl *data)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 3cad4b97a2..22b8bddd66 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -197,21 +197,21 @@ ReturnedValue QtObject::findAndAdd(const QString *name, bool &foundProperty) con
return Encode::undefined();
}
-ReturnedValue QtObject::get(const Managed *m, StringOrSymbol *name, bool *hasProperty)
+ReturnedValue QtObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
bool hasProp = false;
if (hasProperty == nullptr) {
hasProperty = &hasProp;
}
- ReturnedValue ret = QV4::Object::get(m, name, hasProperty);
+ ReturnedValue ret = QV4::Object::get(m, id, receiver, hasProperty);
if (*hasProperty) {
return ret;
}
auto that = static_cast<const QtObject*>(m);
if (!that->d()->isComplete()) {
- const QString key = name->toQString();
+ const QString key = id.toQString();
ret = that->findAndAdd(&key, *hasProperty);
}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index 60a2a6b87d..06555568d3 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -93,7 +93,7 @@ struct QtObject : Object
{
V4_OBJECT2(QtObject, Object)
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 76b3b5e76c..030f924e2a 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1857,7 +1857,7 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const
QV4::ScopedValue v(scope);
uint arrayLength = array->getLength();
for (uint i = 0; i < arrayLength; ++i) {
- v = array->getIndexed(i);
+ v = array->get(i);
const QString groupName = v->toQString();
int index = groupNames.indexOf(groupName);
if (index != -1)
@@ -3383,44 +3383,43 @@ public:
quint32 count() const { return d()->changes->count(); }
const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); }
- static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
+ static QV4::ReturnedValue get(const QV4::Managed *m, QV4::Identifier id, const QV4::Value *receiver, bool *hasProperty)
{
- Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
- QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine();
- QV4::Scope scope(v4);
- QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m));
-
- if (index >= array->count()) {
- if (hasProperty)
- *hasProperty = false;
- return QV4::Primitive::undefinedValue().asReturnedValue();
- }
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
+ QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine();
+ QV4::Scope scope(v4);
+ QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m));
+
+ if (index >= array->count()) {
+ if (hasProperty)
+ *hasProperty = false;
+ return QV4::Primitive::undefinedValue().asReturnedValue();
+ }
- const QQmlChangeSet::Change &change = array->at(index);
+ const QQmlChangeSet::Change &change = array->at(index);
- QV4::ScopedObject changeProto(scope, engineData(v4)->changeProto.value());
- QV4::Scoped<QQmlDelegateModelGroupChange> object(scope, QQmlDelegateModelGroupChange::create(v4));
- object->setPrototypeOf(changeProto);
- object->d()->change = change;
+ QV4::ScopedObject changeProto(scope, engineData(v4)->changeProto.value());
+ QV4::Scoped<QQmlDelegateModelGroupChange> object(scope, QQmlDelegateModelGroupChange::create(v4));
+ object->setPrototypeOf(changeProto);
+ object->d()->change = change;
- if (hasProperty)
- *hasProperty = true;
- return object.asReturnedValue();
- }
+ if (hasProperty)
+ *hasProperty = true;
+ return object.asReturnedValue();
+ }
- static QV4::ReturnedValue get(const QV4::Managed *m, QV4::StringOrSymbol *name, bool *hasProperty)
- {
Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
const QQmlDelegateModelGroupChangeArray *array = static_cast<const QQmlDelegateModelGroupChangeArray *>(m);
- name->makeIdentifier();
- if (name->identifier() == array->engine()->id_length()->identifier()) {
+ if (id == array->engine()->id_length()->identifier()) {
if (hasProperty)
*hasProperty = true;
return QV4::Encode(array->count());
}
- return Object::get(m, name, hasProperty);
+ return Object::get(m, id, receiver, hasProperty);
}
};
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index a8f4708ff6..8ddacdfd9b 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -587,7 +587,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
@@ -668,7 +668,7 @@ void ListModel::set(int elementIndex, QV4::Object *object)
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
@@ -1422,7 +1422,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
ListModel *subModel = new ListModel(role.subLayout, nullptr);
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
roleIndex = setListProperty(role, subModel);
@@ -1584,16 +1584,17 @@ bool ModelObject::put(Managed *m, Identifier id, const Value &value, Value *rece
return true;
}
-ReturnedValue ModelObject::get(const Managed *m, StringOrSymbol *n, bool *hasProperty)
+ReturnedValue ModelObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty)
{
- if (n->isSymbol())
- return Object::get(m, n, hasProperty);
- String *name = static_cast<String *>(n);
+ if (!id.isString())
+ return Object::get(m, id, receiver, hasProperty);
const ModelObject *that = static_cast<const ModelObject*>(m);
+ Scope scope(that);
+ ScopedString name(scope, id.asHeapObject());
const ListLayout::Role *role = that->d()->m_model->m_listModel->getExistingRole(name);
if (!role)
- return QObjectWrapper::get(m, name, hasProperty);
+ return QObjectWrapper::get(m, id, receiver, hasProperty);
if (hasProperty)
*hasProperty = true;
@@ -2343,7 +2344,7 @@ void QQmlListModel::insert(QQmlV4Function *args)
int objectArrayLength = objectArray->getLength();
emitItemsAboutToBeInserted(index, objectArrayLength);
for (int i=0 ; i < objectArrayLength ; ++i) {
- argObject = objectArray->getIndexed(i);
+ argObject = objectArray->get(i);
if (m_dynamicRoles) {
m_modelObjects.insert(index+i, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
@@ -2455,7 +2456,7 @@ void QQmlListModel::append(QQmlV4Function *args)
emitItemsAboutToBeInserted(index, objectArrayLength);
for (int i=0 ; i < objectArrayLength ; ++i) {
- argObject = objectArray->getIndexed(i);
+ argObject = objectArray->get(i);
if (m_dynamicRoles) {
m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index a271d9b4d2..a0fd4a3310 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -174,7 +174,7 @@ struct ModelObject : public QObjectWrapper {
struct ModelObject : public QObjectWrapper
{
static bool put(Managed *m, Identifier id, const Value& value, Value *receiver);
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty);
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
V4_OBJECT2(ModelObject, QObjectWrapper)