diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-29 12:14:53 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-04 13:02:09 +0000 |
commit | 8e23235181eb25faf99324e136412da23dc8386f (patch) | |
tree | 97071ffe480c175200e8cb765a80015aa11cf890 /src/qml/jsruntime/qv4typedarray.cpp | |
parent | a0fcf724ef1d8586301a913d2cd744aed33e3605 (diff) |
Use Symbol.toStringTag in Object.prototype.toString
This should make toString comply fully with the JS Spec.
Also add a couple of missing Symbol.toStringTag
properties.
Change-Id: I29e2018b486a0e1d174b58ce7a14f0e42cc78767
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4typedarray.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4typedarray.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index b3c6f0e094..2fa4a9ecaf 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -623,6 +623,15 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_subarray(const FunctionObject return constructor->callAsConstructor(arguments, 3); } +ReturnedValue IntrinsicTypedArrayPrototype::method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *, int) +{ + const TypedArray *a = thisObject->as<TypedArray>(); + if (!a) + return Encode::undefined(); + + return a->engine()->newString(QString::fromLatin1(a->d()->type->name))->asReturnedValue(); +} + ReturnedValue IntrinsicTypedArrayCtor::callAsConstructor(const FunctionObject *f, const Value *, int) { return f->engine()->throwTypeError(); @@ -650,4 +659,5 @@ void IntrinsicTypedArrayPrototype::init(ExecutionEngine *engine, IntrinsicTypedA defineDefaultProperty(QStringLiteral("set"), method_set, 1); defineDefaultProperty(QStringLiteral("subarray"), method_subarray, 0); defineDefaultProperty(engine->symbol_iterator(), method_values, 0); + defineAccessorProperty(engine->symbol_toStringTag(), method_get_toStringTag, nullptr); } |