aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp4
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp5
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp4
-rw-r--r--src/qml/qml/v4vm/qv4value.cpp38
-rw-r--r--src/qml/qml/v4vm/qv4value_p.h1
-rw-r--r--src/qml/qml/v8/qjsvalue.cpp26
-rw-r--r--src/qml/qml/v8/qv8engine.cpp13
-rw-r--r--src/qml/qml/v8/qv8engine_p.h2
8 files changed, 49 insertions, 44 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 7ee21a79e4..ef869cd986 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -55,6 +55,8 @@
#include <private/qv8debugservice_p.h>
#include "qqmlinfo.h"
+#include <private/qv4value_p.h>
+
#include <QtCore/qstringbuilder.h>
#include <QtCore/qdebug.h>
@@ -140,7 +142,7 @@ QString QQmlBoundSignalExpression::expression() const
Q_ASSERT (context() && engine());
v8::HandleScope handle_scope;
v8::Context::Scope context_scope(QQmlEnginePrivate::get(engine())->v8engine()->context());
- return QV8Engine::toStringStatic(m_v8function->ToString());
+ return m_v8function->v4Value().toQString();
} else if (!m_expressionUtf8.isEmpty()) {
return QString::fromUtf8(m_expressionUtf8);
} else {
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 4568307d5b..a8b3a99e39 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -42,6 +42,7 @@
#include "qqmljavascriptexpression_p.h"
#include <private/qqmlexpression_p.h>
+#include <private/qv4value_p.h>
QT_BEGIN_NAMESPACE
@@ -315,12 +316,12 @@ void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message,
if (file.IsEmpty() || file->Length() == 0)
error.setUrl(QUrl());
else
- error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
+ error.setUrl(QUrl(file->v4Value().toQString()));
error.setLine(lineNumber);
error.setColumn(-1);
- QString qDescription = QV8Engine::toStringStatic(description);
+ QString qDescription = description->v4Value().toQString();
if (qDescription.startsWith(QLatin1String("Uncaught ")))
qDescription = qDescription.mid(9 /* strlen("Uncaught ") */);
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 0ed649bdd1..dee534dc69 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -51,6 +51,8 @@
#include <private/qmetaobjectbuilder_p.h>
#include <private/qqmlrewrite_p.h>
+#include <private/qv4value_p.h>
+
#include <QtCore/qdebug.h>
#include <ctype.h> // for toupper
@@ -1367,7 +1369,7 @@ inline const QString &qQmlPropertyCacheToString(const QString &string)
inline QString qQmlPropertyCacheToString(const QHashedV8String &string)
{
- return QV8Engine::toStringStatic(string.string());
+ return string.string()->v4Value().toQString();
}
template<typename T>
diff --git a/src/qml/qml/v4vm/qv4value.cpp b/src/qml/qml/v4vm/qv4value.cpp
index 6de197b1ce..28c609c872 100644
--- a/src/qml/qml/v4vm/qv4value.cpp
+++ b/src/qml/qml/v4vm/qv4value.cpp
@@ -86,6 +86,44 @@ double Value::toNumber() const
return __qmljs_to_number(*this);
}
+QString Value::toQString() const
+{
+ switch (type()) {
+ case Value::Undefined_Type:
+ return QStringLiteral("undefined");
+ case Value::Null_Type:
+ return QStringLiteral("null");
+ case Value::Boolean_Type:
+ if (booleanValue())
+ return QStringLiteral("true");
+ else
+ return QStringLiteral("false");
+ case Value::String_Type:
+ return stringValue()->toQString();
+ case Value::Object_Type: {
+ ExecutionContext *ctx = objectValue()->internalClass->engine->current;
+ try {
+ Value prim = __qmljs_to_primitive(*this, STRING_HINT);
+ if (prim.isPrimitive())
+ return prim.toQString();
+ } catch (Exception &e) {
+ e.accept(ctx);
+ }
+ return QString();
+ }
+ case Value::Integer_Type: {
+ QString str;
+ __qmljs_numberToString(&str, (double)int_32, 10);
+ return str;
+ }
+ default: { // double
+ QString str;
+ __qmljs_numberToString(&str, doubleValue(), 10);
+ return str;
+ }
+ } // switch
+}
+
bool Value::sameValue(Value other) const {
if (val == other.val)
return true;
diff --git a/src/qml/qml/v4vm/qv4value_p.h b/src/qml/qml/v4vm/qv4value_p.h
index 28bac74bcb..16a01c8a6d 100644
--- a/src/qml/qml/v4vm/qv4value_p.h
+++ b/src/qml/qml/v4vm/qv4value_p.h
@@ -221,6 +221,7 @@ struct Q_QML_EXPORT Value
Bool toBoolean() const;
double toInteger() const;
double toNumber() const;
+ QString toQString() const;
String *toString(ExecutionContext *ctx) const;
Object *toObject(ExecutionContext *ctx) const;
diff --git a/src/qml/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp
index ae91822535..fe77382489 100644
--- a/src/qml/qml/v8/qjsvalue.cpp
+++ b/src/qml/qml/v8/qjsvalue.cpp
@@ -335,31 +335,7 @@ bool QJSValue::isVariant() const
*/
QString QJSValue::toString() const
{
- // have to check these here as converting those to a QV4::String requires a context
- // (which we don't always have for those types)
- if (d->value.isUndefined())
- return QStringLiteral("undefined");
- else if (d->value.isNull())
- return QStringLiteral("null");
- else if (d->value.isBoolean()) {
- if (d->value.booleanValue())
- return QStringLiteral("true");
- else
- return QStringLiteral("false");
- }
- else if (d->value.isNumber()) {
- QString result;
- __qmljs_numberToString(&result, d->value.asDouble());
- return result;
- }
-
- QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
- try {
- return d->value.toString(ctx)->toQString();
- } catch (Exception &e) {
- e.accept(ctx);
- return e.value().toString(ctx)->toQString();
- }
+ return d->value.toQString();
}
/*!
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index e470eaafed..eac90e0237 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -205,19 +205,6 @@ QV8Engine::~QV8Engine()
qPersistentDispose(m_context);
}
-QString QV8Engine::toStringStatic(v8::Handle<v8::Value> jsstr)
-{
- return toStringStatic(jsstr->ToString());
-}
-
-QString QV8Engine::toStringStatic(v8::Handle<v8::String> jsstr)
-{
- QString qstr;
- qstr.resize(jsstr->Length());
- jsstr->Write((uint16_t*)qstr.data());
- return qstr;
-}
-
QVariant QV8Engine::toVariant(v8::Handle<v8::Value> value, int typeHint)
{
if (value.IsEmpty())
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index d5854d37b6..22e2a14426 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -313,8 +313,6 @@ public:
QString toString(v8::Handle<v8::Value> string);
QString toString(v8::Handle<v8::String> string);
- static QString toStringStatic(v8::Handle<v8::Value>);
- static QString toStringStatic(v8::Handle<v8::String>);
static inline bool startsWithUpper(v8::Handle<v8::String>);
QVariant toVariant(v8::Handle<v8::Value>, int typeHint);