aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-07-25 12:54:21 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-07-25 14:53:52 +0000
commitf693a117417426603b9ee3a318b65b82722c884e (patch)
treeb9d5bf8d2dd1deaeec7b837623ef35a6e6d80c35
parent15c3f3c1a32037ff21841af22199951581ccbf8c (diff)
shiboken6: Make it possible to override a C++ deprecation attribute
Task-number: PYSIDE-2394 Change-Id: Ib5af48820eafdd9767a30317bea6526f9cb799ea Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit c06f7743b9a35f90cade1b653a4842c6fab70c06) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafunction.cpp23
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.h3
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp9
-rw-r--r--sources/shiboken6/doc/typesystem_manipulating_objects.rst6
4 files changed, 29 insertions, 12 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
index 92c2a1e7f..c1758bc91 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
@@ -28,6 +28,8 @@
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
+#include <algorithm>
+
using namespace Qt::StringLiterals;
// Cache FunctionModificationList in a flat list per class (0 for global
@@ -708,15 +710,22 @@ void AbstractMetaFunction::addArgument(const AbstractMetaArgument &argument)
d->m_arguments << argument;
}
+static bool modifiedDeprecated(const FunctionModification &mod)
+{
+ return mod.modifiers().testFlag(FunctionModification::Deprecated);
+}
+
+static bool modifiedUndeprecated(const FunctionModification &mod)
+{
+ return mod.modifiers().testFlag(FunctionModification::Undeprecated);
+}
+
bool AbstractMetaFunction::isDeprecated() const
{
- if (d->m_attributes.testFlag(Attribute::Deprecated))
- return true;
- for (const auto &modification : modifications(declaringClass())) {
- if (modification.isDeprecated())
- return true;
- }
- return false;
+ const auto &mods = modifications(declaringClass());
+ return d->m_attributes.testFlag(Attribute::Deprecated)
+ ? std::none_of(mods.cbegin(), mods.cend(), modifiedUndeprecated)
+ : std::any_of(mods.cbegin(), mods.cend(), modifiedDeprecated);
}
bool AbstractMetaFunction::isConstructor() const
diff --git a/sources/shiboken6/ApiExtractor/modifications.h b/sources/shiboken6/ApiExtractor/modifications.h
index 65ed81ff8..44caf1303 100644
--- a/sources/shiboken6/ApiExtractor/modifications.h
+++ b/sources/shiboken6/ApiExtractor/modifications.h
@@ -155,7 +155,8 @@ public:
CodeInjection = 0x1000,
Rename = 0x2000,
Deprecated = 0x4000,
- ReplaceExpression = 0x8000
+ Undeprecated = 0x8000,
+ ReplaceExpression = 0x10000
};
Q_DECLARE_FLAGS(Modifiers, ModifierFlag);
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index d99626219..f680f1cda 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -2726,7 +2726,7 @@ bool TypeSystemParser::parseModifyFunction(const ConditionalStreamReader &reader
QString access;
bool removed = false;
QString rename;
- bool deprecated = false;
+ std::optional<bool> deprecated;
bool isThread = false;
int overloadNumber = TypeSystem::OverloadNumberUnset;
TypeSystem::ExceptionHandling exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
@@ -2826,8 +2826,11 @@ bool TypeSystemParser::parseModifyFunction(const ConditionalStreamReader &reader
mod.setModifierFlag(m);
}
- if (deprecated)
- mod.setModifierFlag(FunctionModification::Deprecated);
+ if (deprecated.has_value()) {
+ mod.setModifierFlag(deprecated.value()
+ ? FunctionModification::Deprecated
+ : FunctionModification::Undeprecated);
+ }
mod.setRemoved(removed);
diff --git a/sources/shiboken6/doc/typesystem_manipulating_objects.rst b/sources/shiboken6/doc/typesystem_manipulating_objects.rst
index b710dbf67..063c87f41 100644
--- a/sources/shiboken6/doc/typesystem_manipulating_objects.rst
+++ b/sources/shiboken6/doc/typesystem_manipulating_objects.rst
@@ -169,7 +169,8 @@ modification affects.
final="true | false"
overload-number="number"
rename="..."
- snake-case="yes | no | both" />
+ snake-case="yes | no | both"
+ deprecated = "true | false" />
</object-type>
The ``signature`` attribute is a normalized C++ signature, excluding return
@@ -257,6 +258,9 @@ given function in the generated target language API.
The *optional* **snake-case** attribute allows for overriding the value
specified on the class entry or **typesystem** element.
+The *optional* **deprecated** attribute allows for overriding deprecation
+as detected by the C++ attribute. It works in both ways.
+
.. _add-function:
add-function