aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-04-10 17:22:14 +0200
committerChristian Tismer <tismer@stackless.com>2022-05-20 22:02:41 +0200
commit31deae2a0ea3725d038433f6be91119865a8f399 (patch)
tree317de39eb7c95c534864dff5fc4b8eb75d47a9ca /sources/shiboken6/ApiExtractor/abstractmetatype.cpp
parent6b27f49e58e4a8e24fee10b67fdb02a0fb28fba1 (diff)
PyEnum: Prepare to support both implementations
The enum implementation should be switchable between the old and the new version. This switching is possible only before PySide import. This patch prepares the switching capability for the signature module and installs fields that will affect the global header files. The new version can be selected by setting the environment variable PYSIDE63_OPTION_PYTHON_ENUM=1 or setting sys.pyside63_option_python_enum=1 [ChangeLog][PySide6] The signature module was prepared to support both C++ enums and Python enums. This can be selected at startup. Task-number: PYSIDE-1735 Pick-to: 6.3 Change-Id: I14999e1049fbaaccd00f00d1b7b1257bc9287255 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetatype.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetatype.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
index 78d07c6f9..d96c28ffe 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
@@ -32,6 +32,8 @@
#include "messages.h"
#include "typedatabase.h"
#include "containertypeentry.h"
+#include "enumtypeentry.h"
+#include "flagstypeentry.h"
#include "parser/codemodel.h"
#include "qtcompat.h"
@@ -668,8 +670,16 @@ QString AbstractMetaTypeData::formatPythonSignature() const
result += TypeInfo::indirectionKeyword(i);
// If it is a flags type, we replace it with the full name:
// "PySide6.QtCore.Qt.ItemFlags" instead of "PySide6.QtCore.QFlags<Qt.ItemFlag>"
- if (m_typeEntry->isFlags())
- result = m_typeEntry->qualifiedTargetLangName();
+ if (m_typeEntry->isFlags()) {
+ // PYSIDE-1735: We need to provide both the flags type and the original enum type
+ // as a choice at runtime.
+ auto flagsTypeEntry = static_cast<const FlagsTypeEntry *>(m_typeEntry);
+ auto enumTypeEntry = flagsTypeEntry->originator();
+ result = m_typeEntry->targetLangPackage() + u".^^"_s
+ + flagsTypeEntry->targetLangName() + u"^^"_s
+ + enumTypeEntry->targetLangName() + u"^^"_s;
+ }
+
result.replace(u"::"_s, u"."_s);
return result;
}