1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QV4BINDINGS_P_H
43 #define QV4BINDINGS_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include "private/qqmlexpression_p.h"
57 #include "private/qqmlbinding_p.h"
58 #include "private/qv4instruction_p.h"
59 #include "private/qpointervaluepair_p.h"
66 class QV4Bindings : public QQmlAbstractExpression,
69 Q_DECLARE_TR_FUNCTIONS(QV4Bindings)
71 QV4Bindings(const char *program, QQmlContextData *context,
73 virtual ~QV4Bindings();
75 QQmlAbstractBinding *configBinding(int index, QObject *target,
76 QObject *scope, int property,
77 int line, int column);
79 #ifdef QML_THREADED_INTERPRETER
80 static void **getDecodeInstrTable();
84 Q_DISABLE_COPY(QV4Bindings)
86 struct Binding : public QQmlAbstractBinding, public QQmlDelayedError {
87 Binding() : enabled(false), updating(0), property(0),
88 scope(0), target(0), executedBlocks(0), parent(0) {}
90 // Inherited from QQmlAbstractBinding
91 virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags);
92 virtual void update(QQmlPropertyPrivate::WriteFlags flags);
93 virtual void destroy();
94 virtual int propertyIndex() const;
95 virtual void retargetBinding(QObject *, int);
96 virtual QObject *object() const;
106 // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24)
107 // propType and valueTypeIndex are only set if the property is a value type property
112 QPointerValuePair<QObject, Retarget> target;
113 quint32 executedBlocks;
118 class Subscription : public QQmlNotifierEndpoint
121 Subscription() : bindings(0), method(-1) { callback = &subscriptionCallback; }
122 static void subscriptionCallback(QQmlNotifierEndpoint *e, void**);
123 QV4Bindings *bindings;
126 friend class Subscription;
128 Subscription *subscriptions;
130 void subscriptionNotify(int);
131 void run(Binding *, QQmlPropertyPrivate::WriteFlags flags);
134 QQmlRefCount *dataRef;
138 void run(int instr, quint32 &executedBlocks, QQmlContextData *context,
139 QQmlDelayedError *error, QObject *scope, QObject *output,
140 QQmlPropertyPrivate::WriteFlags storeFlags
141 #ifdef QML_THREADED_INTERPRETER
142 , void ***decode_instr = 0
147 inline void unsubscribe(int subIndex);
148 inline void subscribeId(QQmlContextData *p, int idIndex, int subIndex);
149 inline void subscribe(QObject *o, int notifyIndex, int subIndex);
151 inline static qint32 toInt32(double n);
152 static const double D32;
153 static quint32 toUint32(double n);
161 #endif // QV4BINDINGS_P_H