diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 22 | ||||
-rw-r--r-- | src/corelib/plugin/qplugin.h | 15 | ||||
-rw-r--r-- | src/corelib/plugin/qplugin_p.h | 4 |
3 files changed, 35 insertions, 6 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 9f877ccda8..35c64180d4 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -69,11 +69,17 @@ static inline int metaDataSignatureLength() static QJsonDocument jsonFromCborMetaData(const char *raw, qsizetype size, QString *errMsg) { - if (Q_UNLIKELY(raw[-1] != '!')) { - *errMsg = QStringLiteral("Invalid metadata signature"); + // extract the keys not stored in CBOR + int qt_metadataVersion = quint8(raw[0]); + int qt_version = qFromBigEndian<quint16>(raw + 1); + int qt_archRequirements = quint8(raw[3]); + if (Q_UNLIKELY(raw[-1] != '!' || qt_metadataVersion != 0)) { + *errMsg = QStringLiteral("Invalid metadata version"); return QJsonDocument(); } + raw += 4; + size -= 4; QByteArray ba = QByteArray::fromRawData(raw, int(size)); QCborParserError err; QCborValue metadata = QCborValue::fromCbor(ba, &err); @@ -88,8 +94,12 @@ static QJsonDocument jsonFromCborMetaData(const char *raw, qsizetype size, QStri return QJsonDocument(); } - // convert the top-level map integer keys QJsonObject o; + o.insert(QLatin1String("version"), qt_version << 8); + o.insert(QLatin1String("debug"), bool(qt_archRequirements & 1)); + o.insert(QLatin1String("archreq"), qt_archRequirements); + + // convert the top-level map integer keys for (auto it : metadata.toMap()) { QString key; if (it.first.isInteger()) { @@ -98,6 +108,12 @@ static QJsonDocument jsonFromCborMetaData(const char *raw, qsizetype size, QStri case int(IntKey): key = QStringLiteral(StringKey); break; QT_PLUGIN_FOREACH_METADATA(CONVERT_TO_STRING) #undef CONVERT_TO_STRING + + case int(QtPluginMetaDataKeys::Requirements): + // special case: recreate the debug key + o.insert(QLatin1String("debug"), bool(it.second.toInteger() & 1)); + key = QStringLiteral("archreq"); + break; } } else { key = it.first.toString(); diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 9922026f97..5aca22497a 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -55,6 +55,21 @@ QT_BEGIN_NAMESPACE # endif #endif +inline constexpr unsigned char qPluginArchRequirements() +{ + return 0 +#ifndef QT_NO_DEBUG + | 1 +#endif +#ifdef __AVX2__ + | 2 +# ifdef __AVX512F__ + | 4 +# endif +#endif + ; +} + typedef QObject *(*QtPluginInstanceFunction)(); typedef const char *(*QtPluginMetaDataFunction)(); diff --git a/src/corelib/plugin/qplugin_p.h b/src/corelib/plugin/qplugin_p.h index 99ee16a3e8..717129268b 100644 --- a/src/corelib/plugin/qplugin_p.h +++ b/src/corelib/plugin/qplugin_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE enum class QtPluginMetaDataKeys { QtVersion, - Debug, + Requirements, IID, ClassName, MetaData @@ -66,8 +66,6 @@ enum class QtPluginMetaDataKeys { // F(IntKey, StringKey, Description) // Keep this list sorted in the order moc should output. #define QT_PLUGIN_FOREACH_METADATA(F) \ - F(QtPluginMetaDataKeys::QtVersion, "version", "Qt version built against") \ - F(QtPluginMetaDataKeys::Debug, "debug", "Whether it is a debug build") \ F(QtPluginMetaDataKeys::IID, "IID", "Plugin's Interface ID") \ F(QtPluginMetaDataKeys::ClassName, "className", "Plugin class name") \ F(QtPluginMetaDataKeys::MetaData, "MetaData", "Other meta data") |