diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-04-19 10:32:42 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-04-19 12:04:08 +0200 |
commit | 190b376859ae9709e887886fcbaa56d60495be66 (patch) | |
tree | 1e775dc4dcd81a33dc83b060f94a583a04f8527d | |
parent | 672d2fd4e844536e22e167f8e99183a4732543b6 (diff) |
Get rid of qv8stringwrapper
Change-Id: I07762a0b0662604b9263775346145cf86acddc61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 27 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine_p.h | 23 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8stringwrapper.cpp | 78 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8stringwrapper_p.h | 78 | ||||
-rw-r--r-- | src/qml/qml/v8/v8.pri | 2 |
5 files changed, 23 insertions, 185 deletions
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 3466550ba7..9eaa7eaec9 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -161,7 +161,6 @@ QV8Engine::QV8Engine(QJSEngine* qq, ContextOwnership ownership) m_bindingFlagKey = qPersistentNew(v8::String::New("qml::binding")); - m_stringWrapper.init(); m_contextWrapper.init(this); m_qobjectWrapper.init(this); m_typeWrapper.init(this); @@ -202,7 +201,6 @@ QV8Engine::~QV8Engine() m_typeWrapper.destroy(); m_qobjectWrapper.destroy(); m_contextWrapper.destroy(); - m_stringWrapper.destroy(); qPersistentDispose(m_bindingFlagKey); @@ -355,7 +353,7 @@ v8::Handle<v8::Value> QV8Engine::fromVariant(const QVariant &variant) case QMetaType::Double: return v8::Number::New(*reinterpret_cast<const double*>(ptr)); case QMetaType::QString: - return m_stringWrapper.toString(*reinterpret_cast<const QString*>(ptr)); + return v8::Value::fromVmValue(QQmlJS::VM::Value::fromString(m_v4Engine->current, *reinterpret_cast<const QString*>(ptr))); case QMetaType::Float: return v8::Number::New(*reinterpret_cast<const float*>(ptr)); case QMetaType::Short: @@ -455,8 +453,8 @@ v8::Local<v8::Script> QV8Engine::qmlModeCompile(const QString &source, const QString &fileName, quint16 lineNumber) { - v8::Local<v8::String> v8source = m_stringWrapper.toString(source); - v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName); + v8::Local<v8::String> v8source = QJSConverter::toString(source); + v8::Local<v8::String> v8fileName = QJSConverter::toString(fileName); v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1)); @@ -476,7 +474,7 @@ v8::Local<v8::Script> QV8Engine::qmlModeCompile(const char *source, int sourceLe sourceLength = int(strlen(source)); v8::Local<v8::String> v8source = v8::String::New(source, sourceLength); - v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName); + v8::Local<v8::String> v8fileName = QJSConverter::toString(fileName); v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1)); @@ -534,7 +532,7 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value) if (value->IsNumber()) return value->ToNumber()->Value(); if (value->IsString()) - return m_stringWrapper.toString(value->ToString()); + return value.get()->vmValue().toString(m_v4Engine->current)->toQString(); if (value->IsDate()) return qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(value)->NumberValue()); // NOTE: since we convert QTime to JS Date, round trip will change the variant type (to QDateTime)! @@ -1560,5 +1558,20 @@ QV8Engine::ThreadData::~ThreadData() } } +QString QV8Engine::toString(v8::Handle<v8::Value> string) +{ + return string.get()->vmValue().toString(m_v4Engine->current)->toQString(); +} + +QString QV8Engine::toString(v8::Handle<v8::String> string) +{ + return string.get()->vmValue().toString(m_v4Engine->current)->toQString(); +} + +v8::Local<v8::String> QV8Engine::toString(const QString &string) +{ + return QJSConverter::toString(string); +} + QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index 23cb15e219..fde5b63f9c 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -73,7 +73,6 @@ #include "qv8objectresource_p.h" #include "qv8contextwrapper_p.h" #include "qv8qobjectwrapper_p.h" -#include "qv8stringwrapper_p.h" #include "qv8typewrapper_p.h" #include "qv8listwrapper_p.h" #include "qv8variantwrapper_p.h" @@ -305,8 +304,8 @@ public: v8::Local<v8::Array> getOwnPropertyNames(v8::Handle<v8::Object>); void freezeObject(v8::Handle<v8::Value>); - inline QString toString(v8::Handle<v8::Value> string); - inline QString toString(v8::Handle<v8::String> string); + 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>); @@ -333,7 +332,7 @@ public: inline QObject *toQObject(v8::Handle<v8::Value>); // Return a JS string for the given QString \a string - inline v8::Local<v8::String> toString(const QString &string); + v8::Local<v8::String> toString(const QString &string); // Create a new value type object inline v8::Handle<v8::Value> newValueType(QObject *, int coreIndex, QQmlValueType *); @@ -464,7 +463,6 @@ protected: v8::Persistent<v8::String> m_bindingFlagKey; - QV8StringWrapper m_stringWrapper; QV8ContextWrapper m_contextWrapper; QV8QObjectWrapper m_qobjectWrapper; QV8TypeWrapper m_typeWrapper; @@ -549,16 +547,6 @@ void qPersistentDispose(v8::Persistent<T> &that) that.Clear(); } -QString QV8Engine::toString(v8::Handle<v8::Value> string) -{ - return m_stringWrapper.toString(string->ToString()); -} - -QString QV8Engine::toString(v8::Handle<v8::String> string) -{ - return m_stringWrapper.toString(string); -} - bool QV8Engine::isVariant(v8::Handle<v8::Value> value) { return m_variantWrapper.isVariant(value); @@ -598,11 +586,6 @@ v8::Handle<v8::Value> QV8Engine::newQObject(QObject *object, const ObjectOwnersh return result; } -v8::Local<v8::String> QV8Engine::toString(const QString &string) -{ - return m_stringWrapper.toString(string); -} - v8::Handle<v8::Value> QV8Engine::newValueType(QObject *object, int property, QQmlValueType *type) { return m_valueTypeWrapper.newValueType(object, property, type); diff --git a/src/qml/qml/v8/qv8stringwrapper.cpp b/src/qml/qml/v8/qv8stringwrapper.cpp deleted file mode 100644 index 7a4a5fcdb2..0000000000 --- a/src/qml/qml/v8/qv8stringwrapper.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qv8stringwrapper_p.h" -#include "qjsconverter_p.h" -#include "qjsconverter_p.h" - -QT_BEGIN_NAMESPACE - -QV8StringWrapper::QV8StringWrapper() -{ -} - -QV8StringWrapper::~QV8StringWrapper() -{ -} - -void QV8StringWrapper::init() -{ -} - -void QV8StringWrapper::destroy() -{ -} - -v8::Local<v8::String> QV8StringWrapper::toString(const QString &qstr) -{ - return QJSConverter::toString(qstr); -} - -QString QV8StringWrapper::toString(v8::Handle<v8::String> jsstr) -{ - if (jsstr.IsEmpty()) { - return QString(); - } else { - return QJSConverter::toString(jsstr); - } -} - -QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qv8stringwrapper_p.h b/src/qml/qml/v8/qv8stringwrapper_p.h deleted file mode 100644 index 6720e06199..0000000000 --- a/src/qml/qml/v8/qv8stringwrapper_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLV8STRINGWRAPPER_P_H -#define QQMLV8STRINGWRAPPER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <private/qtqmlglobal_p.h> - -#include <QtCore/qstring.h> -#include <private/qv8_p.h> - -QT_BEGIN_NAMESPACE - -class Q_QML_PRIVATE_EXPORT QV8StringWrapper -{ -public: - QV8StringWrapper(); - ~QV8StringWrapper(); - - void init(); - void destroy(); - - v8::Local<v8::String> toString(const QString &); - QString toString(v8::Handle<v8::String>); -}; - -QT_END_NAMESPACE - -#endif // QQMLV8STRINGWRAPPER_P_H diff --git a/src/qml/qml/v8/v8.pri b/src/qml/qml/v8/v8.pri index 43ba33e0fc..faad646e99 100644 --- a/src/qml/qml/v8/v8.pri +++ b/src/qml/qml/v8/v8.pri @@ -4,7 +4,6 @@ HEADERS += \ $$PWD/qv8_p.h \ $$PWD/qv8debug_p.h \ $$PWD/qv8profiler_p.h \ - $$PWD/qv8stringwrapper_p.h \ $$PWD/qv8engine_p.h \ $$PWD/qv8sequencewrapper_p.h \ $$PWD/qv8sequencewrapper_p_p.h \ @@ -26,7 +25,6 @@ HEADERS += \ $$PWD/qv8objectresource_p.h SOURCES += \ - $$PWD/qv8stringwrapper.cpp \ $$PWD/qv8engine.cpp \ $$PWD/qv8sequencewrapper.cpp \ $$PWD/qv8contextwrapper.cpp \ |