aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/samplebinding
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-09 08:26:08 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-21 14:15:37 +0200
commitb016f35f94e061ee296d65dbbcb2c7c9e4a988d0 (patch)
treeca13fb7067268070cc0c723d067d02b7ad351554 /sources/shiboken2/tests/samplebinding
parent58d3ac8842d36a6ce615188079e82598efa85b7e (diff)
shiboken2: Allow specifying the sequence of overloads
Add an attribute to specify a number by which the functions will be sorted. This deactivates the default sorting which tries to avoid implicit conversions. Fixes: PYSIDE-1366 Change-Id: I9a891e21f86152b2fdfda9a48d685f19aa936508 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/tests/samplebinding')
-rw-r--r--sources/shiboken2/tests/samplebinding/CMakeLists.txt1
-rw-r--r--sources/shiboken2/tests/samplebinding/overload_sorting_test.py9
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml5
3 files changed, 15 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index 5cc7092b2..ad52565ad 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -22,6 +22,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/collector_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/comparisontester_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/color_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/ctorconvrule_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/customoverloadsequence_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/cvlistuser_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/cvvaluetype_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/sbkdate_wrapper.cpp
diff --git a/sources/shiboken2/tests/samplebinding/overload_sorting_test.py b/sources/shiboken2/tests/samplebinding/overload_sorting_test.py
index 8132e4e3d..958aa0a6d 100644
--- a/sources/shiboken2/tests/samplebinding/overload_sorting_test.py
+++ b/sources/shiboken2/tests/samplebinding/overload_sorting_test.py
@@ -94,5 +94,14 @@ class EnumOverIntSorting(unittest.TestCase):
ic = ImplicitConv(ImplicitConv.CtorTwo)
self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorTwo)
+
+class TestCustomOverloadSequence(unittest.TestCase):
+ '''Ensure the int-overload (returning v + sizeof(v)) is first as specified via
+ overload-number in XML.'''
+ def testCustomOverloadSequence(self):
+ s = CustomOverloadSequence()
+ self.assertEqual(s.overload(42), 46)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index a1f8cd6d1..132bff4ed 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -1806,6 +1806,11 @@
</value-type>
<value-type name="ImplicitTarget"/>
+ <object-type name="CustomOverloadSequence">
+ <modify-function signature="overload(int) const" overload-number="0"/>
+ <modify-function signature="overload(short) const" overload-number="1"/>
+ </object-type>
+
<value-type name="Point">
<add-function signature="__str__" return-type="PyObject*">
<inject-code class="target" position="beginning">