aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlboundsignal_p.h
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-05-21 09:27:43 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-24 00:55:55 +0200
commit0853343c33e394f35c31c161b019b2aed17f9256 (patch)
tree3f792f58979ae75f8e75a0c0ef6e7f89265b1c16 /src/qml/qml/qqmlboundsignal_p.h
parent9ee6bb0e14d968647350683eafbe80eed7a27058 (diff)
Avoid dynamic lookup of signal handler arguments
Rewrite signal handlers to include the parameters in the rewrite. Also check whether parameters are actually used when possible, and if not don't provide them to the expression. Change-Id: I7d65c05f4639979dd61035cf7478119ef7647c25 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlboundsignal_p.h')
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 879b84294c..cdef579b09 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -62,35 +62,43 @@
#include <private/qflagpointer_p.h>
#include <private/qqmlrefcount_p.h>
#include <private/qqmlglobal_p.h>
-#include <private/qobject_p.h>
+#include <private/qbitfield_p.h>
QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpression : public QQmlAbstractExpression, public QQmlJavaScriptExpression, public QQmlRefCount
{
public:
- QQmlBoundSignalExpression(QQmlContextData *ctxt, QObject *scope, const QByteArray &expression,
+ QQmlBoundSignalExpression(QObject *target, int index,
+ QQmlContextData *ctxt, QObject *scope, const QByteArray &expression,
bool isRewritten, const QString &fileName, quint16 line, quint16 column);
- QQmlBoundSignalExpression(QQmlContextData *ctxt, QObject *scope, const QString &expression,
+ QQmlBoundSignalExpression(QObject *target, int index,
+ QQmlContextData *ctxt, QObject *scope, const QString &expression,
bool isRewritten, const QString &fileName, quint16 line, quint16 column);
// "inherited" from QQmlJavaScriptExpression.
static QString expressionIdentifier(QQmlJavaScriptExpression *);
static void expressionChanged(QQmlJavaScriptExpression *);
+ void setParameterCountForJS(int count) { m_parameterCountForJS = count; }
+
// evaluation of a bound signal expression doesn't return any value
- void evaluate(QObject *secondaryScope = 0);
+ void evaluate(void **a);
QString sourceFile() const { return m_fileName; }
quint16 lineNumber() const { return m_line; }
quint16 columnNumber() const { return m_column; }
QString expression() const;
+ QObject *target() const { return m_target; }
QQmlEngine *engine() const { return context() ? context()->engine : 0; }
private:
~QQmlBoundSignalExpression();
+ void init(QQmlContextData *ctxt, QObject *scope);
+ bool hasParameterInfo() const { return m_parameterCountForJS > 0; }
+
v8::Persistent<v8::Object> m_v8qmlscope;
v8::Persistent<v8::Function> m_v8function;
@@ -99,13 +107,18 @@ private:
//extract it from m_v8function if needed.
QByteArray m_expressionUtf8;
QString m_expression; //only used when expression needs to be rewritten
-
QString m_fileName;
quint16 m_line;
quint16 m_column;
+ int m_parameterCountForJS;
+
+ QObject *m_target;
+ int m_index;
+
bool m_expressionFunctionValid:1;
bool m_expressionFunctionRewritten:1;
+ bool m_invalidParameterName:1;
};
class Q_QML_PRIVATE_EXPORT QQmlAbstractBoundSignal
@@ -118,7 +131,6 @@ public:
virtual QQmlBoundSignalExpression *expression() const = 0;
virtual QQmlBoundSignalExpressionPointer setExpression(QQmlBoundSignalExpression *) = 0;
virtual QQmlBoundSignalExpressionPointer takeExpression(QQmlBoundSignalExpression *) = 0;
- virtual QObject *scope() = 0;
virtual bool isEvaluating() const = 0;
void removeFromObject();
@@ -133,12 +145,11 @@ private:
QQmlAbstractBoundSignal *m_nextSignal;
};
-class QQmlBoundSignalParameters;
class Q_QML_PRIVATE_EXPORT QQmlBoundSignal : public QQmlAbstractBoundSignal,
public QQmlNotifierEndpoint
{
public:
- QQmlBoundSignal(QObject *scope, int signal, QObject *owner, QQmlEngine *engine);
+ QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine);
virtual ~QQmlBoundSignal();
int index() const;
@@ -146,27 +157,17 @@ public:
QQmlBoundSignalExpression *expression() const;
QQmlBoundSignalExpressionPointer setExpression(QQmlBoundSignalExpression *);
QQmlBoundSignalExpressionPointer takeExpression(QQmlBoundSignalExpression *);
- QObject *scope() { return *m_scope; }
- bool isEvaluating() const { return m_scope.flag(); }
+ bool isEvaluating() const { return m_isEvaluating; }
private:
friend void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **);
QQmlBoundSignalExpressionPointer m_expression;
- QQmlBoundSignalParameters *m_params;
- // We store some flag bits in the following flag pointer.
- // m_scope:flag1 - m_isEvaluating
- // m_scope:flag2 - m_paramsValid
- QFlagPointer<QObject> m_scope;
int m_index;
-
- void setIsEvaluating(bool v) { m_scope.setFlagValue(v); }
- void setParamsValid(bool v) { m_scope.setFlag2Value(v); }
- bool paramsValid() const { return m_scope.flag2(); }
+ bool m_isEvaluating;
};
-
QT_END_NAMESPACE
#endif // QQMLBOUNDSIGNAL_P_H