aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index a10a15b0..5940aa86 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 <array> function argument modification: change into a type
+// where "int *" becomes "int[]".
+bool AbstractMetaType::applyArrayModification(QString *errorMessage)
+{
+ if (m_pattern == AbstractMetaType::NativePointerAsArrayPattern) {
+ *errorMessage = QLatin1String("<array> 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;