diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 15:34:57 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:25 +0000 |
commit | 98263a01373f5b225d64da216537165ae27d7ff1 (patch) | |
tree | 60980c16c6cc6f6658355bcd428245819b4b732a /src/qml/jsruntime/qv4proxy.cpp | |
parent | d21ef386ece52490d428daacb8f7f4658e9f78e5 (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/qv4proxy.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4proxy.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp index 5b5149a2f4..11914e4feb 100644 --- a/src/qml/jsruntime/qv4proxy.cpp +++ b/src/qml/jsruntime/qv4proxy.cpp @@ -103,7 +103,7 @@ ReturnedValue ProxyObject::getIndexed(const Managed *m, uint index, bool *hasPro return get(m, name, hasProperty); } -bool ProxyObject::put(Managed *m, StringOrSymbol *name, const Value &value) +bool ProxyObject::put(Managed *m, Identifier id, const Value &value, Value *receiver) { Scope scope(m); const ProxyObject *o = static_cast<const ProxyObject *>(m); @@ -117,21 +117,21 @@ bool ProxyObject::put(Managed *m, StringOrSymbol *name, const Value &value) if (scope.hasException()) return Encode::undefined(); if (trap->isNullOrUndefined()) - return target->put(name, value); + return target->put(id, value, receiver); if (!trap->isFunctionObject()) return scope.engine->throwTypeError(); JSCallData cdata(scope, 4, nullptr, handler); cdata.args[0] = target; - cdata.args[1] = name; + cdata.args[1] = id.toStringOrSymbol(scope.engine); cdata.args[2] = value; - cdata.args[3] = o->d(); // ### fix receiver handling + cdata.args[3] = *receiver; ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); if (!trapResult->toBoolean()) return false; 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 (!value.sameValue(targetDesc->value)) @@ -143,13 +143,6 @@ bool ProxyObject::put(Managed *m, StringOrSymbol *name, const Value &value) return true; } -bool ProxyObject::putIndexed(Managed *m, uint index, const Value &value) -{ - Scope scope(m); - ScopedString name(scope, Primitive::fromUInt32(index).toString(scope.engine)); - return put(m, name, value); -} - bool ProxyObject::deleteProperty(Managed *m, Identifier id) { Scope scope(m); |