diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-23 15:53:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-26 08:24:29 +0000 |
commit | 831b22fcd6eb9b45c9e7834799a91698ec00a6a4 (patch) | |
tree | 536212de56d2aec949f504b275dcb77ff2d76540 /sources/shiboken2/ApiExtractor/parser/codemodel.cpp | |
parent | f645e5c8fe02bc6eb177061cfec4fa5bddab05d3 (diff) |
shiboken: Add support for type aliases (using)
QAbstractRayCaster is the first class in Qt to use type aliases:
using Hits = QVector<QRayCasterHit>;
Treat them as typedefs if a canonical type can be obtained for
them. This requires adding some simplification of the canonical types
obtained for standard containers.
Task-number: PYSIDE-751
Change-Id: I521a8b02d3c8cb89e4f72a817fbacc5955041570
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/parser/codemodel.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/parser/codemodel.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index 485222bb0..c9861b510 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -355,6 +355,38 @@ bool TypeInfo::stripLeadingQualifier(const QString &qualifier, QString *s) return true; } +// Helper functionality to simplify a raw standard type as returned by +// clang_getCanonicalType() for g++ standard containers from +// "std::__cxx11::list<int, std::allocator<int> >" or +// "std::__1::list<int, std::allocator<int> >" -> "std::list<int>". + +bool TypeInfo::isStdType() const +{ + return m_qualifiedName.size() > 1 + && m_qualifiedName.constFirst() == QLatin1String("std"); +} + +static inline bool discardStdType(const QString &name) +{ + return name == QLatin1String("allocator") || name == QLatin1String("less"); +} + +void TypeInfo::simplifyStdType() +{ + if (isStdType()) { + if (m_qualifiedName.at(1).startsWith(QLatin1String("__"))) + m_qualifiedName.removeAt(1); + for (int t = m_instantiations.size() - 1; t >= 0; --t) { + if (m_instantiations.at(t).isStdType()) { + if (discardStdType(m_instantiations.at(t).m_qualifiedName.constLast())) + m_instantiations.removeAt(t); + else + m_instantiations[t].simplifyStdType(); + } + } + } +} + #ifndef QT_NO_DEBUG_STREAM template <class It> void formatSequence(QDebug &d, It i1, It i2, const char *separator=", ") |