diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-07-26 11:50:09 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-08-01 11:24:34 +0200 |
commit | b8c5e37cbe9c58bbee00c60646935e76313ab0da (patch) | |
tree | e2d53d3905120145541979efcf32f49096edc2c0 /sources/shiboken6/tests/samplebinding | |
parent | 5a0eb0f30c6d2db0d3b023cff9e1851781d184d2 (diff) |
Add experimental support for rvalue references
Enable functions taking rvalue references if they are user-defined in
some way. Enabling by default is not done since there are cases in
which several overloads exist (QSqlQueryModel::setQuery(QSqlQuery)).
In these cases, they should not be part of the candidate list.
[ChangeLog][shiboken6] Experimental support for rvalue references
has been added.
Task-number: PYSIDE-2394
Task-number: PYSIDE-1790
Change-Id: Ie2eb60ef19ddac321126b64cd0c35913bd805b48
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/tests/samplebinding')
-rw-r--r-- | sources/shiboken6/tests/samplebinding/sample_test.py | 21 | ||||
-rw-r--r-- | sources/shiboken6/tests/samplebinding/typesystem_sample.xml | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/samplebinding/sample_test.py b/sources/shiboken6/tests/samplebinding/sample_test.py index c58322e20..225eae225 100644 --- a/sources/shiboken6/tests/samplebinding/sample_test.py +++ b/sources/shiboken6/tests/samplebinding/sample_test.py @@ -51,6 +51,27 @@ class ModuleTest(unittest.TestCase): self.assertRaises(TypeError, sample.testNullPtrT, 42) + def testRValueRefsWithValueTypes(self): + """Passing value types by rvalue refs: For value types, nothing should + happen since the argument is copied in the call and the copy is + moved from.""" + polygon = sample.Polygon() + polygon.addPoint(sample.Point(1, 2)) + polygon.addPoint(sample.Point(3, 4)) + point_count = len(polygon.points()) + self.assertEqual(point_count, sample.takePolygon(polygon)) + + def testRValueRefsWithObjectTypes(self): + """Passing object types by rvalue refs: The underlying object should + be moved from.""" + o = sample.ObjectType() + object_name = "Name" + o.setObjectName(object_name) + self.assertEqual(len(object_name), sample.takeObjectType(o)) + # o should be moved from, name is now empty + self.assertEqual(len(o.objectName()), 0) + + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml index 25d303a27..9cbef5f02 100644 --- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml +++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml @@ -422,6 +422,8 @@ <function signature="addStdStrings(const std::string&, const std::string&)"/> <function signature="addStdWStrings(const std::wstring&, const std::wstring&)"/> <function signature="testNullPtrT(std::nullptr_t)"/> + <function signature="takePolygon(Polygon&&)"/> + <function signature="takeObjectType(ObjectType&&)"/> <value-type name="ArrayModifyTest"> <modify-function signature="sumIntArray(int, int*)"> |