From d8131513b07d3f0a6d749c9961b294fc955fed6d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 14 Jan 2015 12:50:34 +0100 Subject: Add C++11 move operators, and a simpler internal constructor Move semantics should optimize some copy operations on QJSValues, and the internal constructor will simplify refactoring the QJSValue class to get rid of the extra allocated private. Change-Id: I24863b30523af2432aa81ad6b87fda7fe35749c4 Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsengine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/qml/jsapi/qjsengine.cpp') diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index d54af28f26..e82849746f 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -317,7 +317,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in result = v4->catchException(); if (ctx->d() != v4->rootContext()) v4->popContext(); - return new QJSValuePrivate(v4, result); + return QJSValue(v4, result.asReturnedValue()); } /*! @@ -332,7 +332,7 @@ QJSValue QJSEngine::newObject() { QV4::Scope scope(d->m_v4Engine); QV4::ScopedValue v(scope, d->m_v4Engine->newObject()); - return new QJSValuePrivate(d->m_v4Engine, v); + return QJSValue(d->m_v4Engine, v.asReturnedValue()); } /*! @@ -347,7 +347,7 @@ QJSValue QJSEngine::newArray(uint length) if (length < 0x1000) array->arrayReserve(length); array->setArrayLengthUnchecked(length); - return new QJSValuePrivate(d->m_v4Engine, array); + return QJSValue(d->m_v4Engine, array.asReturnedValue()); } /*! @@ -381,7 +381,7 @@ QJSValue QJSEngine::newQObject(QObject *object) QQmlEngine::setObjectOwnership(object, QQmlEngine::JavaScriptOwnership); } QV4::ScopedValue v(scope, QV4::QObjectWrapper::wrap(v4, object)); - return new QJSValuePrivate(v4, v); + return QJSValue(v4, v.asReturnedValue()); } /*! @@ -399,7 +399,7 @@ QJSValue QJSEngine::globalObject() const Q_D(const QJSEngine); QV4::Scope scope(d->m_v4Engine); QV4::ScopedValue v(scope, d->m_v4Engine->globalObject()); - return new QJSValuePrivate(d->m_v4Engine, v); + return QJSValue(d->m_v4Engine, v.asReturnedValue()); } /*! @@ -411,7 +411,7 @@ QJSValue QJSEngine::create(int type, const void *ptr) Q_D(QJSEngine); QV4::Scope scope(d->m_v4Engine); QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(type, ptr)); - return new QJSValuePrivate(d->m_v4Engine, v); + return QJSValue(d->m_v4Engine, v.asReturnedValue()); } /*! -- cgit v1.2.3