From 9c8c36ccc0d11d31edf2582da1bee670c3db20d5 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Thu, 4 Aug 2011 11:21:57 +0200 Subject: [PATCH] Code cleanup: unify string conversions. Unify string conversions when there is not any external string wrapper. Change-Id: I6665e33c968b9d1c6ad86595639967ddcd257667 Reviewed-on: http://codereview.qt.nokia.com/2701 Reviewed-by: Qt Sanity Bot Reviewed-by: Simon Hausmann --- src/declarative/qml/v8/qjsconverter_p.h | 3 ++- src/declarative/qml/v8/qv8stringwrapper.cpp | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/v8/qjsconverter_p.h b/src/declarative/qml/v8/qjsconverter_p.h index 4aec472..c42381b 100644 --- a/src/declarative/qml/v8/qjsconverter_p.h +++ b/src/declarative/qml/v8/qjsconverter_p.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,7 @@ public: return qstr; } - static v8::Handle toString(const QString& string) + static v8::Local toString(const QString& string) { return v8::String::New(reinterpret_cast(string.data()), string.size()); } diff --git a/src/declarative/qml/v8/qv8stringwrapper.cpp b/src/declarative/qml/v8/qv8stringwrapper.cpp index 5178da0..1fea98f 100644 --- a/src/declarative/qml/v8/qv8stringwrapper.cpp +++ b/src/declarative/qml/v8/qv8stringwrapper.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qv8stringwrapper_p.h" +#include "qjsconverter_p.h" QT_BEGIN_NAMESPACE @@ -73,7 +74,7 @@ void QV8StringWrapper::destroy() v8::Local QV8StringWrapper::toString(const QString &qstr) { // return v8::String::NewExternal(new QV8StringResource(qstr)); - return v8::String::New((uint16_t*)qstr.constData(), qstr.length()); + return QJSConverter::toString(qstr); } QString QV8StringWrapper::toString(v8::Handle jsstr) @@ -84,10 +85,7 @@ QString QV8StringWrapper::toString(v8::Handle jsstr) QV8StringResource *r = (QV8StringResource *)jsstr->GetExternalStringResource(); return r->str; } else { - QString qstr; - qstr.resize(jsstr->Length()); - jsstr->Write((uint16_t*)qstr.data()); - return qstr; + return QJSConverter::toString(jsstr); } } -- 2.7.4