aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetaattributes.h
blob: 06d5e237283fae7c3b587906d8859878c2ae1c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef ABSTRACTMETAATTRIBUTES_H
#define ABSTRACTMETAATTRIBUTES_H

#include <QtCore/qobjectdefs.h>

QT_FORWARD_DECLARE_CLASS(QDebug)

class AbstractMetaAttributes
{
    Q_GADGET
public:
    AbstractMetaAttributes();
    virtual ~AbstractMetaAttributes();

    enum Attribute {
        None                        = 0x00000000,

        Private                     = 0x00000001,
        Protected                   = 0x00000002,
        Public                      = 0x00000004,
        Friendly                    = 0x00000008,
        Visibility                  = 0x0000000f,

        Abstract                    = 0x00000020,
        Static                      = 0x00000040,

        FinalInTargetLang           = 0x00000080,

        GetterFunction              = 0x00000400,
        SetterFunction              = 0x00000800,

        PropertyReader              = 0x00004000,
        PropertyWriter              = 0x00008000,
        PropertyResetter            = 0x00010000,

        Invokable                   = 0x00040000,

        HasRejectedConstructor      = 0x00080000,
        HasRejectedDefaultConstructor = 0x00100000,

        FinalCppClass               = 0x00200000,
        VirtualCppMethod            = 0x00400000,
        OverriddenCppMethod         = 0x00800000,
        FinalCppMethod              = 0x01000000,
        // Add by meta builder (implicit constructors, inherited methods, etc)
        AddedMethod                 = 0x02000000,
        Deprecated                  = 0x04000000
    };
    Q_DECLARE_FLAGS(Attributes, Attribute)
    Q_FLAG(Attribute)

    Attributes attributes() const { return m_attributes; }

    void setAttributes(Attributes attributes) { m_attributes = attributes; }

    Attributes originalAttributes() const { return m_originalAttributes; }

    void setOriginalAttributes(Attributes attributes) { m_originalAttributes = attributes; }

    Attributes visibility() const { return m_attributes & Visibility; }

    void setVisibility(Attributes visi)
    {
        m_attributes = (m_attributes & ~Visibility) | visi;
    }

    void operator+=(Attribute attribute)
    {
        m_attributes |= attribute;
    }

    void operator-=(Attribute attribute)
    {
        m_attributes &= ~attribute;
    }

    bool isFinalInTargetLang() const
    {
        return m_attributes.testFlag(FinalInTargetLang);
    }

    bool isAbstract() const
    {
        return m_attributes.testFlag(Abstract);
    }

    bool isStatic() const
    {
        return m_attributes.testFlag(Static);
    }

    bool isInvokable() const
    {
        return m_attributes.testFlag(Invokable);
    }

    bool isPropertyReader() const
    {
        return m_attributes.testFlag(PropertyReader);
    }

    bool isPropertyWriter() const
    {
        return m_attributes.testFlag(PropertyWriter);
    }

    bool isPropertyResetter() const
    {
        return m_attributes.testFlag(PropertyResetter);
    }

    bool isPrivate() const
    {
        return m_attributes.testFlag(Private);
    }

    bool isProtected() const
    {
        return m_attributes.testFlag(Protected);
    }

    bool isPublic() const
    {
        return m_attributes.testFlag(Public);
    }

    bool isFriendly() const
    {
        return m_attributes.testFlag(Friendly);
    }

    bool wasPrivate() const
    {
        return m_originalAttributes.testFlag(Private);
    }

    bool wasPublic() const
    {
        return m_originalAttributes.testFlag(Public);
    }

#ifndef QT_NO_DEBUG_STREAM
    static void formatMetaAttributes(QDebug &d, AbstractMetaAttributes::Attributes value);
#endif

protected:
    void assignMetaAttributes(const AbstractMetaAttributes &other);

private:
    Attributes m_attributes;
    Attributes m_originalAttributes;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaAttributes::Attributes)

#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const AbstractMetaAttributes *aa);
#endif

#endif // ABSTRACTMETAATTRIBUTES_H