aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsmart/smart.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-15 14:45:14 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-18 11:59:09 +0100
commit1986d8179d2edd4171bb1460e2a0ee97d6ee3e18 (patch)
treea382c9154eadc7138abad7888d5c0cc376414788 /sources/shiboken6/tests/libsmart/smart.cpp
parent1a3d15e0e24bcafc6a273140982a91e42d676fdb (diff)
shiboken6: Generate rich comparison for smart pointers
Add the pointee class to the GeneratorContext for smart pointers and generate a comparison operator for the pointee. Use the pointee's comparison operators if there are any; else generate a simple equality check based on pointee address. [ChangeLog][shiboken6] Comparison operators for pointees of smart pointers are now generated. Fixes: PYSIDE-1711 Change-Id: Ib21b90a4ccfe635ea051831a5b66a79ded06b194 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/tests/libsmart/smart.cpp')
-rw-r--r--sources/shiboken6/tests/libsmart/smart.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsmart/smart.cpp b/sources/shiboken6/tests/libsmart/smart.cpp
index 81fa30c7e..6908c7881 100644
--- a/sources/shiboken6/tests/libsmart/smart.cpp
+++ b/sources/shiboken6/tests/libsmart/smart.cpp
@@ -137,6 +137,18 @@ int Obj::takeSharedPtrToInteger(SharedPtr<Integer> pInt)
return pInt->value();
}
+SharedPtr<Integer> Obj::createSharedPtrToInteger(int value)
+{
+ auto *i = new Integer;
+ i->setValue(value);
+ return SharedPtr<Integer>(i);
+}
+
+SharedPtr<Integer> Obj::createNullSharedPtrToInteger()
+{
+ return {};
+}
+
SharedPtr<const Integer> Obj::giveSharedPtrToConstInteger()
{
SharedPtr<const Integer> co(new Integer);
@@ -194,6 +206,13 @@ void Integer::setValue(int v)
m_int = v;
}
+int Integer::compare(const Integer &rhs) const
+{
+ if (m_int < rhs.m_int)
+ return -1;
+ return m_int > rhs.m_int ? 1 : 0;
+}
+
void Integer::printInteger() const
{
if (shouldPrint())