diff options
Diffstat (limited to 'src/corelib/kernel/qtmetamacros.h')
-rw-r--r-- | src/corelib/kernel/qtmetamacros.h | 123 |
1 files changed, 27 insertions, 96 deletions
diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h index ab2e10884f..ae68abcfee 100644 --- a/src/corelib/kernel/qtmetamacros.h +++ b/src/corelib/kernel/qtmetamacros.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTMETAMACROS_H #define QTMETAMACROS_H @@ -91,41 +55,6 @@ QT_BEGIN_NAMESPACE #define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) #define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) #define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) -#define Q_PRIVATE_QPROPERTY(accessor, type, name, setter, ...) \ - struct _qt_property_api_##name { \ - type value() const; \ - type operator()() const { return value(); } \ - void setValue(type &&); \ - void setValue(type const &); \ - void operator=(type const &v) { setValue(v); } \ - void operator=(type &&v) { setValue(std::move(v)); } \ - QPropertyBinding<type> setBinding(const QPropertyBinding<type> &); \ - QPropertyBinding<type> setBinding(QPropertyBinding<type> &&); \ - QPropertyBinding<type> operator=(const QPropertyBinding<type> &b) { return setBinding(b); } \ - QPropertyBinding<type> operator=(QPropertyBinding<type> &&b) { return setBinding(std::move(b)); } \ - bool setBinding(const QUntypedPropertyBinding &); \ - template <typename Functor> \ - QPropertyBinding<type> setBinding(Functor f, \ - const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) \ - { \ - return setBinding(Qt::makePropertyBinding(f, location)); \ - } \ - bool hasBinding() const; \ - QPropertyBinding<type> binding() const; \ - QPropertyBinding<type> takeBinding(); \ - }; \ - void setter(type const& value); -#if __has_cpp_attribute(no_unique_address) -#define Q_PRIVATE_QPROPERTIES_BEGIN -#define QT_PRIVATE_QPROPERTY_PREFIX [[no_unique_address]] -#define Q_PRIVATE_QPROPERTIES_END -#else -#define Q_PRIVATE_QPROPERTIES_BEGIN union { -#define QT_PRIVATE_QPROPERTY_PREFIX -#define Q_PRIVATE_QPROPERTIES_END }; -#endif -#define Q_PRIVATE_QPROPERTY_IMPL(name) \ - QT_PRIVATE_QPROPERTY_PREFIX _qt_property_api_##name name; #ifndef Q_REVISION # define Q_REVISION(...) #endif @@ -134,13 +63,13 @@ QT_BEGIN_NAMESPACE #define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_ENUM_IMPL(ENUM) \ - friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } + friend constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + friend constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) #define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) #define Q_ENUM_NS_IMPL(ENUM) \ - inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } + inline constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + inline constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) #define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) #define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) @@ -154,34 +83,33 @@ QT_BEGIN_NAMESPACE // full set of tr functions # define QT_TR_FUNCTIONS \ static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \ - { return staticMetaObject.tr(s, c, n); } \ - QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \ { return staticMetaObject.tr(s, c, n); } #else // inherit the ones from QObject # define QT_TR_FUNCTIONS #endif -#ifdef Q_CLANG_QDOC +#ifdef Q_QDOC #define QT_TR_FUNCTIONS #endif -#if defined(Q_CC_INTEL) -// Cannot redefine the visibility of a method in an exported class -# define Q_DECL_HIDDEN_STATIC_METACALL -#else -# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN -#endif +#define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN -#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 -# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") -#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 +#if defined(Q_CC_CLANG) +# if Q_CC_CLANG >= 1100 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") QT_WARNING_DISABLE_CLANG("-Wsuggest-override") +# elif Q_CC_CLANG >= 306 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") +# endif +#elif defined(Q_CC_GNU) && Q_CC_GNU >= 501 # define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") +#elif defined(Q_CC_MSVC) +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_MSVC(26433) #else # define Q_OBJECT_NO_OVERRIDE_WARNING #endif -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 +#if defined(Q_CC_GNU) && Q_CC_GNU >= 600 # define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") #else # define Q_OBJECT_NO_ATTRIBUTES_WARNING @@ -201,17 +129,17 @@ private: \ Q_OBJECT_NO_ATTRIBUTES_WARNING \ Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ QT_WARNING_POP \ - struct QPrivateSignal {}; \ + struct QPrivateSignal { explicit QPrivateSignal() = default; }; \ QT_ANNOTATE_CLASS(qt_qobject, "") /* qmake ignore Q_OBJECT */ #define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") #ifndef QT_NO_META_MACROS -/* qmake ignore Q_GADGET */ -#define Q_GADGET \ +/* qmake ignore Q_GADGET_EXPORT */ +#define Q_GADGET_EXPORT(...) \ public: \ - static const QMetaObject staticMetaObject; \ + static __VA_ARGS__ const QMetaObject staticMetaObject; \ void qt_check_for_QGADGET_macro(); \ typedef void QtGadgetHelper; \ private: \ @@ -222,7 +150,10 @@ private: \ QT_ANNOTATE_CLASS(qt_qgadget, "") \ /*end*/ -/* qmake ignore Q_NAMESPACE_EXPORT */ +/* qmake ignore Q_GADGET */ +#define Q_GADGET Q_GADGET_EXPORT() + + /* qmake ignore Q_NAMESPACE_EXPORT */ #define Q_NAMESPACE_EXPORT(...) \ extern __VA_ARGS__ const QMetaObject staticMetaObject; \ QT_ANNOTATE_CLASS(qt_qnamespace, "") \ |