aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp4
-rw-r--r--sources/shiboken6/tests/libminimal/listuser.cpp10
-rw-r--r--sources/shiboken6/tests/libminimal/listuser.h3
-rw-r--r--sources/shiboken6/tests/minimalbinding/listuser_test.py10
4 files changed, 23 insertions, 4 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 5155d121e..7866a702a 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -2891,7 +2891,7 @@ qsizetype CppGenerator::writePythonToCppTypeConversion(TextStream &s,
// conversion for &cppOut
s << ' ' << cppOutAux;
// No default value for containers which can also be passed by pointer.
- if (arg.type != GeneratorArgument::Type::Container)
+ if (arg.type != GeneratorArgument::Type::Container || type.indirections() == 0)
writeMinimalConstructorExpression(s, api(), type, isPrimitive, defaultValue);
s << ";\n" << typeName << " *" << cppOut << " = &" << cppOutAux;
}
@@ -2923,7 +2923,7 @@ qsizetype CppGenerator::writePythonToCppTypeConversion(TextStream &s,
|| arg.type == GeneratorArgument::Type::Enum
|| arg.type == GeneratorArgument::Type::Flags) {
writeMinimalConstructorExpression(s, api(), typeEntry, isPrimitive, defaultValue);
- } else if (!type.isContainer() && !type.isSmartPointer()) {
+ } else if ((!type.isContainer() || type.indirections() == 0) && !type.isSmartPointer()) {
writeMinimalConstructorExpression(s, api(), type, isPrimitive, defaultValue);
}
break;
diff --git a/sources/shiboken6/tests/libminimal/listuser.cpp b/sources/shiboken6/tests/libminimal/listuser.cpp
index 54acc6e05..ba8f43902 100644
--- a/sources/shiboken6/tests/libminimal/listuser.cpp
+++ b/sources/shiboken6/tests/libminimal/listuser.cpp
@@ -20,6 +20,16 @@ int ListUser::sumIntList(std::list<int> intList)
return std::accumulate(intList.begin(), intList.end(), 0);
}
+int ListUser::sumIntListDefaultParamConstRef(const std::list<int> &intList)
+{
+ return sumIntList(intList);
+}
+
+int ListUser::sumIntListDefaultParam(std::list<int> intList)
+{
+ return sumIntList(intList);
+}
+
std::list<MinBool> ListUser::createMinBoolList(MinBool mb1, MinBool mb2)
{
std::list<MinBool> retval;
diff --git a/sources/shiboken6/tests/libminimal/listuser.h b/sources/shiboken6/tests/libminimal/listuser.h
index 8d16927ea..e77e156f5 100644
--- a/sources/shiboken6/tests/libminimal/listuser.h
+++ b/sources/shiboken6/tests/libminimal/listuser.h
@@ -22,6 +22,9 @@ struct LIBMINIMAL_API ListUser
virtual int sumIntList(std::list<int> intList);
int callSumIntList(std::list<int> intList) { return sumIntList(intList); }
+ int sumIntListDefaultParamConstRef(const std::list<int> &intList = {1, 2, 3});
+ int sumIntListDefaultParam(std::list<int> intList = {1, 2, 3});
+
// List of C++ MinBool objects used as primitives in Python
virtual std::list<MinBool> createMinBoolList(MinBool mb1, MinBool mb2);
std::list<MinBool> callCreateMinBoolList(MinBool mb1, MinBool mb2) { return createMinBoolList(mb1, mb2); }
diff --git a/sources/shiboken6/tests/minimalbinding/listuser_test.py b/sources/shiboken6/tests/minimalbinding/listuser_test.py
index fc108950f..4d092b33c 100644
--- a/sources/shiboken6/tests/minimalbinding/listuser_test.py
+++ b/sources/shiboken6/tests/minimalbinding/listuser_test.py
@@ -95,8 +95,14 @@ class IntListConversionTest(unittest.TestCase):
def testSumIntList(self):
lu = ListUser()
lst = range(4)
- self.assertEqual(lu.sumIntList(lst), sum(lst))
- self.assertEqual(lu.callSumIntList(lst), sum(lst))
+ expected = sum(lst)
+ self.assertEqual(lu.sumIntList(lst), expected)
+ self.assertEqual(lu.callSumIntList(lst), expected)
+ self.assertEqual(lu.sumIntListDefaultParam(lst), expected)
+ self.assertEqual(lu.sumIntListDefaultParamConstRef(lst), expected)
+ # PYSIDE-2454: Check container default parameters (1,2,3)
+ self.assertEqual(lu.sumIntListDefaultParam(), 6)
+ self.assertEqual(lu.sumIntListDefaultParamConstRef(), 6)
def testSumIntListFromExtendedClass(self):
lu = ExtListUser()