OSDN Git Service

make use of the recent C++ additions
authorIvailo Monev <xakepa10@gmail.com>
Wed, 27 Jan 2016 02:51:54 +0000 (04:51 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 27 Jan 2016 02:51:54 +0000 (04:51 +0200)
these should be guarded by QT_NO_STD and are probably not going to work on
all platforms, Qt5 does a lot of magic for this

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/global/qglobal.h
src/core/global/qnumeric.cpp
src/core/global/qnumeric.h
src/core/global/qnumeric_p.h
src/core/tools/qline.cpp
src/core/tools/qlocale.cpp
src/gui/painting/qpaintengine_mac.cpp
src/gui/painting/qpainterpath.cpp
src/gui/painting/qstroker.cpp

index ac98b92..8f9696c 100644 (file)
@@ -1661,7 +1661,7 @@ public:
 #  endif
     };
 #else
-#  error "Qt not configured correctly, please run configure"
+#  error "Qt not configured correctly, please run cmake"
 #endif
 #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
     enum WinVersion {
index b7958da..12d3ddb 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
+#ifdef QT_NO_STL
 /*!
     Returns true if the double \a {d} is equivalent to infinity.
 */
-Q_CORE_EXPORT bool qIsInf(double d) { return qt_is_inf(d); }
+Q_CORE_EXPORT bool qIsInf(double d)
+{
+    uchar *ch = (uchar *)&d;
+#ifdef QT_ARMFPA
+    return (ch[3] & 0x7f) == 0x7f && ch[2] == 0xf0;
+#else
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0;
+    } else {
+        return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
+    }
+#endif
+}
 
 /*!
     Returns true if the double \a {d} is not a number (NaN).
 */
-Q_CORE_EXPORT bool qIsNaN(double d) { return qt_is_nan(d); }
+Q_CORE_EXPORT bool qIsNaN(double d)
+{
+    uchar *ch = (uchar *)&d;
+#ifdef QT_ARMFPA
+    return (ch[3] & 0x7f) == 0x7f && ch[2] > 0xf0;
+#else
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0;
+    } else {
+        return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
+    }
+#endif
+}
 
 /*!
     Returns true if the double \a {d} is a finite number.
 */
-Q_CORE_EXPORT bool qIsFinite(double d) { return qt_is_finite(d); }
+Q_CORE_EXPORT bool qIsFinite(double d)
+{
+    uchar *ch = (uchar *)&d;
+#ifdef QT_ARMFPA
+    return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0xf0) != 0xf0;
+#else
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0;
+    } else {
+        return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
+    }
+#endif
+}
 
 /*!
     Returns true if the float \a {f} is equivalent to infinity.
 */
-Q_CORE_EXPORT bool qIsInf(float f) { return qt_is_inf(f); }
+Q_CORE_EXPORT bool qIsInf(float f)
+{
+    uchar *ch = (uchar *)&f;
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) == 0x7f && ch[1] == 0x80;
+    } else {
+        return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
+    }
+}
 
 /*!
     Returns true if the float \a {f} is not a number (NaN).
 */
-Q_CORE_EXPORT bool qIsNaN(float f) { return qt_is_nan(f); }
+Q_CORE_EXPORT bool qIsNaN(float f)
+{
+    uchar *ch = (uchar *)&f;
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) == 0x7f && ch[1] > 0x80;
+    } else {
+        return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
+    }
+}
 
 /*!
     Returns true if the float \a {f} is a finite number.
 */
-Q_CORE_EXPORT bool qIsFinite(float f) { return qt_is_finite(f); }
+Q_CORE_EXPORT bool qIsFinite(float f)
+{
+    uchar *ch = (uchar *)&f;
+    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+        return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0x80) != 0x80;
+    } else {
+        return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
+    }
+}
+#endif // QT_NO_STL
 
 /*!
     Returns the bit pattern of a signalling NaN as a double.
@@ -89,5 +151,4 @@ Q_CORE_EXPORT double qQNaN() { return qt_qnan(); }
 */
 Q_CORE_EXPORT double qInf() { return qt_inf(); }
 
-
 QT_END_NAMESPACE
index 6b94791..c4ab0a1 100644 (file)
 
 #include <QtCore/qglobal.h>
 
+#ifndef QT_NO_STL
+#include <math.h>
+#endif
+
 QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
 
-
+#ifndef QT_NO_STL
+Q_CORE_EXPORT_INLINE bool qIsInf(double d) { return isinf(d); }
+Q_CORE_EXPORT_INLINE bool qIsNaN(double d) { return isnan(d); }
+Q_CORE_EXPORT_INLINE bool qIsFinite(double d) { return isfinite(d); }
+Q_CORE_EXPORT_INLINE bool qIsInf(float f) { return isinf(f); }
+Q_CORE_EXPORT_INLINE bool qIsNaN(float f) { return isnan(f); }
+Q_CORE_EXPORT_INLINE bool qIsFinite(float f) { return isfinite(f); }
+#else
 Q_CORE_EXPORT bool qIsInf(double d);
 Q_CORE_EXPORT bool qIsNaN(double d);
 Q_CORE_EXPORT bool qIsFinite(double d);
 Q_CORE_EXPORT bool qIsInf(float f);
 Q_CORE_EXPORT bool qIsNaN(float f);
 Q_CORE_EXPORT bool qIsFinite(float f);
+#endif
+
 Q_CORE_EXPORT double qSNaN();
 Q_CORE_EXPORT double qQNaN();
 Q_CORE_EXPORT double qInf();
index 30fe5b8..273477d 100644 (file)
@@ -166,78 +166,6 @@ static inline double qt_qnan()
 
 #endif // Q_CC_MIPS
 
-static inline bool qt_is_inf(double d)
-{
-    uchar *ch = (uchar *)&d;
-#ifdef QT_ARMFPA
-    return (ch[3] & 0x7f) == 0x7f && ch[2] == 0xf0;
-#else
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0;
-    } else {
-        return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
-    }
-#endif
-}
-
-static inline bool qt_is_nan(double d)
-{
-    uchar *ch = (uchar *)&d;
-#ifdef QT_ARMFPA
-    return (ch[3] & 0x7f) == 0x7f && ch[2] > 0xf0;
-#else
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0;
-    } else {
-        return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
-    }
-#endif
-}
-
-static inline bool qt_is_finite(double d)
-{
-    uchar *ch = (uchar *)&d;
-#ifdef QT_ARMFPA
-    return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0xf0) != 0xf0;
-#else
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0;
-    } else {
-        return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
-    }
-#endif
-}
-
-static inline bool qt_is_inf(float d)
-{
-    uchar *ch = (uchar *)&d;
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) == 0x7f && ch[1] == 0x80;
-    } else {
-        return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
-    }
-}
-
-static inline bool qt_is_nan(float d)
-{
-    uchar *ch = (uchar *)&d;
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) == 0x7f && ch[1] > 0x80;
-    } else {
-        return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
-    }
-}
-
-static inline bool qt_is_finite(float d)
-{
-    uchar *ch = (uchar *)&d;
-    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
-        return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0x80) != 0x80;
-    } else {
-        return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
-    }
-}
-
 QT_END_NAMESPACE
 
 #endif // QNUMERIC_P_H
index 4234c6b..b7d24de 100644 (file)
@@ -43,7 +43,7 @@
 #include "qdebug.h"
 #include "qdatastream.h"
 #include "qmath.h"
-#include <qnumeric_p.h>
+#include <qnumeric.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -674,7 +674,7 @@ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPo
     const QPointF c = pt1 - l.pt1;
 
     const qreal denominator = a.y() * b.x() - a.x() * b.y();
-    if (denominator == 0 || !qt_is_finite(denominator))
+    if (denominator == 0 || !qIsFinite(denominator))
         return NoIntersection;
 
     const qreal reciprocal = 1 / denominator;
index e5fdaa0..28d6415 100644 (file)
@@ -70,6 +70,7 @@ QT_END_NAMESPACE
 #   include "qt_windows.h"
 #   include <time.h>
 #endif
+#include "qnumeric.h"
 #include "qnumeric_p.h"
 #include "qsystemlibrary_p.h"
 
@@ -2496,11 +2497,11 @@ QString QLocalePrivate::doubleToString(const QChar _zero, const QChar plus, cons
     QString num_str;
 
     // Detect special numbers (nan, +/-inf)
-    if (qt_is_inf(d)) {
+    if (qIsInf(d)) {
         num_str = QString::fromLatin1("inf");
         special_number = true;
         negative = d < 0;
-    } else if (qt_is_nan(d)) {
+    } else if (qIsNaN(d)) {
         num_str = QString::fromLatin1("nan");
         special_number = true;
     }
index 6fccf0c..33329ae 100644 (file)
@@ -54,6 +54,7 @@
 #include <qdebug.h>
 #include <qcoreapplication.h>
 #include <qmath.h>
+#include <qnumeric.h>
 
 #include <qfont_p.h>
 #include <qfontengine_p.h>
@@ -754,9 +755,9 @@ QCoreGraphicsPaintEngine::updateMatrix(const QTransform &transform)
     Q_D(QCoreGraphicsPaintEngine);
     Q_ASSERT(isActive());
 
-    if (qt_is_nan(transform.m11()) || qt_is_nan(transform.m12()) || qt_is_nan(transform.m13())
-       || qt_is_nan(transform.m21()) || qt_is_nan(transform.m22()) || qt_is_nan(transform.m23())
-       || qt_is_nan(transform.m31()) || qt_is_nan(transform.m32()) || qt_is_nan(transform.m33()))
+    if (qIsNaN(transform.m11()) || qIsNaN(transform.m12()) || qIsNaN(transform.m13())
+       || qIsNaN(transform.m21()) || qIsNaN(transform.m22()) || qIsNaN(transform.m23())
+       || qIsNaN(transform.m31()) || qIsNaN(transform.m32()) || qIsNaN(transform.m33()))
        return;
 
     d->current.transform = transform;
index 4bee41c..95e38a9 100644 (file)
@@ -55,7 +55,7 @@
 
 #include <qbezier_p.h>
 #include <qfontengine_p.h>
-#include <qnumeric_p.h>
+#include <qnumeric.h>
 #include <qobject_p.h>
 #include <qpathclipper_p.h>
 #include <qstroker_p.h>
@@ -637,7 +637,7 @@ void QPainterPath::moveTo(const QPointF &p)
     printf("QPainterPath::moveTo() (%.2f,%.2f)\n", p.x(), p.y());
 #endif
 
-    if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) {
+    if (!qIsFinite(p.x()) || !qIsFinite(p.y())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
 #endif
@@ -687,7 +687,7 @@ void QPainterPath::lineTo(const QPointF &p)
     printf("QPainterPath::lineTo() (%.2f,%.2f)\n", p.x(), p.y());
 #endif
 
-    if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) {
+    if (!qIsFinite(p.x()) || !qIsFinite(p.y())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
 #endif
@@ -746,8 +746,8 @@ void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &
            c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
 #endif
 
-    if (!qt_is_finite(c1.x()) || !qt_is_finite(c1.y()) || !qt_is_finite(c2.x()) || !qt_is_finite(c2.y())
-        || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) {
+    if (!qIsFinite(c1.x()) || !qIsFinite(c1.y()) || !qIsFinite(c2.x()) || !qIsFinite(c2.y())
+        || !qIsFinite(e.x()) || !qIsFinite(e.y())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::cubicTo: Adding point where x or y is NaN or Inf, ignoring call");
 #endif
@@ -803,7 +803,7 @@ void QPainterPath::quadTo(const QPointF &c, const QPointF &e)
            c.x(), c.y(), e.x(), e.y());
 #endif
 
-    if (!qt_is_finite(c.x()) || !qt_is_finite(c.y()) || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) {
+    if (!qIsFinite(c.x()) || !qIsFinite(c.y()) || !qIsFinite(e.x()) || !qIsFinite(e.y())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::quadTo: Adding point where x or y is NaN or Inf, ignoring call");
 #endif
@@ -874,8 +874,8 @@ void QPainterPath::arcTo(const QRectF &rect, qreal startAngle, qreal sweepLength
            rect.x(), rect.y(), rect.width(), rect.height(), startAngle, sweepLength);
 #endif
 
-    if ((!qt_is_finite(rect.x()) && !qt_is_finite(rect.y())) || !qt_is_finite(rect.width()) || !qt_is_finite(rect.height())
-        || !qt_is_finite(startAngle) || !qt_is_finite(sweepLength)) {
+    if ((!qIsFinite(rect.x()) && !qIsFinite(rect.y())) || !qIsFinite(rect.width()) || !qIsFinite(rect.height())
+        || !qIsFinite(startAngle) || !qIsFinite(sweepLength)) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN or Inf, ignoring call");
 #endif
@@ -980,7 +980,7 @@ QPointF QPainterPath::currentPosition() const
 */
 void QPainterPath::addRect(const QRectF &r)
 {
-    if (!qt_is_finite(r.x()) || !qt_is_finite(r.y()) || !qt_is_finite(r.width()) || !qt_is_finite(r.height())) {
+    if (!qIsFinite(r.x()) || !qIsFinite(r.y()) || !qIsFinite(r.width()) || !qIsFinite(r.height())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN or Inf, ignoring call");
 #endif
@@ -1063,8 +1063,8 @@ void QPainterPath::addPolygon(const QPolygonF &polygon)
 */
 void QPainterPath::addEllipse(const QRectF &boundingRect)
 {
-    if (!qt_is_finite(boundingRect.x()) || !qt_is_finite(boundingRect.y())
-        || !qt_is_finite(boundingRect.width()) || !qt_is_finite(boundingRect.height())) {
+    if (!qIsFinite(boundingRect.x()) || !qIsFinite(boundingRect.y())
+        || !qIsFinite(boundingRect.width()) || !qIsFinite(boundingRect.height())) {
 #ifndef QT_NO_DEBUG
         qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN or Inf, ignoring call");
 #endif
@@ -2393,7 +2393,7 @@ QDataStream &operator>>(QDataStream &s, QPainterPath &p)
         s >> x;
         s >> y;
         Q_ASSERT(type >= 0 && type <= 3);
-        if (!qt_is_finite(x) || !qt_is_finite(y)) {
+        if (!qIsFinite(x) || !qIsFinite(y)) {
 #ifndef QT_NO_DEBUG
             qWarning("QDataStream::operator>>: NaN or Inf element found in path, skipping it");
 #endif
index 0da4813..38834ae 100644 (file)
@@ -44,7 +44,8 @@
 #include "qmath_p.h"
 #include "qline.h"
 #include "qtransform.h"
-#include <qmath.h>
+#include "qmath.h"
+#include "qnumeric.h"
 
 QT_BEGIN_NAMESPACE
 
@@ -860,8 +861,8 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
     Q_ASSERT(curves);
 
     *point_count = 0;
-    if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height())
-        || qt_is_nan(startAngle) || qt_is_nan(sweepLength)) {
+    if (qIsNaN(rect.x()) || qIsNaN(rect.y()) || qIsNaN(rect.width()) || qIsNaN(rect.height())
+        || qIsNaN(startAngle) || qIsNaN(sweepLength)) {
         qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined");
         return QPointF();
     }