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 /sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | |
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>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
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>. |