From 5abbce3485e91bdbac532d4c811b9696f8e88cfc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Feb 2019 15:11:19 +0100 Subject: shiboken: Handle modifications in template inheritance Array modifications did not work in template specializations (like typedef QGenericMatrix<2,2,int> QMatrix2x2> causing warnings like: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const float *' of argument 1 in function 'QMatrix2x2::QMatrix2x2(const float * values)'. Rewrite the array modification code to operate on AbstractMetaType only instead of requiring code model data types and add the missing handling to AbstractMetaBuilderPrivate::inheritTemplate(). Add a test. Note that the warning was fixed by another change removing the array modification since it did not take effect due to the presence of a manually added PySequence constructor. Change-Id: Ie4a1092fbef7237f8858790a74e2f75070ef6586 Reviewed-by: Cristian Maureira-Fredes --- .../shiboken2/ApiExtractor/abstractmetalang.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp') diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index a10a15b08..5940aa86a 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -207,6 +207,35 @@ AbstractMetaType *AbstractMetaType::copy() const return cpy; } +// For applying the function argument modification: change into a type +// where "int *" becomes "int[]". +bool AbstractMetaType::applyArrayModification(QString *errorMessage) +{ + if (m_pattern == AbstractMetaType::NativePointerAsArrayPattern) { + *errorMessage = QLatin1String(" modification already applied."); + return false; + } + if (m_arrayElementType != nullptr) { + QTextStream(errorMessage) << "The type \"" << cppSignature() + << "\" is an array of " << m_arrayElementType->name() << '.'; + return false; + } + if (m_indirections.isEmpty()) { + QTextStream(errorMessage) << "The type \"" << cppSignature() + << "\" does not have indirections."; + return false; + } + // Element type to be used for ArrayHandle<>, strip constness. + auto elementType = copy(); + elementType->m_indirections.pop_front(); + elementType->setConstant(false); + elementType->setVolatile(false); + elementType->decideUsagePattern(); + m_arrayElementType = elementType; + setTypeUsagePattern(AbstractMetaType::NativePointerAsArrayPattern); + return true; +} + AbstractMetaTypeCList AbstractMetaType::nestedArrayTypes() const { AbstractMetaTypeCList result; -- cgit v1.2.3