| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2019 The Qt Company Ltd. |
| 4 | ** Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> |
| 5 | ** Contact: https://www.qt.io/licensing/ |
| 6 | ** |
| 7 | ** This file is part of the QtCore module of the Qt Toolkit. |
| 8 | ** |
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 10 | ** Commercial License Usage |
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 12 | ** accordance with the commercial license agreement provided with the |
| 13 | ** Software or, alternatively, in accordance with the terms contained in |
| 14 | ** a written agreement between you and The Qt Company. For licensing terms |
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 16 | ** information use the contact form at https://www.qt.io/contact-us. |
| 17 | ** |
| 18 | ** GNU Lesser General Public License Usage |
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 20 | ** General Public License version 3 as published by the Free Software |
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 22 | ** packaging of this file. Please review the following information to |
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 25 | ** |
| 26 | ** GNU General Public License Usage |
| 27 | ** Alternatively, this file may be used under the terms of the GNU |
| 28 | ** General Public License version 2.0 or (at your option) the GNU General |
| 29 | ** Public license version 3 or any later version approved by the KDE Free |
| 30 | ** Qt Foundation. The licenses are as published by the Free Software |
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 32 | ** included in the packaging of this file. Please review the following |
| 33 | ** information to ensure the GNU General Public License requirements will |
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 36 | ** |
| 37 | ** $QT_END_LICENSE$ |
| 38 | ** |
| 39 | ****************************************************************************/ |
| 40 | |
| 41 | #ifndef QTMETAMACROS_H |
| 42 | #define QTMETAMACROS_H |
| 43 | |
| 44 | #include <QtCore/qglobal.h> |
| 45 | |
| 46 | QT_BEGIN_NAMESPACE |
| 47 | |
| 48 | #ifndef Q_MOC_OUTPUT_REVISION |
| 49 | #define Q_MOC_OUTPUT_REVISION 68 |
| 50 | #endif |
| 51 | |
| 52 | // The following macros can be defined by tools that understand Qt |
| 53 | // to have the information from the macro. |
| 54 | #ifndef QT_ANNOTATE_CLASS |
| 55 | # define QT_ANNOTATE_CLASS(type, ...) |
| 56 | #endif |
| 57 | #ifndef QT_ANNOTATE_CLASS2 |
| 58 | # define QT_ANNOTATE_CLASS2(type, a1, a2) |
| 59 | #endif |
| 60 | #ifndef QT_ANNOTATE_FUNCTION |
| 61 | # define QT_ANNOTATE_FUNCTION(x) |
| 62 | #endif |
| 63 | #ifndef QT_ANNOTATE_ACCESS_SPECIFIER |
| 64 | # define QT_ANNOTATE_ACCESS_SPECIFIER(x) |
| 65 | #endif |
| 66 | |
| 67 | // The following macros are our "extensions" to C++ |
| 68 | // They are used, strictly speaking, only by the moc. |
| 69 | |
| 70 | #ifndef Q_MOC_RUN |
| 71 | #ifndef QT_NO_META_MACROS |
| 72 | # if defined(QT_NO_KEYWORDS) |
| 73 | # define QT_NO_EMIT |
| 74 | # else |
| 75 | # ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS |
| 76 | # define slots Q_SLOTS |
| 77 | # define signals Q_SIGNALS |
| 78 | # endif |
| 79 | # endif |
| 80 | # define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) |
| 81 | # define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) |
| 82 | # define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) |
| 83 | # define Q_EMIT |
| 84 | #ifndef QT_NO_EMIT |
| 85 | # define emit |
| 86 | #endif |
| 87 | #ifndef Q_CLASSINFO |
| 88 | # define Q_CLASSINFO(name, value) |
| 89 | #endif |
| 90 | #define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) |
| 91 | #define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) |
| 92 | #define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) |
| 93 | #define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) |
| 94 | #ifndef Q_REVISION |
| 95 | # define Q_REVISION(...) |
| 96 | #endif |
| 97 | #define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) |
| 98 | #define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) |
| 99 | #define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) |
| 100 | #define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) |
| 101 | #define Q_ENUM_IMPL(ENUM) \ |
| 102 | friend constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ |
| 103 | friend constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } |
| 104 | #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) |
| 105 | #define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) |
| 106 | #define Q_ENUM_NS_IMPL(ENUM) \ |
| 107 | inline constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ |
| 108 | inline constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } |
| 109 | #define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) |
| 110 | #define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) |
| 111 | #define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) |
| 112 | #define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) |
| 113 | #define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) |
| 114 | #define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) |
| 115 | #define Q_MOC_INCLUDE(...) QT_ANNOTATE_CLASS(qt_moc_include, __VA_ARGS__) |
| 116 | #endif // QT_NO_META_MACROS |
| 117 | |
| 118 | #ifndef QT_NO_TRANSLATION |
| 119 | // full set of tr functions |
| 120 | # define QT_TR_FUNCTIONS \ |
| 121 | static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \ |
| 122 | { return staticMetaObject.tr(s, c, n); } |
| 123 | #else |
| 124 | // inherit the ones from QObject |
| 125 | # define QT_TR_FUNCTIONS |
| 126 | #endif |
| 127 | |
| 128 | #ifdef Q_CLANG_QDOC |
| 129 | #define QT_TR_FUNCTIONS |
| 130 | #endif |
| 131 | |
| 132 | #if defined(Q_CC_INTEL) |
| 133 | // Cannot redefine the visibility of a method in an exported class |
| 134 | # define Q_DECL_HIDDEN_STATIC_METACALL |
| 135 | #else |
| 136 | # define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN |
| 137 | #endif |
| 138 | |
| 139 | #if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 |
| 140 | # define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") |
| 141 | #elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 |
| 142 | # define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") |
| 143 | #else |
| 144 | # define Q_OBJECT_NO_OVERRIDE_WARNING |
| 145 | #endif |
| 146 | |
| 147 | #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 |
| 148 | # define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") |
| 149 | #else |
| 150 | # define Q_OBJECT_NO_ATTRIBUTES_WARNING |
| 151 | #endif |
| 152 | |
| 153 | /* qmake ignore Q_OBJECT */ |
| 154 | #define Q_OBJECT \ |
| 155 | public: \ |
| 156 | QT_WARNING_PUSH \ |
| 157 | Q_OBJECT_NO_OVERRIDE_WARNING \ |
| 158 | static const QMetaObject staticMetaObject; \ |
| 159 | virtual const QMetaObject *metaObject() const; \ |
| 160 | virtual void *qt_metacast(const char *); \ |
| 161 | virtual int qt_metacall(QMetaObject::Call, int, void **); \ |
| 162 | QT_TR_FUNCTIONS \ |
| 163 | private: \ |
| 164 | Q_OBJECT_NO_ATTRIBUTES_WARNING \ |
| 165 | Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ |
| 166 | QT_WARNING_POP \ |
| 167 | struct QPrivateSignal {}; \ |
| 168 | QT_ANNOTATE_CLASS(qt_qobject, "") |
| 169 | |
| 170 | /* qmake ignore Q_OBJECT */ |
| 171 | #define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") |
| 172 | |
| 173 | #ifndef QT_NO_META_MACROS |
| 174 | /* qmake ignore Q_GADGET */ |
| 175 | #define Q_GADGET \ |
| 176 | public: \ |
| 177 | static const QMetaObject staticMetaObject; \ |
| 178 | void qt_check_for_QGADGET_macro(); \ |
| 179 | typedef void QtGadgetHelper; \ |
| 180 | private: \ |
| 181 | QT_WARNING_PUSH \ |
| 182 | Q_OBJECT_NO_ATTRIBUTES_WARNING \ |
| 183 | Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ |
| 184 | QT_WARNING_POP \ |
| 185 | QT_ANNOTATE_CLASS(qt_qgadget, "") \ |
| 186 | /*end*/ |
| 187 | |
| 188 | /* qmake ignore Q_NAMESPACE_EXPORT */ |
| 189 | #define Q_NAMESPACE_EXPORT(...) \ |
| 190 | extern __VA_ARGS__ const QMetaObject staticMetaObject; \ |
| 191 | QT_ANNOTATE_CLASS(qt_qnamespace, "") \ |
| 192 | /*end*/ |
| 193 | |
| 194 | /* qmake ignore Q_NAMESPACE */ |
| 195 | #define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ |
| 196 | /*end*/ |
| 197 | |
| 198 | #endif // QT_NO_META_MACROS |
| 199 | |
| 200 | #else // Q_MOC_RUN |
| 201 | #define slots slots |
| 202 | #define signals signals |
| 203 | #define Q_SLOTS Q_SLOTS |
| 204 | #define Q_SIGNALS Q_SIGNALS |
| 205 | #define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) |
| 206 | #define Q_INTERFACES(x) Q_INTERFACES(x) |
| 207 | #define Q_PROPERTY(text) Q_PROPERTY(text) |
| 208 | #define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) |
| 209 | #define Q_PRIVATE_QPROPERTY(accessor, type, name, setter, ...) Q_PRIVATE_QPROPERTY(accessor, type, name, setter, __VA_ARGS__) |
| 210 | #define Q_PRIVATE_QPROPERTIES_BEGIN |
| 211 | #define Q_PRIVATE_QPROPERTY_IMPL(name) |
| 212 | #define Q_PRIVATE_QPROPERTIES_END |
| 213 | #define Q_REVISION(...) Q_REVISION(__VA_ARGS__) |
| 214 | #define Q_OVERRIDE(text) Q_OVERRIDE(text) |
| 215 | #define Q_ENUMS(x) Q_ENUMS(x) |
| 216 | #define Q_FLAGS(x) Q_FLAGS(x) |
| 217 | #define Q_ENUM(x) Q_ENUM(x) |
| 218 | #define Q_FLAGS(x) Q_FLAGS(x) |
| 219 | /* qmake ignore Q_OBJECT */ |
| 220 | #define Q_OBJECT Q_OBJECT |
| 221 | /* qmake ignore Q_OBJECT */ |
| 222 | #define Q_OBJECT_FAKE Q_OBJECT_FAKE |
| 223 | /* qmake ignore Q_GADGET */ |
| 224 | #define Q_GADGET Q_GADGET |
| 225 | #define Q_SCRIPTABLE Q_SCRIPTABLE |
| 226 | #define Q_INVOKABLE Q_INVOKABLE |
| 227 | #define Q_SIGNAL Q_SIGNAL |
| 228 | #define Q_SLOT Q_SLOT |
| 229 | #endif //Q_MOC_RUN |
| 230 | |
| 231 | QT_END_NAMESPACE |
| 232 | |
| 233 | #endif // QTMETAMACROS_H |
| 234 | |