aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-03 08:57:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-11 19:01:30 +0000
commit5b682a6bceec3f43a984a028afe242950a2d82d7 (patch)
tree1809c7b55ef7e3e592d56f714f90520e5ba4ba7f /sources/shiboken2/ApiExtractor/parser/codemodel.cpp
parentd23b43816a7ed6a9513b2213a7e633eed2155769 (diff)
shiboken: Add instantiations to TypeInfo
When streamlining the typeinfo structs in 7f798dfc9fc6e3e9756f06f0fedc821e16f1320a, the parser was wrongly changed to use TypeInfo::m_arguments for template instantiations. This field is intented for function pointer arguments (which the parser does not support). Add a new TypeInfo::m_instantiations (matching AbstractMetaType::m_instantiations) for templates, support it in the type parser and to the toString() method. This allows to remove the mysterious TypeInfo::instantiationName() method. Task-number: PYSIDE-672 Change-Id: I705b26d65988ebfb837e8323941076b4fb37d120 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/parser/codemodel.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
index d862692dd..39f438f4e 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
@@ -142,6 +142,7 @@ TypeInfo TypeInfo::combine(const TypeInfo &__lhs, const TypeInfo &__rhs)
__result.setReferenceType(__rhs.referenceType());
__result.setIndirections(__result.indirections() + __rhs.indirections());
__result.setArrayElements(__result.arrayElements() + __rhs.arrayElements());
+ __result.m_instantiations.append(__rhs.m_instantiations);
return __result;
}
@@ -150,6 +151,7 @@ bool TypeInfo::isVoid() const
{
return m_indirections == 0 && m_referenceType == NoReference
&& m_arguments.isEmpty() && m_arrayElements.isEmpty()
+ && m_instantiations.isEmpty()
&& m_qualifiedName.size() == 1
&& m_qualifiedName.constFirst() == QLatin1String("void");
}
@@ -204,6 +206,18 @@ QString TypeInfo::toString() const
if (isVolatile())
tmp += QLatin1String(" volatile");
+ if (const int instantiationCount = m_instantiations.size()) {
+ tmp += QLatin1Char('<');
+ for (int i = 0; i < instantiationCount; ++i) {
+ if (i)
+ tmp += QLatin1String(", ");
+ tmp += m_instantiations.at(i).toString();
+ }
+ if (tmp.endsWith(QLatin1Char('>')))
+ tmp += QLatin1Char(' ');
+ tmp += QLatin1Char('>');
+ }
+
if (indirections())
tmp += QString(indirections(), QLatin1Char('*'));
@@ -238,20 +252,6 @@ QString TypeInfo::toString() const
return tmp;
}
-QStringList TypeInfo::instantiationName() const
-{
- QStringList result = m_qualifiedName;
- if (const int argumentCount = m_arguments.size()) {
- QString &last = result.last();
- for (int i = 0; i < argumentCount; ++i) {
- last += i ? QLatin1String(", ") : QLatin1String("< ");
- last += m_arguments.at(i).toString();
- }
- last += QLatin1String(" >");
- }
- return result;
-}
-
bool TypeInfo::operator==(const TypeInfo &other) const
{
if (arrayElements().count() != other.arrayElements().count())
@@ -269,7 +269,8 @@ bool TypeInfo::operator==(const TypeInfo &other) const
return flags == other.flags
&& m_qualifiedName == other.m_qualifiedName
- && (!m_functionPointer || m_arguments == other.m_arguments);
+ && (!m_functionPointer || m_arguments == other.m_arguments)
+ && m_instantiations == other.m_instantiations;
}
#ifndef QT_NO_DEBUG_STREAM
@@ -304,6 +305,11 @@ void TypeInfo::formatDebug(QDebug &d) const
d << ", [rvalref]";
break;
}
+ if (!m_instantiations.isEmpty()) {
+ d << ", template<";
+ formatSequence(d, m_instantiations.begin(), m_instantiations.end());
+ d << '>';
+ }
if (m_functionPointer) {
d << ", function ptr(";
formatSequence(d, m_arguments.begin(), m_arguments.end());