QT_INLINE_SINCE: take version into account
This patch improves the QT_INLINE_SINCE(maj, min) macro to take deprecation version into account. If the specified (maj, min) version is less than or equal to the version defined by QT_DISABLE_DEPRECATED_BEFORE, the macro will expand to "inline", and the out-of-line fallback will be removed from the library. This is achieved by introducing the helper QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) macro. Fixes: QTBUG-104131 Change-Id: I285029dad7b71126072b024a3be6d7b11341996d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 5a5bc86028b2967ffccf151a9463459e67b96a8b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
7b3092c137
commit
89db5c3d34
@ -21,13 +21,21 @@
|
|||||||
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) inline
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) inline
|
||||||
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
||||||
#elif defined(QT_@module_define_infix@_BUILD_REMOVED_API)
|
#elif defined(QT_@module_define_infix@_BUILD_REMOVED_API)
|
||||||
/* inside library, inside removed_api.cpp → non-inline decl, defi */
|
/* inside library, inside removed_api.cpp:
|
||||||
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) /* not inline */
|
* keep deprecated API → non-inline decl;
|
||||||
|
* remove deprecated API → inline decl;
|
||||||
|
* definition is always available */
|
||||||
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) \
|
||||||
|
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
||||||
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
||||||
#else
|
#else
|
||||||
/* inside library, outside removed_api.cpp → non-inline decl, no defi */
|
/* inside library, outside removed_api.cpp:
|
||||||
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) /* not inline */
|
* keep deprecated API → non-inline decl, no defi;
|
||||||
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 0
|
* remove deprecated API → inline decl, defi */
|
||||||
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) \
|
||||||
|
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
||||||
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) \
|
||||||
|
QT_IF_DEPRECATED_SINCE(major, minor, 1, 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QT_@module_define_infix@_BUILD_REMOVED_API
|
#ifdef QT_@module_define_infix@_BUILD_REMOVED_API
|
||||||
|
@ -442,6 +442,90 @@ typedef double qreal;
|
|||||||
#define QT_DEPRECATED_VERSION_5(minor) QT_DEPRECATED_VERSION_5_##minor
|
#define QT_DEPRECATED_VERSION_5(minor) QT_DEPRECATED_VERSION_5_##minor
|
||||||
#define QT_DEPRECATED_VERSION(major, minor) QT_DEPRECATED_VERSION_##major##_##minor
|
#define QT_DEPRECATED_VERSION(major, minor) QT_DEPRECATED_VERSION_##major##_##minor
|
||||||
|
|
||||||
|
/*
|
||||||
|
QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) expands to
|
||||||
|
\a whenTrue if the specified (\a major, \a minor) version is less than or
|
||||||
|
equal to the deprecation version defined by QT_DISABLE_DEPRECATED_BEFORE,
|
||||||
|
and to \a whenFalse otherwise.
|
||||||
|
|
||||||
|
Currently used for QT_INLINE_SINCE(maj, min), but can also be helpful for
|
||||||
|
other macros of that kind.
|
||||||
|
|
||||||
|
The implementation uses QT_DEPRECATED_SINCE(maj, min) to define a bunch of
|
||||||
|
helper QT_IF_DEPRECATED_SINCE_X_Y macros, which expand to \a whenTrue or
|
||||||
|
\a whenFalse depending on the value of QT_DEPRECATED_SINCE.
|
||||||
|
|
||||||
|
If you need to use QT_IF_DEPRECATED_SINCE() for a (major, minor) version,
|
||||||
|
that is not yet covered by the list below, you need to copy the definition
|
||||||
|
and change the major and minor versions accordingly. For example, for
|
||||||
|
version (X, Y), you will need to add
|
||||||
|
|
||||||
|
\code
|
||||||
|
#if QT_DEPRECATED_SINCE(X, Y)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_X_Y(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_X_Y(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
\endcode
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) \
|
||||||
|
QT_IF_DEPRECATED_SINCE_ ## major ## _ ## minor(whenTrue, whenFalse)
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_0(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_0(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 1)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_1(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_1(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 2)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_2(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_2(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 3)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_3(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_3(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 4)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_4(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_4(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 5)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_5(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_5(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 6)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_6(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_6(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 7)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_7(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_7(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 8)
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_8(whenTrue, whenFalse) whenFalse
|
||||||
|
#else
|
||||||
|
# define QT_IF_DEPRECATED_SINCE_6_8(whenTrue, whenFalse) whenTrue
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// A tag to help mark stuff deprecated (cf. QStringViewLiteral)
|
// A tag to help mark stuff deprecated (cf. QStringViewLiteral)
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user