diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-23 22:56:38 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-24 12:39:34 +0200 |
commit | 1d62cefbaa23ef96fa4dc36d950cc2d9a2d4b5c3 (patch) | |
tree | 114eb77af818b37b05801498f9e4e3e4c482d7e1 /src/qml/qml/qqmlbinding.cpp | |
parent | fa2d572d5d202b05ed1908ea1119a1995960ce1f (diff) |
Add support for direct binding evaluation in QV4Script
This way there is no need to rewrite the binding expressions
anymore, instead we can directly compile them into a
binding function.
Change-Id: I91a0c540d066976e363590fe9ccde6a81ee92b1d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlbinding.cpp')
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index b66f053b0f..936c63f35e 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -108,11 +108,8 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContext *ctxt) QQmlAbstractExpression::setContext(QQmlContextData::get(ctxt)); setScopeObject(obj); - QQmlRewrite::RewriteBinding rewriteBinding; - QString code = rewriteBinding(str); - m_expression = str.toUtf8(); - v4function = evalFunction(context(), obj, code, QString(), 0); + v4function = qmlBinding(context(), obj, str, QString(), 0); } QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt) @@ -146,11 +143,6 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte } } - if (needRewrite) { - QQmlRewrite::RewriteBinding rewriteBinding; - code = rewriteBinding(scriptPrivate->script); - } - setNotifyOnValueChanged(true); QQmlAbstractExpression::setContext(QQmlContextData::get(ctxt ? ctxt : scriptPrivate->context)); setScopeObject(obj ? obj : scriptPrivate->scope); @@ -159,7 +151,10 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte m_lineNumber = scriptPrivate->lineNumber; m_columnNumber = scriptPrivate->columnNumber; - v4function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber); + if (needRewrite) + v4function = qmlBinding(context(), scopeObject(), code, QString(), m_lineNumber); + else + v4function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber); } QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt) @@ -170,11 +165,8 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt QQmlAbstractExpression::setContext(ctxt); setScopeObject(obj); - QQmlRewrite::RewriteBinding rewriteBinding; - QString code = rewriteBinding(str); - m_expression = str.toUtf8(); - v4function = evalFunction(ctxt, obj, code, QString(), 0); + v4function = qmlBinding(ctxt, obj, str, QString(), 0); } QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj, @@ -187,17 +179,12 @@ QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj, QQmlAbstractExpression::setContext(ctxt); setScopeObject(obj); - QString code; - if (isRewritten) { - code = str; - } else { - QQmlRewrite::RewriteBinding rewriteBinding; - code = rewriteBinding(str); - } - m_expression = str.toUtf8(); - v4function = evalFunction(ctxt, obj, code, url, m_lineNumber); + if (isRewritten) + v4function = evalFunction(ctxt, obj, str, url, m_lineNumber); + else + v4function = qmlBinding(ctxt, obj, str, url, m_lineNumber); } /*! |