From bb90a1d87b7ac9e498e46c5f3658010609aebcf2 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 14 Jul 2020 01:13:08 +0000 Subject: [PATCH] review qglobal header comments, style, etc. Signed-off-by: Ivailo Monev --- src/core/global/qglobal.h.cmake | 159 +++++++++++++++------------------------- 1 file changed, 60 insertions(+), 99 deletions(-) diff --git a/src/core/global/qglobal.h.cmake b/src/core/global/qglobal.h.cmake index 1b077f6f5..974b0c451 100644 --- a/src/core/global/qglobal.h.cmake +++ b/src/core/global/qglobal.h.cmake @@ -83,7 +83,6 @@ https://gcc.gnu.org/backends.html https://en.wikipedia.org/wiki/GNU_Compiler_Collection#Architectures */ - #if defined(__alpha__) # define QT_ARCH_ALPHA #elif defined(__arm__) @@ -124,7 +123,7 @@ # error Unable to detect architecture, please update above list #endif -// detect target endianness +// Detect target endianness #if defined (__BYTE_ORDER__) && \ (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) # define Q_BYTE_ORDER __BYTE_ORDER__ @@ -248,18 +247,16 @@ QT_USE_NAMESPACE # error "Katie has not been ported to this OS" #endif -#if !defined(Q_OS_UNIX) -# define Q_OS_UNIX -#endif +// Compatibility, used to be conditional +#define Q_WS_X11 +#define Q_OS_UNIX -#ifdef __LSB_VERSION__ +#if defined(__LSB_VERSION__) # if __LSB_VERSION__ < 40 # error "This version of the Linux Standard Base is unsupported" # endif -#ifndef QT_LINUXBASE # define QT_LINUXBASE #endif -#endif /* The compiler, must be one of: (Q_CC_x) @@ -269,7 +266,6 @@ QT_USE_NAMESPACE Should be sorted most to least authoritative. */ - #if defined(__GNUC__) # define Q_CC_GNU # define Q_C_CALLBACKS @@ -319,7 +315,6 @@ QT_USE_NAMESPACE * http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */ - #if defined(Q_CC_GNU) # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L /* C++0x features supported in GCC 4.3: */ @@ -365,16 +360,6 @@ QT_USE_NAMESPACE } AFUNC ## __dest_instance__; #define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) -/* - The window system, must be one of: (Q_WS_x) - - X11 - X Window System -*/ - -#if defined(Q_OS_UNIX) -# define Q_WS_X11 -#endif - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -383,7 +368,6 @@ QT_BEGIN_NAMESPACE Make sure to update QMetaType when changing these typedefs */ - typedef signed char qint8; /* 8 bit signed */ typedef unsigned char quint8; /* 8 bit unsigned */ typedef short qint16; /* 16 bit signed */ @@ -413,7 +397,6 @@ typedef quint64 qulonglong; /* Useful type definitions for Qt */ - typedef std::uintptr_t quintptr; typedef std::ptrdiff_t qptrdiff; @@ -434,18 +417,16 @@ QT_END_INCLUDE_NAMESPACE #else # define Q_DECL_DEPRECATED #endif -#ifndef Q_DECL_CONSTRUCTOR_DEPRECATED -# if defined(Q_MOC_RUN) -# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED -# elif defined(Q_NO_DEPRECATED_CONSTRUCTORS) -# define Q_DECL_CONSTRUCTOR_DEPRECATED -# else -# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED -# endif + +#if defined(Q_MOC_RUN) +# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED +#elif defined(Q_NO_DEPRECATED_CONSTRUCTORS) +# define Q_DECL_CONSTRUCTOR_DEPRECATED +#else +# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED #endif #if defined(QT_NO_DEPRECATED) -/* disable Qt3 support as well */ # undef QT3_SUPPORT_WARNINGS # undef QT3_SUPPORT # undef QT_DEPRECATED @@ -482,7 +463,7 @@ QT_END_INCLUDE_NAMESPACE #endif #if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) -#define QT_NO_FPU +# define QT_NO_FPU #endif // This logic must match the one in qmetatype.h @@ -495,7 +476,6 @@ typedef double qreal; /* Utility macros and inline functions */ - template Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; } @@ -507,45 +487,41 @@ template Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max) { return qMax(min, qMin(max, val)); } -#ifndef Q_DECL_EXPORT -# if defined(QT_VISIBILITY_AVAILABLE) -# define Q_DECL_EXPORT __attribute__((visibility("default"))) -# define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) -# else -# define Q_DECL_EXPORT -# define Q_DECL_HIDDEN -# endif -# define Q_DECL_IMPORT +#if defined(QT_VISIBILITY_AVAILABLE) +# define Q_DECL_EXPORT __attribute__((visibility("default"))) +# define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) +#else +# define Q_DECL_EXPORT +# define Q_DECL_HIDDEN #endif - -#if !defined(Q_CORE_EXPORT) -# if defined(QT_SHARED) -# define Q_CORE_EXPORT Q_DECL_EXPORT -# define Q_GUI_EXPORT Q_DECL_EXPORT -# define Q_SQL_EXPORT Q_DECL_EXPORT -# define Q_NETWORK_EXPORT Q_DECL_EXPORT -# define Q_SVG_EXPORT Q_DECL_EXPORT -# define Q_TEST_EXPORT Q_DECL_EXPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# define Q_XML_EXPORT Q_DECL_EXPORT -# define Q_SCRIPT_EXPORT Q_DECL_EXPORT -# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT -# define Q_DBUS_EXPORT Q_DECL_EXPORT -# define Q_UITOOLS_EXPORT Q_DECL_EXPORT -# else -# define Q_CORE_EXPORT -# define Q_GUI_EXPORT -# define Q_SQL_EXPORT -# define Q_NETWORK_EXPORT -# define Q_SVG_EXPORT -# define Q_TEST_EXPORT -# define Q_DECLARATIVE_EXPORT -# define Q_XML_EXPORT -# define Q_SCRIPT_EXPORT -# define Q_SCRIPTTOOLS_EXPORT -# define Q_DBUS_EXPORT -# define Q_UITOOLS_EXPORT -# endif +#define Q_DECL_IMPORT + +#if defined(QT_SHARED) +# define Q_CORE_EXPORT Q_DECL_EXPORT +# define Q_GUI_EXPORT Q_DECL_EXPORT +# define Q_SQL_EXPORT Q_DECL_EXPORT +# define Q_NETWORK_EXPORT Q_DECL_EXPORT +# define Q_SVG_EXPORT Q_DECL_EXPORT +# define Q_TEST_EXPORT Q_DECL_EXPORT +# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT +# define Q_XML_EXPORT Q_DECL_EXPORT +# define Q_SCRIPT_EXPORT Q_DECL_EXPORT +# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT +# define Q_DBUS_EXPORT Q_DECL_EXPORT +# define Q_UITOOLS_EXPORT Q_DECL_EXPORT +#else +# define Q_CORE_EXPORT +# define Q_GUI_EXPORT +# define Q_SQL_EXPORT +# define Q_NETWORK_EXPORT +# define Q_SVG_EXPORT +# define Q_TEST_EXPORT +# define Q_DECLARATIVE_EXPORT +# define Q_XML_EXPORT +# define Q_SCRIPT_EXPORT +# define Q_SCRIPTTOOLS_EXPORT +# define Q_DBUS_EXPORT +# define Q_UITOOLS_EXPORT #endif #define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline @@ -570,7 +546,6 @@ inline void qt_noop(void) {} If you can't live with that constraint, don't use these macros. Use the QT_NO_EXCEPTIONS macro to protect your code instead. */ - #if !defined(QT_NO_EXCEPTIONS) && !defined(Q_COMPILER_EXCEPTIONS) && !defined(Q_MOC_RUN) # define QT_NO_EXCEPTIONS #endif @@ -590,7 +565,6 @@ inline void qt_noop(void) {} /* System information */ - class Q_CORE_EXPORT QSysInfo { public: enum Sizes { @@ -615,15 +589,13 @@ Q_CORE_EXPORT bool qSharedBuild(); /* Avoid "unused parameter" warnings */ - #define Q_UNUSED(x) (void)x; /* Debugging and error handling */ - #if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM) -#define QT_NO_DEBUG_STREAM +# define QT_NO_DEBUG_STREAM #endif class QString; @@ -658,22 +630,18 @@ Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...); Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line); -#if !defined(Q_ASSERT) -# ifndef QT_NO_DEBUG -# define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) -# else -# define Q_ASSERT(cond) qt_noop() -# endif +#ifndef QT_NO_DEBUG +# define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) +#else +# define Q_ASSERT(cond) qt_noop() #endif Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line); -#if !defined(Q_ASSERT_X) -# ifndef QT_NO_DEBUG -# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop()) -# else -# define Q_ASSERT_X(cond, where, what) qt_noop() -# endif +#ifndef QT_NO_DEBUG +# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop()) +#else +# define Q_ASSERT_X(cond, where, what) qt_noop() #endif Q_CORE_EXPORT void qt_check_pointer(const char *, int); @@ -745,9 +713,9 @@ public: return thisGlobalStatic.pointer; \ } -#else +#else // QT_NO_THREAD -// forward declaration, since qatomic.h needs qglobal.h +// Forward declaration, since qatomic.h needs qglobal.h template class QAtomicPointer; // POD for Q_GLOBAL_STATIC @@ -824,7 +792,7 @@ public: return this__StaticVar_.pointer; \ } -#endif +#endif // QT_NO_THREAD Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { @@ -892,7 +860,6 @@ static inline bool qIsNull(float f) Just in case other code relies on it we better trigger a warning mandating a real implementation. */ - #ifdef Q_FULL_TEMPLATE_INSTANTIATION # define Q_DUMMY_COMPARISON_OPERATOR(C) \ bool operator==(const C&) const { \ @@ -903,11 +870,9 @@ static inline bool qIsNull(float f) # define Q_DUMMY_COMPARISON_OPERATOR(C) #endif - /* QTypeInfo - type trait functionality */ - template class QTypeInfo { @@ -964,8 +929,6 @@ public: \ template<> \ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) - - template inline void qSwap(T &value1, T &value2) { @@ -1014,7 +977,6 @@ Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); These functions make it possible to use standard C++ functions with a similar name from Qt header files (especially template classes). */ - class Q_CORE_EXPORT QFlag { int i; @@ -1110,7 +1072,7 @@ private: #define Q_FOREACH(variable, container) \ for (variable: QForeachContainer(container)) -#else +#else // QT_FOREACH_COMPAT #define Q_FOREACH(variable, container) for (variable: container) @@ -1164,7 +1126,6 @@ template static inline typename Wrapper::pointer qGetPtrHelpe When RTTI is not available, define this macro to force any uses of dynamic_cast to cause a compile failure. */ - #ifdef QT_NO_DYNAMIC_CAST # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check) -- 2.11.0