From b333c3396af80d63b40734293ae59d2e00cd714b Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 8 Apr 2016 11:54:52 +0200 Subject: qdoc: Remove Q_QDOC for qRound() and qRound64() These uses of Q_QDOC cause clang to report syntax errors. They are used to hide function return values as qreal instead of using double and float. The decision is to be more transparent and use double and float in the docs instead of qreal. This change does not require clang in qdoc. Change-Id: I65b3afb693b1eff486b0b45b8d972fec96953c5f Task-number: QTBUG-52454 Reviewed-by: Martin Smith --- .../snippets/code/src_corelib_global_qglobal.cpp | 36 +++++++++++++++----- src/corelib/global/qglobal.cpp | 38 +++++++++++++++++----- src/corelib/global/qglobal.h | 12 ------- 3 files changed, 57 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index a022187c21..ae969ca269 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -131,26 +131,46 @@ absoluteValue = qAbs(myValue); //! [10] -//! [11] -qreal valueA = 2.3; -qreal valueB = 2.7; +//! [11A] +double valueA = 2.3; +double valueB = 2.7; int roundedValueA = qRound(valueA); // roundedValueA = 2 int roundedValueB = qRound(valueB); // roundedValueB = 3 -//! [11] +//! [11A] +//! [11B] +float valueA = 2.3; +float valueB = 2.7; -//! [12] -qreal valueA = 42949672960.3; -qreal valueB = 42949672960.7; +int roundedValueA = qRound(valueA); +// roundedValueA = 2 +int roundedValueB = qRound(valueB); +// roundedValueB = 3 +//! [11B] + + +//! [12A] +double valueA = 42949672960.3; +double valueB = 42949672960.7; + +qint64 roundedValueA = qRound64(valueA); +// roundedValueA = 42949672960 +qint64 roundedValueB = qRound64(valueB); +// roundedValueB = 42949672961 +//! [12A] + +//! [12B] +float valueA = 42949672960.3; +float valueB = 42949672960.7; qint64 roundedValueA = qRound64(valueA); // roundedValueA = 42949672960 qint64 roundedValueB = qRound64(valueB); // roundedValueB = 42949672961 -//! [12] +//! [12B] //! [13] diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a2cbd94c92..96a31e4167 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -571,11 +571,11 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 4 The remaining functions are qRound() and qRound64(), which both - accept a \l qreal value as their argument returning the value - rounded up to the nearest integer and 64-bit integer respectively, - the qInstallMessageHandler() function which installs the given - QtMessageHandler, and the qVersion() function which returns the - version number of Qt at run-time as a string. + accept a \c double or \c float value as their argument returning + the value rounded up to the nearest integer and 64-bit integer + respectively, the qInstallMessageHandler() function which installs + the given QtMessageHandler, and the qVersion() function which + returns the version number of Qt at run-time as a string. \section1 Macros @@ -862,24 +862,44 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 10 */ -/*! \fn int qRound(qreal value) +/*! \fn int qRound(double value) \relates Rounds \a value to the nearest integer. Example: - \snippet code/src_corelib_global_qglobal.cpp 11 + \snippet code/src_corelib_global_qglobal.cpp 11A */ -/*! \fn qint64 qRound64(qreal value) +/*! \fn int qRound(float value) + \relates + + Rounds \a value to the nearest integer. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp 11B +*/ + +/*! \fn qint64 qRound64(double value) + \relates + + Rounds \a value to the nearest 64-bit integer. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp 12A +*/ + +/*! \fn qint64 qRound64(float value) \relates Rounds \a value to the nearest 64-bit integer. Example: - \snippet code/src_corelib_global_qglobal.cpp 12 + \snippet code/src_corelib_global_qglobal.cpp 12B */ /*! \fn const T &qMin(const T &value1, const T &value2) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 86ac5d0312..cc3eab4e42 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -526,23 +526,11 @@ Q_DECL_CONSTEXPR inline int qRound(double d) { return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); } Q_DECL_CONSTEXPR inline int qRound(float d) { return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); } -#ifdef Q_QDOC -/* - Just for documentation generation -*/ -int qRound(qreal d); -#endif Q_DECL_CONSTEXPR inline qint64 qRound64(double d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); } Q_DECL_CONSTEXPR inline qint64 qRound64(float d) { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); } -#ifdef Q_QDOC -/* - Just for documentation generation -*/ -qint64 qRound64(qreal d); -#endif template Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; } -- cgit v1.2.3