1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQml module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQMLBOUNDSIGNAL_P_H
41#define QQMLBOUNDSIGNAL_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtCore/qmetaobject.h>
55
56#include <private/qqmljavascriptexpression_p.h>
57#include <private/qqmlboundsignalexpressionpointer_p.h>
58#include <private/qqmlnotifier_p.h>
59#include <private/qflagpointer_p.h>
60#include <private/qqmlrefcount_p.h>
61#include <private/qqmlglobal_p.h>
62#include <private/qbitfield_p.h>
63
64QT_BEGIN_NAMESPACE
65
66class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpression : public QQmlJavaScriptExpression, public QQmlRefCount
67{
68public:
69 QQmlBoundSignalExpression(QObject *target, int index,
70 QQmlContextData *ctxt, QObject *scope, const QString &expression,
71 const QString &fileName, quint16 line, quint16 column,
72 const QString &handlerName = QString(),
73 const QString &parameterString = QString());
74
75 QQmlBoundSignalExpression(QObject *target, int index,
76 QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function,
77 QV4::ExecutionContext *scope = nullptr);
78
79 // inherited from QQmlJavaScriptExpression.
80 QString expressionIdentifier() const override;
81 void expressionChanged() override;
82
83 // evaluation of a bound signal expression doesn't return any value
84 void evaluate(void **a);
85 void evaluate(const QList<QVariant> &args);
86
87 QString expression() const;
88 QObject *target() const { return m_target; }
89
90 QQmlEngine *engine() const { return context() ? context()->engine : nullptr; }
91
92private:
93 ~QQmlBoundSignalExpression() override;
94
95 void init(QQmlContextData *ctxt, QObject *scope);
96
97 bool expressionFunctionValid() const { return function() != nullptr; }
98
99 int m_index;
100 QObject *m_target;
101};
102
103class Q_QML_PRIVATE_EXPORT QQmlBoundSignal : public QQmlNotifierEndpoint
104{
105public:
106 QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine);
107 ~QQmlBoundSignal();
108
109 void removeFromObject();
110
111 QQmlBoundSignalExpression *expression() const;
112 void takeExpression(QQmlBoundSignalExpression *);
113
114 void setEnabled(bool enabled);
115
116private:
117 friend void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **);
118 friend class QQmlPropertyPrivate;
119 friend class QQmlData;
120 friend class QQmlEngineDebugService;
121
122 void addToObject(QObject *owner);
123
124 QQmlBoundSignal **m_prevSignal;
125 QQmlBoundSignal *m_nextSignal;
126
127 bool m_enabled;
128
129 QQmlBoundSignalExpressionPointer m_expression;
130};
131
132QT_END_NAMESPACE
133
134#endif // QQMLBOUNDSIGNAL_P_H
135

source code of qtdeclarative/src/qml/qml/qqmlboundsignal_p.h