aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 91ed7eec5..1f576cfe4 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -2206,6 +2206,23 @@ const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction
return argType;
}
+static inline QString arrayHandleType(const AbstractMetaTypeCList &nestedArrayTypes)
+{
+ switch (nestedArrayTypes.size()) {
+ case 1:
+ return QStringLiteral("Shiboken::Conversions::ArrayHandle<")
+ + nestedArrayTypes.constLast()->minimalSignature()
+ + QLatin1Char('>');
+ case 2:
+ return QStringLiteral("Shiboken::Conversions::Array2Handle<")
+ + nestedArrayTypes.constLast()->minimalSignature()
+ + QStringLiteral(", ")
+ + QString::number(nestedArrayTypes.constFirst()->arrayElementCount())
+ + QLatin1Char('>');
+ }
+ return QString();
+}
+
void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
const AbstractMetaType* type,
const QString& pyIn,
@@ -2227,7 +2244,13 @@ void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
&& !isCppPrimitive(type)
&& isNotContainerEnumOrFlags
&& !(treatAsPointer || isPointerOrObjectType);
- QString typeName = getFullTypeNameWithoutModifiers(type);
+
+ const AbstractMetaTypeCList nestedArrayTypes = type->nestedArrayTypes();
+ const bool isCppPrimitiveArray = !nestedArrayTypes.isEmpty()
+ && nestedArrayTypes.constLast()->isCppPrimitive();
+ QString typeName = isCppPrimitiveArray
+ ? arrayHandleType(nestedArrayTypes)
+ : getFullTypeNameWithoutModifiers(type);
bool isProtectedEnum = false;
@@ -2244,7 +2267,9 @@ void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
}
s << INDENT << typeName;
- if (treatAsPointer || isPointerOrObjectType) {
+ if (isCppPrimitiveArray) {
+ s << ' ' << cppOut;
+ } else if (treatAsPointer || isPointerOrObjectType) {
s << "* " << cppOut;
if (!defaultValue.isEmpty())
s << " = " << defaultValue;