aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmljavascriptexpression.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-12-02 09:50:36 +0100
committerLars Knoll <lars.knoll@qt.io>2016-12-09 14:01:23 +0000
commitf9b8436a07534867686627b656418d62f75ba3e5 (patch)
tree896411a3196df42ebfda4e61b9335dabf01958e8 /src/qml/qml/qqmljavascriptexpression.cpp
parentd7ef2aa02c9ba736104fe973bfce7d87e30f81af (diff)
Mostly use the QV4::Function in javascript expressions
Move the function() accessor from QQmlBoundSIgnal to QQmlJavaScriptExpression. Change the profiler to operate on QV4::Function objects for binding profiling. Change-Id: Ic7ce83c487ceb69cad4b16e3dab42026238b7e82 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression.cpp')
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index f81320aa6b..a694b43447 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -48,6 +48,7 @@
#include <private/qv4scopedvalue_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qqmlbuiltinfunctions_p.h>
QT_BEGIN_NAMESPACE
@@ -131,6 +132,9 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const
{
return m_function.valueRef()->as<QV4::FunctionObject>()->sourceLocation();
+ // Can't use the below yet, as the source location for bindings gnerated with Qt.binding() would be wrong.
+// auto f = function();
+// return f ? f->sourceLocation() : QQmlSourceLocation();
}
void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
@@ -154,6 +158,14 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
}
}
+QV4::Function *QQmlJavaScriptExpression::function() const
+{
+ QV4::FunctionObject *f = m_function.valueRef()->as<QV4::FunctionObject>();
+ if (f && f->isBinding())
+ return static_cast<QV4::QQmlBindingFunction *>(f)->d()->originalFunction->function;
+ return f ? f->function() : 0;
+}
+
void QQmlJavaScriptExpression::refresh()
{
}