diff options
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4numberobject.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 3 |
6 files changed, 37 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a3c48fb378..0ace88b01f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -582,6 +582,16 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(InternalClass *ic, Object *pr return object->d(); } +Heap::ArrayBuffer *ExecutionEngine::newArrayBuffer(const QByteArray &array) +{ + Scope scope(this); + Scoped<ArrayBuffer> object(scope, memoryManager->alloc<ArrayBuffer>(this, array.size())); + if (!hasException) { + memcpy(object->d()->data->data(), array.data(), array.size()); + } + return object->d(); +} + Heap::DateObject *ExecutionEngine::newDateObject(const Value &value) { diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 098510e91a..bcb74ab694 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -268,6 +268,8 @@ public: Heap::ArrayObject *newArrayObject(const QStringList &list); Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype); + Heap::ArrayBuffer *newArrayBuffer(const QByteArray &array); + Heap::DateObject *newDateObject(const Value &value); Heap::DateObject *newDateObject(const QDateTime &dt); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 9769940a77..a79f71ff64 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -34,10 +34,19 @@ #ifndef QV4GLOBAL_H #define QV4GLOBAL_H +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +#define V4_BOOTSTRAP +#endif + #include <QtCore/qglobal.h> #include <QString> + +#ifdef V4_BOOTSTRAP +#include <private/qtqmldevtoolsglobal_p.h> +#else #include <qtqmlglobal.h> #include <private/qtqmlglobal_p.h> +#endif #if defined(Q_CC_MSVC) #include <float.h> @@ -59,10 +68,6 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } #define qOffsetOf(s, m) ((size_t)((((char *)&(((s *)64)->m)) - 64))) -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -#define V4_BOOTSTRAP -#endif - // Decide whether to enable or disable the JIT // White list architectures diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index d8c9d89369..89ff110b20 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -204,9 +204,15 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) str = QString::fromLatin1("NaN"); else if (qIsInf(v)) str = QString::fromLatin1(v < 0 ? "-Infinity" : "Infinity"); - else if (v < 1.e21) - str = QString::number(v, 'f', int (fdigits)); - else + else if (v < 1.e21) { + char buf[100]; + double_conversion::StringBuilder builder(buf, sizeof(buf)); + double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToFixed(v, fdigits, &builder); + str = QString::fromLatin1(builder.Finalize()); + // At some point, the 3rd party double-conversion code should be moved to qtcore. + // When that's done, we can use: +// str = QString::number(v, 'f', int (fdigits)); + } else return RuntimeHelpers::stringFromNumber(ctx->engine(), v)->asReturnedValue(); return scope.engine->newString(str)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 7853b5fac6..a7e3b22cd2 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -527,6 +527,8 @@ Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, QObjec } +namespace QV4 { + typedef QQmlSequence<QStringList> QQmlQStringList; template<> DEFINE_OBJECT_VTABLE(QQmlQStringList); @@ -546,6 +548,8 @@ typedef QQmlSequence<QList<qreal> > QQmlRealList; template<> DEFINE_OBJECT_VTABLE(QQmlRealList); +} + #define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType<SequenceType>(#SequenceType); void SequencePrototype::init() { diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index ea98adc0c8..8ed6c1459c 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -370,6 +370,9 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value static inline Primitive fromDouble(double d); static inline Primitive fromUInt32(uint i); + using Value::toInt32; + using Value::toUInt32; + static double toInteger(double fromNumber); static int toInt32(double value); static unsigned int toUInt32(double value); |