aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsvalue.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-14 12:50:34 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-21 18:22:47 +0100
commitd8131513b07d3f0a6d749c9961b294fc955fed6d (patch)
tree8d757fffe19623bd1ea78a40240dc41c25b81a8f /src/qml/jsapi/qjsvalue.cpp
parent630f118f043edb88501e387d779c62c86b1030d4 (diff)
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsapi/qjsvalue.cpp')
-rw-r--r--src/qml/jsapi/qjsvalue.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 0a29e7802c..479a2d0901 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -172,8 +172,11 @@ QJSValue::QJSValue(bool value)
{
}
-QJSValue::QJSValue(QJSValuePrivate *dd)
- : d(dd)
+/*!
+ \internal
+*/
+QJSValue::QJSValue(ExecutionEngine *e, quint64 val)
+ : d(new QJSValuePrivate(e, val))
{
}
@@ -255,7 +258,8 @@ QJSValue::QJSValue(const QJSValue& other)
*/
QJSValue::~QJSValue()
{
- d->deref();
+ if (d)
+ d->deref();
}
/*!
@@ -642,7 +646,7 @@ QJSValue QJSValue::call(const QJSValueList &args)
if (engine->hasException)
result = engine->catchException();
- return new QJSValuePrivate(engine, result);
+ return QJSValue(engine, result.asReturnedValue());
}
/*!
@@ -697,7 +701,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
if (engine->hasException)
result = engine->catchException();
- return new QJSValuePrivate(engine, result);
+ return QJSValue(engine, result.asReturnedValue());
}
/*!
@@ -744,7 +748,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
if (engine->hasException)
result = engine->catchException();
- return new QJSValuePrivate(engine, result);
+ return QJSValue(engine, result.asReturnedValue());
}
#ifdef QT_DEPRECATED
@@ -785,7 +789,7 @@ QJSValue QJSValue::prototype() const
ScopedObject p(scope, o->prototype());
if (!p)
return QJSValue(NullValue);
- return new QJSValuePrivate(o->internalClass()->engine, p);
+ return QJSValue(o->internalClass()->engine, p.asReturnedValue());
}
/*!
@@ -979,7 +983,7 @@ QJSValue QJSValue::property(const QString& name) const
if (engine->hasException)
result = engine->catchException();
- return new QJSValuePrivate(engine, result);
+ return QJSValue(engine, result.asReturnedValue());
}
/*!
@@ -1008,7 +1012,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex));
if (engine->hasException)
engine->catchException();
- return new QJSValuePrivate(engine, result);
+ return QJSValue(engine, result.asReturnedValue());
}
/*!