Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtmetamacros.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QTMETAMACROS_H
6#define QTMETAMACROS_H
7
8#include <QtCore/qglobal.h>
9#include <QtCore/qtclasshelpermacros.h>
10
12
13#ifndef Q_MOC_OUTPUT_REVISION
14// This number should be in sync with moc's outputrevision.h
15#define Q_MOC_OUTPUT_REVISION 69
16#endif
17
18// The following macros can be defined by tools that understand Qt
19// to have the information from the macro.
20#ifndef QT_ANNOTATE_CLASS
21# define QT_ANNOTATE_CLASS(type, ...)
22#endif
23#ifndef QT_ANNOTATE_CLASS2
24# define QT_ANNOTATE_CLASS2(type, a1, a2)
25#endif
26#ifndef QT_ANNOTATE_FUNCTION
27# define QT_ANNOTATE_FUNCTION(x)
28#endif
29#ifndef QT_ANNOTATE_ACCESS_SPECIFIER
30# define QT_ANNOTATE_ACCESS_SPECIFIER(x)
31#endif
32
33// The following macros are our "extensions" to C++
34// They are used, strictly speaking, only by the moc.
35
36#ifndef Q_MOC_RUN
37#ifndef QT_NO_META_MACROS
38# if defined(QT_NO_KEYWORDS)
39# define QT_NO_EMIT
40# else
41# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS
42# define slots Q_SLOTS
43# define signals Q_SIGNALS
44# endif
45# endif
46# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot)
47# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal)
48# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature)
49# define Q_EMIT
50#ifndef QT_NO_EMIT
51# define emit
52#endif
53#ifndef Q_CLASSINFO
54# define Q_CLASSINFO(name, value)
55#endif
56#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x)
57#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x)
58#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__)
59#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text)
60#ifndef Q_REVISION
61# define Q_REVISION(...)
62#endif
63#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text)
64#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text)
65#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x)
66#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x)
67#define Q_ENUM_IMPL(ENUM)
68 friend constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; }
69 friend constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; }
70#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x)
71#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x)
72#define Q_ENUM_NS_IMPL(ENUM)
73 inline constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; }
74 inline constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; }
75#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x)
76#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x)
77#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable)
78#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable)
79#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal)
80#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot)
81#define Q_MOC_INCLUDE(...) QT_ANNOTATE_CLASS(qt_moc_include, __VA_ARGS__)
82#endif // QT_NO_META_MACROS
83
84#ifndef QT_NO_TRANSLATION
85// full set of tr functions
86# define QT_TR_FUNCTIONS
87 static inline QString tr(const char *s, const char *c = nullptr, int n = -1)
88 { return staticMetaObject.tr(s, c, n); }
89#else
90// inherit the ones from QObject
91# define QT_TR_FUNCTIONS
92#endif
93
94#ifdef Q_QDOC
95#define QT_TR_FUNCTIONS
96#endif
97
98#define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN
99
100#if defined(Q_CC_CLANG)
101# if Q_CC_CLANG >= 1100
102# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") QT_WARNING_DISABLE_CLANG("-Wsuggest-override")
103# elif Q_CC_CLANG >= 306
104# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override")
105# endif
106#elif defined(Q_CC_GNU) && Q_CC_GNU >= 501
107# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override")
108#elif defined(Q_CC_MSVC)
109# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_MSVC(26433)
110#else
111# define Q_OBJECT_NO_OVERRIDE_WARNING
112#endif
113
114#if defined(Q_CC_GNU) && Q_CC_GNU >= 600
115# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes")
116#else
117# define Q_OBJECT_NO_ATTRIBUTES_WARNING
118#endif
119
120#define QT_META_OBJECT_VARS
121 template <typename> static constexpr auto qt_create_metaobjectdata();
122 template <typename MetaObjectTagType> static constexpr inline auto
123 qt_staticMetaObjectContent = qt_create_metaobjectdata<MetaObjectTagType>();
124 template <typename MetaObjectTagType> static constexpr inline auto
125 qt_staticMetaObjectStaticContent = qt_staticMetaObjectContent<MetaObjectTagType>.data;
126 template <typename MetaObjectTagType> static constexpr inline auto
127 qt_staticMetaObjectRelocatingContent = qt_staticMetaObjectContent<MetaObjectTagType>.metaTypes;
128
129#define QT_OBJECT_GADGET_COMMON
132 Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
133
134/* qmake ignore Q_OBJECT */
135#define Q_OBJECT public
136 :
137 QT_WARNING_PUSH
139 static const QMetaObject staticMetaObject;
140 virtual const QMetaObject *metaObject() const;
141 virtual void *qt_metacast(const char *);
142 virtual int qt_metacall(QMetaObject::Call, int, void **);
143 QT_TR_FUNCTIONS private
144 :
146 QT_DEFINE_TAG_STRUCT(QPrivateSignal);
147 QT_WARNING_POP
148 QT_ANNOTATE_CLASS(qt_qobject, "")
149
150/* qmake ignore Q_OBJECT */
151#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "")
152
153#ifndef QT_NO_META_MACROS
154/* qmake ignore Q_GADGET_EXPORT */
155#define Q_GADGET_EXPORT(...) public
156 :
157 static __VA_ARGS__ const QMetaObject staticMetaObject;
158 void qt_check_for_QGADGET_macro();
159 typedef void QtGadgetHelper; private
160 :
161 QT_WARNING_PUSH
163 QT_WARNING_POP
164 QT_ANNOTATE_CLASS(qt_qgadget, "")
165 /*end*/
166
167/* qmake ignore Q_GADGET */
168#define Q_GADGET Q_GADGET_EXPORT()
169
170 /* qmake ignore Q_NAMESPACE_EXPORT */
171#define Q_NAMESPACE_EXPORT(...)
172 extern __VA_ARGS__ const QMetaObject staticMetaObject;
173 template <typename> static constexpr auto qt_create_metaobjectdata();
174 QT_ANNOTATE_CLASS(qt_qnamespace, "")
175 /*end*/
176
177/* qmake ignore Q_NAMESPACE */
178#define Q_NAMESPACE Q_NAMESPACE_EXPORT()
179 /*end*/
180
181#endif // QT_NO_META_MACROS
182
183#else // Q_MOC_RUN
184#define slots slots
185#define signals signals
186#define Q_SLOTS Q_SLOTS
187#define Q_SIGNALS Q_SIGNALS
188#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value)
189#define Q_INTERFACES(x) Q_INTERFACES(x)
190#define Q_PROPERTY(text) Q_PROPERTY(text)
191#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text)
192#define Q_PRIVATE_QPROPERTY(accessor, type, name, setter, ...) Q_PRIVATE_QPROPERTY(accessor, type, name, setter, __VA_ARGS__)
193#define Q_PRIVATE_QPROPERTIES_BEGIN
194#define Q_PRIVATE_QPROPERTY_IMPL(name)
195#define Q_PRIVATE_QPROPERTIES_END
196#define Q_REVISION(...) Q_REVISION(__VA_ARGS__)
197#define Q_OVERRIDE(text) Q_OVERRIDE(text)
198#define Q_ENUMS(x) Q_ENUMS(x)
199#define Q_FLAGS(x) Q_FLAGS(x)
200#define Q_ENUM(x) Q_ENUM(x)
201#define Q_FLAGS(x) Q_FLAGS(x)
202 /* qmake ignore Q_OBJECT */
203#define Q_OBJECT Q_OBJECT
204 /* qmake ignore Q_OBJECT */
205#define Q_OBJECT_FAKE Q_OBJECT_FAKE
206 /* qmake ignore Q_GADGET */
207#define Q_GADGET Q_GADGET
208#define Q_SCRIPTABLE Q_SCRIPTABLE
209#define Q_INVOKABLE Q_INVOKABLE
210#define Q_SIGNAL Q_SIGNAL
211#define Q_SLOT Q_SLOT
212#endif //Q_MOC_RUN
213
215
216#endif // QTMETAMACROS_H
\inmodule QtSql
#define QT_ANNOTATE_FUNCTION(x)
#define QT_ANNOTATE_CLASS2(type, a1, a2)
#define Q_GADGET_EXPORT(...)
#define Q_OBJECT
#define Q_DECL_HIDDEN_STATIC_METACALL
#define QT_ANNOTATE_CLASS(type,...)
#define Q_OBJECT_NO_ATTRIBUTES_WARNING
#define QT_META_OBJECT_VARS
#define Q_FLAGS(x)
#define QT_TR_FUNCTIONS
#define QT_ANNOTATE_ACCESS_SPECIFIER(x)
#define QT_OBJECT_GADGET_COMMON
#define Q_SLOTS
#define Q_OBJECT_NO_OVERRIDE_WARNING
#define Q_ENUMS(x)
#define Q_SIGNALS
#define Q_ENUM_IMPL(ENUM)
#define Q_ENUM_NS_IMPL(ENUM)
#define Q_NAMESPACE_EXPORT(...)