aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qmlcontext.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-22 15:34:57 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-02 19:29:25 +0000
commit98263a01373f5b225d64da216537165ae27d7ff1 (patch)
tree60980c16c6cc6f6658355bcd428245819b4b732a /src/qml/jsruntime/qv4qmlcontext.cpp
parentd21ef386ece52490d428daacb8f7f4658e9f78e5 (diff)
Unify put and putIndexed
Pass an Identifier through those virtual methods to unify the string and integer based versions. Also add the receiver that's required in ES7 Change-Id: I4e7f01b4c97cc80bcb3c485f6343f28213dc9e6b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4qmlcontext.cpp')
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index 4226bf7972..a3e761050c 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -229,13 +229,12 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, StringOrSymbol *n, bool
return Encode::undefined();
}
-bool QQmlContextWrapper::put(Managed *m, StringOrSymbol *n, const Value &value)
+bool QQmlContextWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver)
{
Q_ASSERT(m->as<QQmlContextWrapper>());
- if (n->isSymbol())
- return Object::put(m, n, value);
- String *name = static_cast<String *>(n);
+ if (id.isSymbol() || id.isArrayIndex())
+ return Object::put(m, id, value, receiver);
QQmlContextWrapper *resource = static_cast<QQmlContextWrapper *>(m);
ExecutionEngine *v4 = resource->engine();
@@ -244,21 +243,20 @@ bool QQmlContextWrapper::put(Managed *m, StringOrSymbol *n, const Value &value)
return false;
QV4::Scoped<QQmlContextWrapper> wrapper(scope, resource);
- name->makeIdentifier();
- uint member = wrapper->internalClass()->find(name->identifier());
+ uint member = wrapper->internalClass()->find(id);
if (member < UINT_MAX)
return wrapper->putValue(member, value);
if (wrapper->d()->isNullWrapper) {
if (wrapper && wrapper->d()->readOnly) {
- QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
+ QString error = QLatin1String("Invalid write to global property \"") + id.toQString() +
QLatin1Char('"');
ScopedString e(scope, v4->newString(error));
v4->throwError(e);
return false;
}
- return Object::put(m, name, value);
+ return Object::put(m, id, value, receiver);
}
// It's possible we could delay the calculation of the "actual" context (in the case
@@ -272,6 +270,7 @@ bool QQmlContextWrapper::put(Managed *m, StringOrSymbol *n, const Value &value)
// See QV8ContextWrapper::Getter for resolution order
QObject *scopeObject = wrapper->getScopeObject();
+ ScopedString name(scope, id.asHeapObject());
while (context) {
const QV4::IdentifierHash &properties = context->propertyNames();
@@ -302,7 +301,7 @@ bool QQmlContextWrapper::put(Managed *m, StringOrSymbol *n, const Value &value)
return false;
}
- return Object::put(m, name, value);
+ return Object::put(m, id, value, receiver);
}
void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContextWrapper *qml)