From 4da3350f151a978521fc3712f151c4d3bed9d846 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 23 Aug 2022 17:15:44 +0200 Subject: [PATCH] Extract header qconstructormacros.h from qglobal.h Task-number: QTBUG-99313 Change-Id: I3861a3095148c7927aabd8becf6f7b534f214fba Reviewed-by: Thiago Macieira --- src/corelib/CMakeLists.txt | 1 + src/corelib/global/qconstructormacros.h | 38 +++++++++++++++++++++++++ src/corelib/global/qglobal.h | 23 +-------------- 3 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 src/corelib/global/qconstructormacros.h diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 60f54027af2..663ceeda633 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -51,6 +51,7 @@ qt_internal_add_module(Core global/qcompare_impl.h global/qcompare.h global/qcompilerdetection.h + global/qconstructormacros.h global/qcontainerinfo.h global/qendian.cpp global/qendian.h global/qendian_p.h global/qenvironmentvariables.cpp global/qenvironmentvariables.h diff --git a/src/corelib/global/qconstructormacros.h b/src/corelib/global/qconstructormacros.h new file mode 100644 index 00000000000..21492ac31f6 --- /dev/null +++ b/src/corelib/global/qconstructormacros.h @@ -0,0 +1,38 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCONSTRUCTORMACROS_H +#define QCONSTRUCTORMACROS_H + +#if 0 +#pragma qt_class(QtConstructorMacros) +#pragma qt_sync_stop_processing +#endif + +#if defined(__cplusplus) + +#ifndef Q_CONSTRUCTOR_FUNCTION +# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ + namespace { \ + static const struct AFUNC ## _ctor_class_ { \ + inline AFUNC ## _ctor_class_() { AFUNC(); } \ + } AFUNC ## _ctor_instance_; \ + } + +# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) +#endif + +#ifndef Q_DESTRUCTOR_FUNCTION +# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ + namespace { \ + static const struct AFUNC ## _dtor_class_ { \ + inline AFUNC ## _dtor_class_() { } \ + inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \ + } AFUNC ## _dtor_instance_; \ + } +# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) +#endif + +#endif // __cplusplus + +#endif // QCONSTRUCTORMACROS_H diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index fcc61d5397e..ca0f09ef5c9 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -70,28 +70,6 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; #if defined(__cplusplus) -#ifndef Q_CONSTRUCTOR_FUNCTION -# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ - namespace { \ - static const struct AFUNC ## _ctor_class_ { \ - inline AFUNC ## _ctor_class_() { AFUNC(); } \ - } AFUNC ## _ctor_instance_; \ - } - -# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) -#endif - -#ifndef Q_DESTRUCTOR_FUNCTION -# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ - namespace { \ - static const struct AFUNC ## _dtor_class_ { \ - inline AFUNC ## _dtor_class_() { } \ - inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \ - } AFUNC ## _dtor_instance_; \ - } -# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) -#endif - /* moc compats (signals/slots) */ #ifndef QT_MOC_COMPAT # define QT_MOC_COMPAT @@ -240,6 +218,7 @@ QT_END_NAMESPACE #include #include +#include #include #include #include