Bootstrap: disable the entire convert/view QMetaType code

Nothing is using it and this greatly simplifies the code, both for the
bootstrap build and for the maintenance of QtCore.

Change-Id: I5c48d16ccdd468834a80fffdf6ec94d06ae655dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2025-01-08 00:43:42 -03:00
parent c1026f2ff0
commit c9ca74660b

View File

@ -983,6 +983,7 @@ static constexpr struct : QMetaTypeModuleHelper
} }
} }
#ifndef QT_BOOTSTRAPPED
bool convert(const void *from, int fromTypeId, void *to, int toTypeId) const override bool convert(const void *from, int fromTypeId, void *to, int toTypeId) const override
{ {
Q_ASSERT(fromTypeId != toTypeId); Q_ASSERT(fromTypeId != toTypeId);
@ -1015,7 +1016,6 @@ static constexpr struct : QMetaTypeModuleHelper
QMETATYPE_CONVERTER(To, From, result = double(source); return true;) QMETATYPE_CONVERTER(To, From, result = double(source); return true;)
#define QMETATYPE_CONVERTER_ASSIGN_NUMBER(To, From) \ #define QMETATYPE_CONVERTER_ASSIGN_NUMBER(To, From) \
QMETATYPE_CONVERTER(To, From, result = To::number(source); return true;) QMETATYPE_CONVERTER(To, From, result = To::number(source); return true;)
#ifndef QT_BOOTSTRAPPED
#define CONVERT_CBOR_AND_JSON(To) \ #define CONVERT_CBOR_AND_JSON(To) \
QMETATYPE_CONVERTER(To, QCborValue, \ QMETATYPE_CONVERTER(To, QCborValue, \
if constexpr(std::is_same_v<To, Bool>) { \ if constexpr(std::is_same_v<To, Bool>) { \
@ -1047,9 +1047,6 @@ static constexpr struct : QMetaTypeModuleHelper
} \ } \
return true; \ return true; \
) )
#else
#define CONVERT_CBOR_AND_JSON(To)
#endif
#define INTEGRAL_CONVERTER(To) \ #define INTEGRAL_CONVERTER(To) \
QMETATYPE_CONVERTER_ASSIGN(To, Bool); \ QMETATYPE_CONVERTER_ASSIGN(To, Bool); \
@ -1134,7 +1131,6 @@ static constexpr struct : QMetaTypeModuleHelper
FLOAT_CONVERTER(Float); FLOAT_CONVERTER(Float);
FLOAT_CONVERTER(Double); FLOAT_CONVERTER(Double);
#ifndef QT_BOOTSTRAPPED
QMETATYPE_CONVERTER_ASSIGN(QUrl, QString); QMETATYPE_CONVERTER_ASSIGN(QUrl, QString);
QMETATYPE_CONVERTER(QUrl, QCborValue, QMETATYPE_CONVERTER(QUrl, QCborValue,
if (source.isUrl()) { if (source.isUrl()) {
@ -1143,7 +1139,6 @@ static constexpr struct : QMetaTypeModuleHelper
} }
return false; return false;
); );
#endif
#if QT_CONFIG(itemmodel) #if QT_CONFIG(itemmodel)
QMETATYPE_CONVERTER_ASSIGN(QModelIndex, QPersistentModelIndex); QMETATYPE_CONVERTER_ASSIGN(QModelIndex, QPersistentModelIndex);
QMETATYPE_CONVERTER_ASSIGN(QPersistentModelIndex, QModelIndex); QMETATYPE_CONVERTER_ASSIGN(QPersistentModelIndex, QModelIndex);
@ -1221,7 +1216,6 @@ static constexpr struct : QMetaTypeModuleHelper
QMETATYPE_CONVERTER(QString, QStringList, QMETATYPE_CONVERTER(QString, QStringList,
return (source.size() == 1) ? (result = source.at(0), true) : false; return (source.size() == 1) ? (result = source.at(0), true) : false;
); );
#ifndef QT_BOOTSTRAPPED
QMETATYPE_CONVERTER(QString, QUrl, result = source.toString(); return true;); QMETATYPE_CONVERTER(QString, QUrl, result = source.toString(); return true;);
QMETATYPE_CONVERTER(QString, QJsonValue, QMETATYPE_CONVERTER(QString, QJsonValue,
if (source.isString() || source.isNull()) { if (source.isString() || source.isNull()) {
@ -1230,7 +1224,6 @@ static constexpr struct : QMetaTypeModuleHelper
} }
return false; return false;
); );
#endif
QMETATYPE_CONVERTER(QString, Nullptr, Q_UNUSED(source); result = QString(); return true;); QMETATYPE_CONVERTER(QString, Nullptr, Q_UNUSED(source); result = QString(); return true;);
// QByteArray // QByteArray
@ -1260,12 +1253,10 @@ static constexpr struct : QMetaTypeModuleHelper
); );
QMETATYPE_CONVERTER(QByteArray, Nullptr, Q_UNUSED(source); result = QByteArray(); return true;); QMETATYPE_CONVERTER(QByteArray, Nullptr, Q_UNUSED(source); result = QByteArray(); return true;);
#ifndef QT_BOOTSTRAPPED
QMETATYPE_CONVERTER(QString, QUuid, result = source.toString(); return true;); QMETATYPE_CONVERTER(QString, QUuid, result = source.toString(); return true;);
QMETATYPE_CONVERTER(QUuid, QString, result = QUuid(source); return true;); QMETATYPE_CONVERTER(QUuid, QString, result = QUuid(source); return true;);
QMETATYPE_CONVERTER(QByteArray, QUuid, result = source.toByteArray(); return true;); QMETATYPE_CONVERTER(QByteArray, QUuid, result = source.toByteArray(); return true;);
QMETATYPE_CONVERTER(QUuid, QByteArray, result = QUuid(source); return true;); QMETATYPE_CONVERTER(QUuid, QByteArray, result = QUuid(source); return true;);
#endif
#ifndef QT_NO_GEOM_VARIANT #ifndef QT_NO_GEOM_VARIANT
QMETATYPE_CONVERTER(QSize, QSizeF, result = source.toSize(); return true;); QMETATYPE_CONVERTER(QSize, QSizeF, result = source.toSize(); return true;);
@ -1280,7 +1271,6 @@ static constexpr struct : QMetaTypeModuleHelper
QMETATYPE_CONVERTER(QStringList, QString, result = QStringList() << source; return true;); QMETATYPE_CONVERTER(QStringList, QString, result = QStringList() << source; return true;);
#ifndef QT_NO_VARIANT
QMETATYPE_CONVERTER(QByteArrayList, QVariantList, QMETATYPE_CONVERTER(QByteArrayList, QVariantList,
result.reserve(source.size()); result.reserve(source.size());
for (const auto &v: source) for (const auto &v: source)
@ -1317,8 +1307,6 @@ static constexpr struct : QMetaTypeModuleHelper
result.insert(it.key(), it.value()); result.insert(it.key(), it.value());
return true; return true;
); );
#endif // !QT_NO_VARIANT
#ifndef QT_BOOTSTRAPPED
QMETATYPE_CONVERTER_ASSIGN(QCborValue, QString); QMETATYPE_CONVERTER_ASSIGN(QCborValue, QString);
QMETATYPE_CONVERTER(QString, QCborValue, QMETATYPE_CONVERTER(QString, QCborValue,
if (source.isContainer() || source.isTag()) if (source.isContainer() || source.isTag())
@ -1637,8 +1625,6 @@ static constexpr struct : QMetaTypeModuleHelper
return true; return true;
); );
#endif
QMETATYPE_CONVERTER(QDate, QDateTime, result = source.date(); return true;); QMETATYPE_CONVERTER(QDate, QDateTime, result = source.date(); return true;);
QMETATYPE_CONVERTER(QTime, QDateTime, result = source.time(); return true;); QMETATYPE_CONVERTER(QTime, QDateTime, result = source.time(); return true;);
QMETATYPE_CONVERTER(QDateTime, QDate, result = source.startOfDay(); return true;); QMETATYPE_CONVERTER(QDateTime, QDate, result = source.startOfDay(); return true;);
@ -1660,6 +1646,7 @@ static constexpr struct : QMetaTypeModuleHelper
} }
return false; return false;
} }
#endif // !QT_BOOTSTRAPPED
} metatypeHelper = {}; } metatypeHelper = {};
Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper = nullptr; Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper = nullptr;
@ -1676,6 +1663,7 @@ static const QMetaTypeModuleHelper *qModuleHelperForType(int type)
return nullptr; return nullptr;
} }
#ifndef QT_BOOTSTRAPPED
template<typename T, typename Key> template<typename T, typename Key>
class QMetaTypeFunctionRegistry class QMetaTypeFunctionRegistry
{ {
@ -1841,6 +1829,7 @@ void QMetaType::unregisterConverterFunction(QMetaType from, QMetaType to)
return; return;
customTypesConversionRegistry()->remove(from.id(), to.id()); customTypesConversionRegistry()->remove(from.id(), to.id());
} }
#endif // !QT_BOOTSTRAPPED
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
@ -1933,6 +1922,7 @@ static QMetaEnum metaEnumFromType(QMetaType t)
} }
#endif #endif
#ifndef QT_BOOTSTRAPPED
static bool convertFromEnum(QMetaType fromType, const void *from, QMetaType toType, void *to) static bool convertFromEnum(QMetaType fromType, const void *from, QMetaType toType, void *to)
{ {
qlonglong ll; qlonglong ll;
@ -2058,7 +2048,6 @@ static bool convertToEnum(QMetaType fromType, const void *from, QMetaType toType
} }
} }
#ifndef QT_BOOTSTRAPPED
static bool convertIterableToVariantList(QMetaType fromType, const void *from, void *to) static bool convertIterableToVariantList(QMetaType fromType, const void *from, void *to)
{ {
QSequentialIterable list; QSequentialIterable list;
@ -2343,7 +2332,6 @@ static bool convertMetaObject(QMetaType fromType, const void *from, QMetaType to
} }
return false; return false;
} }
#endif // !QT_BOOTSTRAPPED
/*! /*!
\fn bool QMetaType::convert(const void *from, int fromTypeId, void *to, int toTypeId) \fn bool QMetaType::convert(const void *from, int fromTypeId, void *to, int toTypeId)
@ -2400,8 +2388,6 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
} }
} }
#ifndef QT_BOOTSTRAPPED
# ifndef QT_NO_VARIANT
if (toTypeId == QVariantPair && convertIterableToVariantPair(fromType, from, to)) if (toTypeId == QVariantPair && convertIterableToVariantPair(fromType, from, to))
return true; return true;
@ -2414,7 +2400,6 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
if (toTypeId == QVariantHash && convertIterableToVariantHash(fromType, from, to)) if (toTypeId == QVariantHash && convertIterableToVariantHash(fromType, from, to))
return true; return true;
# endif
if (toTypeId == qMetaTypeId<QSequentialIterable>()) if (toTypeId == qMetaTypeId<QSequentialIterable>())
return convertToSequentialIterable(fromType, from, to); return convertToSequentialIterable(fromType, from, to);
@ -2423,9 +2408,6 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
return convertToAssociativeIterable(fromType, from, to); return convertToAssociativeIterable(fromType, from, to);
return convertMetaObject(fromType, from, toType, to); return convertMetaObject(fromType, from, toType, to);
#else
return false;
#endif
} }
/*! /*!
@ -2445,7 +2427,6 @@ bool QMetaType::view(QMetaType fromType, void *from, QMetaType toType, void *to)
if (f) if (f)
return (*f)(from, to); return (*f)(from, to);
#ifndef QT_BOOTSTRAPPED
if (toTypeId == qMetaTypeId<QSequentialIterable>()) if (toTypeId == qMetaTypeId<QSequentialIterable>())
return viewAsSequentialIterable(fromType, from, to); return viewAsSequentialIterable(fromType, from, to);
@ -2453,9 +2434,6 @@ bool QMetaType::view(QMetaType fromType, void *from, QMetaType toType, void *to)
return viewAsAssociativeIterable(fromType, from, to); return viewAsAssociativeIterable(fromType, from, to);
return convertMetaObject(fromType, from, toType, to); return convertMetaObject(fromType, from, toType, to);
#else
return false;
#endif
} }
/*! /*!
@ -2487,7 +2465,6 @@ bool QMetaType::canView(QMetaType fromType, QMetaType toType)
if (f) if (f)
return true; return true;
#ifndef QT_BOOTSTRAPPED
if (toTypeId == qMetaTypeId<QSequentialIterable>()) if (toTypeId == qMetaTypeId<QSequentialIterable>())
return canImplicitlyViewAsSequentialIterable(fromType); return canImplicitlyViewAsSequentialIterable(fromType);
@ -2496,7 +2473,6 @@ bool QMetaType::canView(QMetaType fromType, QMetaType toType)
if (canConvertMetaObject(fromType, toType)) if (canConvertMetaObject(fromType, toType))
return true; return true;
#endif
return false; return false;
} }
@ -2592,14 +2568,11 @@ bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
if (f) if (f)
return true; return true;
#ifndef QT_BOOTSTRAPPED
if (toTypeId == qMetaTypeId<QSequentialIterable>()) if (toTypeId == qMetaTypeId<QSequentialIterable>())
return canConvertToSequentialIterable(fromType); return canConvertToSequentialIterable(fromType);
if (toTypeId == qMetaTypeId<QAssociativeIterable>()) if (toTypeId == qMetaTypeId<QAssociativeIterable>())
return canConvertToAssociativeIterable(fromType); return canConvertToAssociativeIterable(fromType);
#endif
#ifndef QT_NO_VARIANT
if (toTypeId == QVariantList if (toTypeId == QVariantList
&& canConvert(fromType, QMetaType::fromType<QSequentialIterable>())) { && canConvert(fromType, QMetaType::fromType<QSequentialIterable>())) {
return true; return true;
@ -2613,7 +2586,6 @@ bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
if (toTypeId == QVariantPair && hasRegisteredConverterFunction( if (toTypeId == QVariantPair && hasRegisteredConverterFunction(
fromType, QMetaType::fromType<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) fromType, QMetaType::fromType<QtMetaTypePrivate::QPairVariantInterfaceImpl>()))
return true; return true;
#endif
if (fromType.flags() & IsEnumeration) { if (fromType.flags() & IsEnumeration) {
if (toTypeId == QString || toTypeId == QByteArray) if (toTypeId == QString || toTypeId == QByteArray)
@ -2627,10 +2599,8 @@ bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
} }
if (toTypeId == Nullptr && fromType.flags() & IsPointer) if (toTypeId == Nullptr && fromType.flags() & IsPointer)
return true; return true;
#ifndef QT_BOOTSTRAPPED
if (canConvertMetaObject(fromType, toType)) if (canConvertMetaObject(fromType, toType))
return true; return true;
#endif
return false; return false;
} }
@ -2727,6 +2697,7 @@ bool QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaT
const QMetaType to = QMetaType::fromType<QIterable<QMetaAssociation>>(); const QMetaType to = QMetaType::fromType<QIterable<QMetaAssociation>>();
return QMetaType::hasRegisteredMutableViewFunction(m, to); return QMetaType::hasRegisteredMutableViewFunction(m, to);
} }
#endif // !QT_BOOTSTRAPPED
/*! /*!
\fn const char *QMetaType::typeName(int typeId) \fn const char *QMetaType::typeName(int typeId)