diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-04 12:22:54 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-11 19:01:47 +0000 |
commit | 6f5f279b49756b1f848a6d85fde6bcae5eef4937 (patch) | |
tree | 825fe846b1ce66c01338a97aebb9126749ccaf3a /sources/shiboken2/ApiExtractor/parser/codemodel.cpp | |
parent | ae7cb8f5c903b0176dbb98617d6c604874ca4219 (diff) |
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 <cristian.maureira-fredes@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/parser/codemodel.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/parser/codemodel.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
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 <class It> 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; |