From 6f5f279b49756b1f848a6d85fde6bcae5eef4937 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Jul 2018 12:22:54 +0200 Subject: shiboken: Introduce enumeration for C++ indirections Replace the int "indirections" field of TypeInfo and AbstractMetaType by a Vector of an enumeration representing '*' and "* const". It is then possible distinguish between "int *" and "int *const". Task-number: PYSIDE-672 Change-Id: I68677fa515abb7e94217fc1c2b6ac28b42678284 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Alexandru Croitor --- sources/shiboken2/ApiExtractor/parser/codemodel.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/parser/codemodel.cpp') diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index 39f438f4e..4ad86bd15 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -140,7 +140,7 @@ TypeInfo TypeInfo::combine(const TypeInfo &__lhs, const TypeInfo &__rhs) __result.setVolatile(__result.isVolatile() || __rhs.isVolatile()); if (__rhs.referenceType() > __result.referenceType()) __result.setReferenceType(__rhs.referenceType()); - __result.setIndirections(__result.indirections() + __rhs.indirections()); + __result.m_indirections.append(__rhs.m_indirections); __result.setArrayElements(__result.arrayElements() + __rhs.arrayElements()); __result.m_instantiations.append(__rhs.m_instantiations); @@ -149,7 +149,7 @@ TypeInfo TypeInfo::combine(const TypeInfo &__lhs, const TypeInfo &__rhs) bool TypeInfo::isVoid() const { - return m_indirections == 0 && m_referenceType == NoReference + return m_indirections.isEmpty() && m_referenceType == NoReference && m_arguments.isEmpty() && m_arrayElements.isEmpty() && m_instantiations.isEmpty() && m_qualifiedName.size() == 1 @@ -218,8 +218,8 @@ QString TypeInfo::toString() const tmp += QLatin1Char('>'); } - if (indirections()) - tmp += QString(indirections(), QLatin1Char('*')); + for (Indirection i : m_indirections) + tmp.append(indirectionKeyword(i)); switch (referenceType()) { case NoReference: @@ -273,6 +273,12 @@ bool TypeInfo::operator==(const TypeInfo &other) const && m_instantiations == other.m_instantiations; } +QString TypeInfo::indirectionKeyword(Indirection i) +{ + return i == Indirection::Pointer + ? QStringLiteral("*") : QStringLiteral("* const"); +} + #ifndef QT_NO_DEBUG_STREAM template void formatSequence(QDebug &d, It i1, It i2, const char *separator=", ") @@ -293,8 +299,11 @@ void TypeInfo::formatDebug(QDebug &d) const d << ", [const]"; if (m_volatile) d << ", [volatile]"; - if (m_indirections) - d << ", indirections=" << m_indirections; + if (!m_indirections.isEmpty()) { + d << ", indirections="; + for (auto i : m_indirections) + d << ' ' << TypeInfo::indirectionKeyword(i); + } switch (m_referenceType) { case NoReference: break; -- cgit v1.2.3