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/clangparser/clangbuilder.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/clangparser/clangbuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index e3d7d0273..e3e52cdd3 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -190,6 +190,8 @@ public: TypeInfo *t) const; bool addTemplateInstantiationsRecursion(const CXType &type, TypeInfo *t) const; + void addTypeDef(const CXCursor &cursor, const TypeInfo &ti); + TemplateParameterModelItem createTemplateParameter(const CXCursor &cursor) const; TemplateParameterModelItem createNonTypeTemplateParameter(const CXCursor &cursor) const; void addField(const CXCursor &cursor); @@ -511,6 +513,7 @@ TypeInfo BuilderPrivate::createTypeInfoHelper(const CXType &type) const typeInfo.setQualifiedName(qualifiedName(typeName)); // 3320:CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); function ptr types? + typeInfo.simplifyStdType(); return typeInfo; } @@ -522,6 +525,16 @@ TypeInfo BuilderPrivate::createTypeInfo(const CXType &type) const return it.value(); } +void BuilderPrivate::addTypeDef(const CXCursor &cursor, const TypeInfo &ti) +{ + TypeDefModelItem item(new _TypeDefModelItem(m_model, getCursorSpelling(cursor))); + setFileName(cursor, item.data()); + item->setType(ti); + item->setScope(m_scope); + m_scopeStack.back()->addTypeDef(item); + m_cursorTypedefHash.insert(cursor, item); +} + // extract an expression from the cursor via source // CXCursor_EnumConstantDecl, ParmDecl (a = Flag1 | Flag2) QString BuilderPrivate::cursorValueExpression(BaseVisitor *bv, const CXCursor &cursor) const @@ -912,17 +925,14 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) } break; case CXCursor_TypeAliasDecl: - case CXCursor_TypeAliasTemplateDecl: // May contain nested CXCursor_TemplateTypeParameter - return Skip; - case CXCursor_TypedefDecl: { - const QString name = getCursorSpelling(cursor); - TypeDefModelItem item(new _TypeDefModelItem(d->m_model, name)); - setFileName(cursor, item.data()); - item->setType(d->createTypeInfo(clang_getTypedefDeclUnderlyingType(cursor))); - item->setScope(d->m_scope); - d->m_scopeStack.back()->addTypeDef(item); - d->m_cursorTypedefHash.insert(cursor, item); + case CXCursor_TypeAliasTemplateDecl: { // May contain nested CXCursor_TemplateTypeParameter + const CXType type = clang_getCanonicalType(clang_getCursorType(cursor)); + if (type.kind > CXType_Unexposed) + d->addTypeDef(cursor, d->createTypeInfo(type)); } + return Skip; + case CXCursor_TypedefDecl: + d->addTypeDef(cursor, d->createTypeInfo(clang_getTypedefDeclUnderlyingType(cursor))); break; case CXCursor_TypeRef: if (!d->m_currentFunction.isNull()) { |