diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-04-16 10:29:29 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-27 06:33:27 +0000 |
commit | 0e14a46f60124d9da1101fe7766c7d85e2b72e64 (patch) | |
tree | efb39fcd3950619220bb927c84c174718e38415c | |
parent | f8a104432051d182dfc880cea0d4931fcd229204 (diff) |
Move m_function into the base class
Change-Id: I2ebc0ac8f5085157f5d1ec71a1b75559c6a46f8b
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 7 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlexpression.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlexpression_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 11 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 6 |
8 files changed, 17 insertions, 22 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 2110c8a05e..cfcca18d37 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -191,7 +191,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) bool isUndefined = false; - QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(f, &isUndefined)); + QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(&isUndefined)); bool needsErrorLocationData = false; if (!watcher.wasDeleted() && !hasError()) @@ -225,13 +225,12 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) QVariant QQmlBinding::evaluate() { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); - QV4::Scope scope(ep->v4engine()); ep->referenceScarceResources(); bool isUndefined = false; - QV4::ScopedValue f(scope, m_function.value()); - QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(f, &isUndefined)); + QV4::Scope scope(ep->v4engine()); + QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(&isUndefined)); ep->dereferenceScarceResources(); diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index c11f3255d2..6ffb5a756a 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -102,8 +102,6 @@ protected: ~QQmlBinding(); private: - QV4::PersistentValue m_function; - inline bool updatingFlag() const; inline void setUpdatingFlag(bool); inline bool enabledFlag() const; diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 5cfccd2f80..77dccf6f04 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -84,10 +84,11 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function) : QQmlJavaScriptExpression(), m_index(index), - m_function(function.as<QV4::Object>()->engine(), function), m_target(target), m_extra(0) { + m_function.set(function.as<QV4::Object>()->engine(), function); + setExpressionFunctionValid(true); setInvalidParameterName(false); @@ -248,7 +249,6 @@ void QQmlBoundSignalExpression::evaluate(void **a) int *argsTypes = QQmlMetaObject(m_target).methodParameterTypes(methodIndex, dummy, 0); int argCount = argsTypes ? *argsTypes : 0; - QV4::ScopedValue f(scope, m_function.value()); QV4::ScopedCallData callData(scope, argCount); for (int ii = 0; ii < argCount; ++ii) { int type = argsTypes[ii + 1]; @@ -272,7 +272,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) } } - QQmlJavaScriptExpression::evaluate(f, callData, 0); + QQmlJavaScriptExpression::evaluate(callData, 0); } ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index fb9c878fd2..bc30b25d6a 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -98,8 +98,6 @@ private: void setInvalidParameterName(bool v) { m_extra.setFlag2Value(v); } int m_index; - QV4::PersistentValue m_function; - QObject *m_target; // only needed when !expressionFunctionValid() diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index e6fbbd491d..3813281044 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -250,9 +250,7 @@ QV4::ReturnedValue QQmlExpressionPrivate::v4value(bool *isUndefined) expressionFunctionValid = true; } - QV4::Scope scope(v4); - QV4::ScopedValue f(scope, m_function.value()); - return evaluate(f, isUndefined); + return evaluate(isUndefined); } QVariant QQmlExpressionPrivate::value(bool *isUndefined) diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h index e179fe35b9..0419c9c11c 100644 --- a/src/qml/qml/qqmlexpression_p.h +++ b/src/qml/qml/qqmlexpression_p.h @@ -87,7 +87,6 @@ public: QString expression; QV4::PersistentValue qmlscope; - QV4::PersistentValue m_function; QString url; // This is a QString for a reason. QUrls are slooooooow... quint16 line; diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 12594ae43a..cc57d855c3 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -140,20 +140,21 @@ void QQmlJavaScriptExpression::refresh() { } -QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(const QV4::Value &function, bool *isUndefined) +QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(bool *isUndefined) { QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_context->engine); QV4::Scope scope(v4); QV4::ScopedCallData callData(scope); - return evaluate(function, callData, isUndefined); + return evaluate(callData, isUndefined); } -QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(const QV4::Value &function, QV4::CallData *callData, bool *isUndefined) +QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefined) { Q_ASSERT(m_context && m_context->engine); - if (function.isUndefined()) { + QV4::Value *f = m_function.valueRef(); + if (!f || f->isUndefined()) { if (isUndefined) *isUndefined = true; return QV4::Encode::undefined(); @@ -185,7 +186,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(const QV4::Value &function callData->thisObject = value; } - result = function.as<QV4::FunctionObject>()->call(callData); + result = f->as<QV4::FunctionObject>()->call(callData); if (scope.hasException()) { if (watcher.wasDeleted()) scope.engine->catchException(); // ignore exception diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 80b9089f26..f846b6570f 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -98,8 +98,8 @@ public: virtual QString expressionIdentifier() = 0; virtual void expressionChanged() = 0; - QV4::ReturnedValue evaluate(const QV4::Value &function, bool *isUndefined); - QV4::ReturnedValue evaluate(const QV4::Value &function, QV4::CallData *callData, bool *isUndefined); + QV4::ReturnedValue evaluate(bool *isUndefined); + QV4::ReturnedValue evaluate(QV4::CallData *callData, bool *isUndefined); inline bool notifyOnValueChanged() const; @@ -181,6 +181,8 @@ private: QQmlJavaScriptExpression **m_prevExpression; QQmlJavaScriptExpression *m_nextExpression; +protected: + QV4::PersistentValue m_function; }; QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e) |