Commit 7e9060b1 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

Make sure isErrorFiltered is called in release as well

parent f0e64b1d
......@@ -199,9 +199,9 @@ protected:
bool tryBind ( bool&& b) { set(QCborValue( b )); return true; }
bool tryBind ( float&& d) { set(QCborValue(double(d))); return true; }
bool tryBind ( double&& d) { set(QCborValue( d )); return true; }
bool tryBind ( quint64&& n) { if (quint64(std::numeric_limits<qint64>::max())<n) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { set(QCborValue(std::numeric_limits<qint64>::max())); return true; } return false; }
set(QCborValue(qint64(n))); return true; }
bool tryBind ( double&& d) { set(QCborValue( d )); return true; }
bool tryBind ( quint64&& n) { if (quint64(std::numeric_limits<qint64>::max())<n) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { set(QCborValue(std::numeric_limits<qint64>::max())); return true; } return false; }
set(QCborValue(qint64(n))); return true; }
bool tryBind ( qint64&& n) { set(QCborValue( n )); return true; }
bool tryBind ( QByteArray&& s) { set(QCborValue( s )); return true; }
......@@ -329,10 +329,10 @@ protected:
bool tryBind ( double& n) { if (caching) { return caching->tryBind(n) && cacheOut(); }
return getNumber(n); }
bool tryBind ( float& n) { double d;
if (!tryBind(d)) { return false; }
if (d<double(std::numeric_limits<float>::min()) ) { Q_ASSERT(isErrorFiltered(qBindExpectedSmallerNumber)); n=std::numeric_limits<float>::min(); return true; } // using isErrorFiltered result to return false (allowing user to bind with a larger type) would require a cachedNumber like in JSON
if ( double(std::numeric_limits<float>::max())<d) { Q_ASSERT(isErrorFiltered(qBindExpectedSmallerNumber)); n=std::numeric_limits<float>::max(); return true; }
n=float(d); return true; }
if (!tryBind(d)) { return false; }
if (d<double(std::numeric_limits<float>::min()) ) { Q_VERIFY(isErrorFiltered(qBindExpectedSmallerNumber)); n=std::numeric_limits<float>::min(); return true; } // using isErrorFiltered result to return false (allowing user to bind with a larger type) would require a cachedNumber like in JSON
if ( double(std::numeric_limits<float>::max())<d) { Q_VERIFY(isErrorFiltered(qBindExpectedSmallerNumber)); n=std::numeric_limits<float>::max(); return true; }
n=float(d); return true; }
bool tryBind ( quint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
skipTag();
......@@ -340,11 +340,11 @@ protected:
t=toUnsignedInteger(); return true; }
bool tryBind ( qint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
quint64 i; bool neg;
if (!getInteger(i,neg)) { return false; }
if ( neg && quint64(std::numeric_limits<qint64>::max())+1<i) { Q_ASSERT(isErrorFiltered(qBindExpectedSmallerNumber)); t=std::numeric_limits<qint64>::min(); return true; } // using isErrorFiltered result to return false (allowing user to bind with a larger type) would require a cachedNumber like in JSON
if (!neg && quint64(std::numeric_limits<qint64>::max()) <i) { Q_ASSERT(isErrorFiltered(qBindExpectedSmallerNumber)); t=std::numeric_limits<qint64>::max(); return true; }
t = neg ? -qint64(i) : qint64(i); return true;
}
if (!getInteger(i,neg)) { return false; }
if ( neg && quint64(std::numeric_limits<qint64>::max())+1<i) { Q_VERIFY(isErrorFiltered(qBindExpectedSmallerNumber)); t=std::numeric_limits<qint64>::min(); return true; } // using isErrorFiltered result to return false (allowing user to bind with a larger type) would require a cachedNumber like in JSON
if (!neg && quint64(std::numeric_limits<qint64>::max()) <i) { Q_VERIFY(isErrorFiltered(qBindExpectedSmallerNumber)); t=std::numeric_limits<qint64>::max(); return true; }
t = neg ? -qint64(i) : qint64(i); return true;
}
bool tryItem( QIdentifierLiteral u) { if (caching) { return caching->tryItem(u); }
QIdentifier s;
......
......@@ -303,8 +303,8 @@ protected:
bool tryBind ( qint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
if (getNumber()==None) return false;
if (cachedNumber==FloatingPoint) { if (isErrorFiltered(qBindExpectedInteger)) { t=i; cachedNumber=None; return true; } return false; }
if (!neg && quint64( std::numeric_limits<qint64>::max())<i) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { t=std::numeric_limits<qint64>::max(); cachedNumber=None; return true; } return false; }
if ( neg && quint64(-std::numeric_limits<qint64>::min())<i) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { t=std::numeric_limits<qint64>::min(); cachedNumber=None; return true; } return false; }
if (!neg && quint64(std::numeric_limits<qint64>::max()) <i) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { t=std::numeric_limits<qint64>::max(); cachedNumber=None; return true; } return false; }
if ( neg && quint64(std::numeric_limits<qint64>::max())+1<i) { if (isErrorFiltered(qBindExpectedSmallerNumber)) { t=std::numeric_limits<qint64>::min(); cachedNumber=None; return true; } return false; }
t = neg ? -qint64(i) : qint64(i); cachedNumber=None; return true; }
bool tryBind ( QVariant& dst) { if (caching) { return caching->tryBind(dst) && cacheOut(); }
{
......
......@@ -44,7 +44,7 @@
Class ( ) noexcept = default; \
Class (Class&& o) noexcept = default; \
Class& operator=(Class&& o) noexcept = default;
#define Q_VERIFY(Predicate) if (!(Predicate)) { Q_ASSERT(false); }
#include <QtCore/qvariant.h>
#include "QData.h"
......@@ -787,12 +787,22 @@ struct QAbstractValueReader : public QAbstractValue
virtual bool tryItem( ) = 0;
virtual bool tryItem(QIdentifier& n) = 0;
virtual bool tryItem(QIdentifierLiteral n) { QIdentifier id; return tryItem(id) && id.utf8()==n.utf8(); }
// TODO
// QIdentifier id;
// for (;;) {
// if (!tryItem(id))
// return false;
// if (id.utf8()==n.utf8())
// return true;
// Q_VERIFY(isErrorFiltered(qBindUnexpectedItem) && tryAny())
// }
// }
virtual bool tryBind( const char* u) { return tryBind(QUtf8DataView(u)); }
virtual bool tryBind( QUtf8DataView u) { QUtf8Data r; if (tryBind(r) && r.utf8()==u.data()) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(QAsciiDataView a) { QUtf8Data r; if (tryBind(r) && r.utf8()==a.data()) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QLatin1String l) { QString r; if (tryBind(r) && r==l ) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QStringView s) { QString r; if (tryBind(r) && r==s ) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QUtf8DataView u) { QUtf8Data r; if (!tryBind(r)) return false; Q_VERIFY(r.utf8()==u.data() || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(QAsciiDataView a) { QUtf8Data r; if (!tryBind(r)) return false; Q_VERIFY(r.utf8()==a.data() || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QLatin1String l) { QString r; if (!tryBind(r)) return false; Q_VERIFY(r ==l || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QStringView s) { QString r; if (!tryBind(r)) return false; Q_VERIFY(r ==s || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QUtf8Data& s) = 0;
virtual bool tryBind( QString& s) { QUtf8Data u; if (!tryBind(u)) return false; s=QString::fromUtf8(u.utf8()); return true; }
......@@ -800,6 +810,8 @@ struct QAbstractValueReader : public QAbstractValue
if (u.utf8().compare("true" , Qt::CaseInsensitive)==0) { b=true ; }
else if (u.utf8().compare("false", Qt::CaseInsensitive)==0) { b=false; }
else { return false; } return true; }
// TODO Q_VERIFY(isErrorFiltered(qBindExpectedSmallerNumber)); n=... return true;
virtual bool tryBind( qint8& n) { qint64 l; if (!tryBind(l)) return false; if (l<std::numeric_limits< qint8>::min() || std::numeric_limits< qint8>::max()<l) { isErrorFiltered(qBindExpectedSmallerNumber); return false; } n= qint8(l); return true; }
virtual bool tryBind( quint8& n) { quint64 l; if (!tryBind(l)) return false; if ( std::numeric_limits< quint8>::max()<l) { isErrorFiltered(qBindExpectedSmallerNumber); return false; } n= quint8(l); return true; }
virtual bool tryBind( qint16& n) { qint64 l; if (!tryBind(l)) return false; if (l<std::numeric_limits< qint16>::min() || std::numeric_limits< qint16>::max()<l) { isErrorFiltered(qBindExpectedSmallerNumber); return false; } n= qint16(l); return true; }
......@@ -829,37 +841,37 @@ struct QAbstractValueReader : public QAbstractValue
return isErrorFiltered(qBindUnexpectedValue) && tryAny();
}
virtual bool tryBind(const QUtf8Data& k) { QUtf8Data r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; } // FIXME move to QCur or QVal since tryAny is unnecessary even if we return false to short-circuit further bind
virtual bool tryBind(const QString& k) { QString r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const bool& k) { bool r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const qint8& k) { qint8 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const quint8& k) { quint8 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const qint16& k) { qint16 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const quint16& k) { quint16 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const qint32& k) { qint32 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const quint32& k) { quint32 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const qint64& k) { qint64 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const quint64& k) { quint64 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const float& k) { float r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; } // TODO silent warning
virtual bool tryBind(const double& k) { double r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; } // TODO silent warning
virtual bool tryBind(const QByteArray& k) { QByteArray r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const QVariant& k) { QVariant r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QUtf8Data&& k) { QUtf8Data r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QString&& k) { QString r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( bool&& k) { bool r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( qint8&& k) { qint8 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( quint8&& k) { quint8 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( qint16&& k) { qint16 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( quint16&& k) { quint16 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( qint32&& k) { qint32 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( quint32&& k) { quint32 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( qint64&& k) { qint64 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( quint64&& k) { quint64 r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( float&& k) { float r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; } // TODO silent warning
virtual bool tryBind( double&& k) { double r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; } // TODO silent warning
virtual bool tryBind( QByteArray&& k) { QByteArray r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind( QVariant&& k) { QVariant r; if (tryBind(r) && k==r) return true; isErrorFiltered(qBindExpectedConstant); return false; }
virtual bool tryBind(const QUtf8Data& k) { QUtf8Data r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const QString& k) { QString r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const bool& k) { bool r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const qint8& k) { qint8 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const quint8& k) { quint8 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const qint16& k) { qint16 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const quint16& k) { quint16 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const qint32& k) { qint32 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const quint32& k) { quint32 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const qint64& k) { qint64 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const quint64& k) { quint64 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const float& k) { float r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; } // TODO silent warning
virtual bool tryBind(const double& k) { double r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; } // TODO silent warning
virtual bool tryBind(const QByteArray& k) { QByteArray r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind(const QVariant& k) { QVariant r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QUtf8Data&& k) { QUtf8Data r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QString&& k) { QString r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( bool&& k) { bool r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( qint8&& k) { qint8 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( quint8&& k) { quint8 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( qint16&& k) { qint16 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( quint16&& k) { quint16 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( qint32&& k) { qint32 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( quint32&& k) { quint32 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( qint64&& k) { qint64 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( quint64&& k) { quint64 r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( float&& k) { float r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; } // TODO silent warning
virtual bool tryBind( double&& k) { double r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; } // TODO silent warning
virtual bool tryBind( QByteArray&& k) { QByteArray r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryBind( QVariant&& k) { QVariant r; if (!tryBind(r)) return false; Q_VERIFY(k==r || isErrorFiltered(qBindExpectedConstant)); return true; }
virtual bool tryAny() {
QSuspendedValueErrorHandler(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment