CBOR: disable UUID and QRegularExpression support in bootstrapped builds

We don't need them.

Drive-by opportunity to ensure byteData() didn't return null. It could
happen.

Change-Id: I74249c52dc02478ba93cfffd16d1e1fc060cdaef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Thiago Macieira 2022-02-08 10:10:11 -08:00
parent a1b2c474fd
commit 1f7089437a
3 changed files with 27 additions and 22 deletions

View File

@ -1861,7 +1861,6 @@ QCborValue::QCborValue(const QUrl &url)
t = Url;
container->elements[1].type = String;
}
#endif
#if QT_CONFIG(regularexpression)
/*!
@ -1900,6 +1899,7 @@ QCborValue::QCborValue(const QUuid &uuid)
// change our type
t = Uuid;
}
#endif
// destructor
void QCborValue::dispose()
@ -2031,7 +2031,6 @@ QUrl QCborValue::toUrl(const QUrl &defaultValue) const
return QUrl::fromEncoded(byteData->asByteArrayView());
}
#endif
#if QT_CONFIG(regularexpression)
/*!
@ -2074,6 +2073,7 @@ QUuid QCborValue::toUuid(const QUuid &defaultValue) const
return QUuid::fromRfc4122(byteData->asByteArrayView());
}
#endif
/*!
\fn QCborArray QCborValue::toArray() const
@ -2896,13 +2896,13 @@ size_t qHash(const QCborValue &value, size_t seed)
#ifndef QT_BOOTSTRAPPED
case QCborValue::Url:
return qHash(value.toUrl(), seed);
#endif
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
case QCborValue::RegularExpression:
return qHash(value.toRegularExpression(), seed);
#endif
# endif
case QCborValue::Uuid:
return qHash(value.toUuid(), seed);
#endif
case QCborValue::Invalid:
return seed;
default:

View File

@ -166,11 +166,11 @@ public:
explicit QCborValue(const QDateTime &dt);
#ifndef QT_BOOTSTRAPPED
explicit QCborValue(const QUrl &url);
#endif
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
explicit QCborValue(const QRegularExpression &rx);
#endif
# endif
explicit QCborValue(const QUuid &uuid);
#endif
~QCborValue() { if (container) dispose(); }
@ -238,11 +238,13 @@ public:
QByteArray toByteArray(const QByteArray &defaultValue = {}) const;
QString toString(const QString &defaultValue = {}) const;
QDateTime toDateTime(const QDateTime &defaultValue = {}) const;
#ifndef QT_BOOTSTRAPPED
QUrl toUrl(const QUrl &defaultValue = {}) const;
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
#endif
# endif
QUuid toUuid(const QUuid &defaultValue = {}) const;
#endif
// only forward-declared, need split functions
QCborArray toArray() const;
@ -385,13 +387,13 @@ public:
#ifndef QT_BOOTSTRAPPED
QUrl toUrl(const QUrl &defaultValue = {}) const
{ return concrete().toUrl(defaultValue); }
#endif
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
{ return concrete().toRegularExpression(defaultValue); }
#endif
# endif
QUuid toUuid(const QUuid &defaultValue = {}) const
{ return concrete().toUuid(defaultValue); }
#endif
// only forward-declared, need split functions. Implemented in qcbor{array,map}.h
inline QCborArray toArray() const;
@ -538,13 +540,13 @@ public:
#ifndef QT_BOOTSTRAPPED
QUrl toUrl(const QUrl &defaultValue = {}) const
{ return concrete().toUrl(defaultValue); }
#endif
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
{ return concrete().toRegularExpression(defaultValue); }
#endif
# endif
QUuid toUuid(const QUuid &defaultValue = {}) const
{ return concrete().toUuid(defaultValue); }
#endif
// only forward-declared, need split functions. Implemented in qcbor{array,map}.h
QCborArray toArray() const;

View File

@ -98,7 +98,6 @@ static QString maybeEncodeTag(const QCborContainerPrivate *d)
{
qint64 tag = d->elements.at(0).value;
const Element &e = d->elements.at(1);
const ByteData *b = d->byteData(e);
switch (tag) {
case qint64(QCborKnownTags::DateTimeString):
@ -115,8 +114,12 @@ static QString maybeEncodeTag(const QCborContainerPrivate *d)
break;
case qint64(QCborKnownTags::Uuid):
if (e.type == QCborValue::ByteArray && b->len == sizeof(QUuid))
#ifndef QT_BOOTSTRAPPED
if (const ByteData *b = d->byteData(e); e.type == QCborValue::ByteArray && b
&& b->len == sizeof(QUuid))
return QUuid::fromRfc4122(b->asByteArrayView()).toString(QUuid::WithoutBraces);
#endif
break;
}
// don't know what to do, bail out
@ -586,15 +589,15 @@ QVariant QCborValue::toVariant() const
#ifndef QT_BOOTSTRAPPED
case Url:
return toUrl();
#endif
#if QT_CONFIG(regularexpression)
# if QT_CONFIG(regularexpression)
case RegularExpression:
return toRegularExpression();
#endif
# endif
case Uuid:
return toUuid();
#endif
case Invalid:
return QVariant();
@ -763,9 +766,9 @@ QCborValue QCborValue::fromVariant(const QVariant &variant)
#ifndef QT_BOOTSTRAPPED
case QMetaType::QUrl:
return QCborValue(variant.toUrl());
#endif
case QMetaType::QUuid:
return QCborValue(variant.toUuid());
#endif
case QMetaType::QVariantList:
return QCborArray::fromVariantList(variant.toList());
case QMetaType::QVariantMap: