From 9b41055fe043a1f190a06e0cc8b4fc82398261b9 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Tue, 30 Aug 2022 16:57:55 +0200 Subject: PyEnum: Simplify code generator because of full forgiveness PyEnum needed extra signature handling in the parser.py file and the abstractmetatype.cpp file because we needed to decide at runtime what names are to be generated. With the full forgiveness mode, all special handling is still implemented, but the old versions of the enum representation can also always be used. The unexpected funny side effect is that we now can remove all special handling that has been implemented for these cases. The way how things are written is no longer relevant, although the new version is still the only one advertized. Change-Id: I76efc8ffc646d3a04d974d6776a1c9c2b5ffec70 Task-number: PYSIDE-1735 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 5419080e948c89d4f271d7d4a9bf980f647d53f5) Reviewed-by: Adrian Herrmann Reviewed-by: Friedemann Kleint --- sources/shiboken6/ApiExtractor/abstractmetatype.cpp | 12 ++---------- .../files.dir/shibokensupport/signature/parser.py | 12 ------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp index d47b25ef2..b5fa4100c 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp @@ -668,16 +668,8 @@ 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" - 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(m_typeEntry); - auto enumTypeEntry = flagsTypeEntry->originator(); - result = m_typeEntry->targetLangPackage() + u".^^"_s - + flagsTypeEntry->targetLangName() + u"^^"_s - + enumTypeEntry->targetLangName() + u"^^"_s; - } - + if (m_typeEntry->isFlags()) + result = m_typeEntry->qualifiedTargetLangName(); result.replace(u"::"_s, u"."_s); return result; } diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py index 1d4dadc55..c877f1ee4 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py @@ -434,18 +434,6 @@ def handle_retvar(obj): def calculate_props(line): - # PYSIDE-1735: QFlag is now divided into fields for future Python Enums, like - # "PySide.QtCore.^^Qt.ItemFlags^^Qt.ItemFlag^^" - # Resolve that until Enum is finally settled. - while "^^" in line: - parts = line.split("^^", 3) - selected = EnumSelect.SELECTION - line = parts[0] + parts[selected.value] + parts[3] - if selected is EnumSelect.NEW: - _old, _new = EnumSelect.OLD.value, EnumSelect.NEW.value - line = re.sub(rf"\b{parts[_old]}\b", parts[_new], line) - type_map[parts[_old]] = parts[_new] - parsed = SimpleNamespace(**_parse_line(line.strip())) arglist = parsed.arglist annotations = {} -- cgit v1.2.3