diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-10 13:52:34 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-12 01:31:11 +0200 |
commit | 0466acb02740b5dbf3254d6445186b4d3ccd0699 (patch) | |
tree | a1b7314c2faae73cf93403afdc7ca92f2106d70d /src/declarative/qml/v4/qdeclarativev4bindings_p.h | |
parent | 3422d4adda7480a44a063ab86447c2fe2792fe02 (diff) |
Optimize signal handling
Bindings connect to lots of signals that are never emitted. By managing
signal connection lists ourselves, we can do a much better job than Qt's
generic signal/slot connection logic.
Also, by connecting to QDeclarativeNotifierEndpoint's rather than QObject
slots, we can eliminate the need to instantiate a QObject for the V4 and
V8 binding managers.
Change-Id: I598667deaefdbd2860227bd74378a1b196761686
Reviewed-on: http://codereview.qt-project.org/6278
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Sanity-Review: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml/v4/qdeclarativev4bindings_p.h')
-rw-r--r-- | src/declarative/qml/v4/qdeclarativev4bindings_p.h | 70 |
1 files changed, 62 insertions, 8 deletions
diff --git a/src/declarative/qml/v4/qdeclarativev4bindings_p.h b/src/declarative/qml/v4/qdeclarativev4bindings_p.h index c0345ea3c4..d69d75b835 100644 --- a/src/declarative/qml/v4/qdeclarativev4bindings_p.h +++ b/src/declarative/qml/v4/qdeclarativev4bindings_p.h @@ -61,28 +61,82 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QDeclarativeV4BindingsPrivate; -class QDeclarativeV4Bindings : public QObject, - public QDeclarativeAbstractExpression, +class QDeclarativeV4Program; +class QDeclarativeV4Bindings : public QDeclarativeAbstractExpression, public QDeclarativeRefCount { + Q_DECLARE_TR_FUNCTIONS(QDeclarativeV4Bindings) public: QDeclarativeV4Bindings(const char *program, QDeclarativeContextData *context, QDeclarativeRefCount *); virtual ~QDeclarativeV4Bindings(); - QDeclarativeAbstractBinding *configBinding(int index, QObject *target, QObject *scope, int property); + QDeclarativeAbstractBinding *configBinding(int index, QObject *target, + QObject *scope, int property); #ifdef QML_THREADED_INTERPRETER static void **getDecodeInstrTable(); #endif -protected: - int qt_metacall(QMetaObject::Call, int, void **); - private: Q_DISABLE_COPY(QDeclarativeV4Bindings) - Q_DECLARE_PRIVATE(QDeclarativeV4Bindings) + + struct Binding : public QDeclarativeAbstractBinding, public QDeclarativeDelayedError { + Binding() : enabled(false), updating(0), property(0), + scope(0), target(0), executedBlocks(0), parent(0) {} + + // Inherited from QDeclarativeAbstractBinding + virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags); + virtual void update(QDeclarativePropertyPrivate::WriteFlags flags); + virtual void destroy(); + + int index:30; + bool enabled:1; + bool updating:1; + int property; + QObject *scope; + QObject *target; + quint32 executedBlocks; + + QDeclarativeV4Bindings *parent; + }; + + struct Subscription : public QDeclarativeNotifierEndpoint + { + Subscription() : bindings(0), method(-1) { callback = &subscriptionCallback; } + static void subscriptionCallback(QDeclarativeNotifierEndpoint *e); + QDeclarativeV4Bindings *bindings; + int method; + }; + friend class Subscription; + + Subscription *subscriptions; + + void subscriptionNotify(int); + void run(Binding *, QDeclarativePropertyPrivate::WriteFlags flags); + + QDeclarativeV4Program *program; + QDeclarativeRefCount *dataRef; + Binding *bindings; + + void init(); + void run(int instr, quint32 &executedBlocks, QDeclarativeContextData *context, + QDeclarativeDelayedError *error, QObject *scope, QObject *output, + QDeclarativePropertyPrivate::WriteFlags storeFlags +#ifdef QML_THREADED_INTERPRETER + , void ***decode_instr = 0 +#endif + ); + + + inline void unsubscribe(int subIndex); + inline void subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex); + inline void subscribe(QObject *o, int notifyIndex, int subIndex); + + inline static qint32 toInt32(qreal n); + static const qreal D32; + static quint32 toUint32(qreal n); + }; QT_END_NAMESPACE |