aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-07-25 12:54:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-07-25 16:04:28 +0200
commitc06f7743b9a35f90cade1b653a4842c6fab70c06 (patch)
tree27d0b68e1d8abc21337912a8c5d3ddf421c474bb
parentc8ad350819b8c5134cfb86239b8f447a18245e44 (diff)
shiboken6: Make it possible to override a C++ deprecation attribute
Pick-to: 6.5 Task-number: PYSIDE-2394 Change-Id: Ib5af48820eafdd9767a30317bea6526f9cb799ea Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-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 4dc9b3611..7b4d27b8b 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
@@ -701,15 +703,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