diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-01 23:21:21 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-04 18:25:38 +0000 |
commit | f5ad1a13e5ce9ce1389ea7731829ea455259a4db (patch) | |
tree | 3e340593b23df47c9f016d2db43d9184a1a64e59 /src/qml/jsruntime/qv4propertykey.cpp | |
parent | a6ba4f044e3611fb66a6cce87bc06933c3e27070 (diff) |
Fix a couple of internals in TypedArrays
Handle property keys that are numeric strings, and implement
getOwnProperty.
Change-Id: I4c7ed21b6429b07f02a28bce537bcb7934a993d3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4propertykey.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4propertykey.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp index 12a3653034..361ade17c2 100644 --- a/src/qml/jsruntime/qv4propertykey.cpp +++ b/src/qml/jsruntime/qv4propertykey.cpp @@ -42,6 +42,7 @@ #include <QtCore/qstring.h> #include <qv4string_p.h> #include <qv4engine_p.h> +#include <qv4scopedvalue_p.h> QV4::Heap::StringOrSymbol *QV4::PropertyKey::toStringOrSymbol(QV4::ExecutionEngine *e) { @@ -60,6 +61,24 @@ bool QV4::PropertyKey::isSymbol() const { return s && !s->internalClass->vtable->isString && s->internalClass->vtable->isStringOrSymbol; } +bool QV4::PropertyKey::isCanonicalNumericIndexString() const +{ + if (isArrayIndex()) + return true; + if (isSymbol()) + return false; + Heap::String *s = static_cast<Heap::String *>(asStringOrSymbol()); + Scope scope(s->internalClass->engine); + ScopedString str(scope, s); + double d = str->toNumber(); + if (d == 0. && std::signbit(d)) + return true; + ScopedString converted(scope, Primitive::fromDouble(d).toString(scope.engine)); + if (converted->equals(str)) + return true; + return false; +} + QString QV4::PropertyKey::toQString() const { if (isArrayIndex()) |