diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-05-18 12:55:11 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-18 22:07:53 +0000 |
commit | 39748d5e133fb860f3dfdac34d319b09553be7a9 (patch) | |
tree | 4695fb910111fd02cb43f28eb80b21d9c7cb2d19 | |
parent | 9fe9c110c5a951f4440015f2a36ac9bc949cd6cc (diff) |
shiboken6: Skip Q_ENUM helper functions when PySide extensions are enabled
The helper functions qt_getEnumMetaObject() and qt_getEnumName()
defined by Q_ENUM had to be rejected in the typesystem files in each
namespace. Pass the ApiExtractor flags to the meta builder to cleanly
detect all Qt special functions and automatically reject them when
PySide extensions are enabled.
[ChangeLog][shiboken6] The Q_ENUM helper functions
qt_getEnumMetaObject() and qt_getEnumName() are now automatically
rejected when PySide extensions are enabled.
Fixes: PYSIDE-1932
Change-Id: Iceb5f0c3175ecaef657ae71adf6a5b8bf48af740
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 14c6809ec52ea0583e310825c158fe0e0ab68883)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
5 files changed, 27 insertions, 11 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 7ac0e95ca..086de7e69 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -520,8 +520,6 @@ <rejection class="QFile" function-name="setEncodingFunction"/> <rejection class="QRegion" function-name="cleanUp"/> <rejection class="QSettings" function-name="registerFormat"/> - <rejection class="Qt" function-name="qt_getEnumMetaObject"/> - <rejection class="Qt" function-name="qt_getEnumName"/> <namespace-type name="Qt"> <extra-includes> diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index 5fd6ce51e..995e1f316 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -1899,18 +1899,27 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio return nullptr; } const QString &functionName = functionItem->name(); - QString className; - if (currentClass) { + const QString className = currentClass != nullptr ? + currentClass->typeEntry()->qualifiedCppName() : QString{}; + + if (m_apiExtractorFlags.testFlag(ApiExtractorFlag::UsePySideExtensions)) { + // Skip enum helpers generated by Q_ENUM + if ((currentClass == nullptr || currentClass->isNamespace()) + && (functionName == u"qt_getEnumMetaObject" || functionName == u"qt_getEnumName")) { + return nullptr; + } + // Clang: Skip qt_metacast(), qt_metacall(), expanded from Q_OBJECT // and overridden metaObject(), QGADGET helpers - if (functionName == u"qt_check_for_QGADGET_macro" - || functionName.startsWith(u"qt_meta")) { - return nullptr; + if (currentClass != nullptr) { + if (functionName == u"qt_check_for_QGADGET_macro" + || functionName.startsWith(u"qt_meta")) { + return nullptr; + } + if (functionName == u"metaObject" && className != u"QObject") + return nullptr; } - className = currentClass->typeEntry()->qualifiedCppName(); - if (functionName == u"metaObject" && className != u"QObject") - return nullptr; - } + } // PySide extensions // Store original signature with unresolved typedefs for message/log purposes const QString originalQualifiedSignatureWithReturn = @@ -3389,6 +3398,11 @@ void AbstractMetaBuilder::setSkipDeprecated(bool value) d->m_skipDeprecated = value; } +void AbstractMetaBuilder::setApiExtractorFlags(ApiExtractorFlags flags) +{ + d->m_apiExtractorFlags = flags; +} + // PYSIDE-975: When receiving an absolute path name from the code model, try // to resolve it against the include paths set on shiboken in order to recreate // relative paths like #include <foo/bar.h>. diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h index afbba9e86..ebdfce1c7 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h @@ -95,6 +95,8 @@ public: void setSkipDeprecated(bool value); + void setApiExtractorFlags(ApiExtractorFlags flags); + enum TranslateTypeFlag { DontResolveType = 0x1 }; diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h index 18de68047..34f590945 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h @@ -241,6 +241,7 @@ public: QStringList m_headerPaths; mutable QHash<QString, Include> m_resolveIncludeHash; QList<TypeClassEntry> m_typeSystemTypeDefs; // look up metatype->class for type system typedefs + ApiExtractorFlags m_apiExtractorFlags; bool m_skipDeprecated = false; static bool m_useGlobalHeader; static bool m_codeModelTestMode; diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp index d0265c16a..4a06c1320 100644 --- a/sources/shiboken6/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp @@ -265,6 +265,7 @@ bool ApiExtractorPrivate::runHelper(ApiExtractorFlags flags) m_builder->setGlobalHeaders(m_cppFileNames); m_builder->setSkipDeprecated(m_skipDeprecated); m_builder->setHeaderPaths(m_includePaths); + m_builder->setApiExtractorFlags(flags); QByteArrayList arguments; const auto clangOptionsSize = m_clangOptions.size(); |