diff options
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp | 14 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/parser/codemodel.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/parser/codemodel.h | 3 |
3 files changed, 9 insertions, 16 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index 31adbb898..5ce33f433 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -200,7 +200,7 @@ public: void addField(const CXCursor &cursor); static QString cursorValueExpression(BaseVisitor *bv, const CXCursor &cursor); - QString getBaseClassName(CXType type) const; + std::pair<QString, ClassModelItem> getBaseClass(CXType type) const; void addBaseClass(const CXCursor &cursor); template <class Item> @@ -702,7 +702,7 @@ static TypeDeclaration resolveType(CXType type) // Note: Return the baseclass for cursors like CXCursor_CXXBaseSpecifier, // where the cursor spelling has "struct baseClass". -QString BuilderPrivate::getBaseClassName(CXType type) const +std::pair<QString, ClassModelItem> BuilderPrivate::getBaseClass(CXType type) const { const auto decl = resolveType(type); // Note: spelling has "struct baseClass", use type @@ -725,7 +725,7 @@ QString BuilderPrivate::getBaseClassName(CXType type) const // "class X : public std::list<...>", "template<class T> class Foo : public T" // and standard types like true_type, false_type. if (it == m_cursorClassHash.constEnd()) - return baseClassName; + return {baseClassName, {}}; // Completely qualify the class name by looking it up and taking its scope // plus the actual baseClass stripped off any scopes. Consider: @@ -745,7 +745,7 @@ QString BuilderPrivate::getBaseClassName(CXType type) const baseClassName.prepend(colonColon()); baseClassName.prepend(baseScope.join(colonColon())); } - return baseClassName; + return {baseClassName, it.value()}; } // Add a base class to the current class from CXCursor_CXXBaseSpecifier @@ -753,8 +753,8 @@ void BuilderPrivate::addBaseClass(const CXCursor &cursor) { Q_ASSERT(clang_getCursorKind(cursor) == CXCursor_CXXBaseSpecifier); const auto access = accessPolicy(clang_getCXXAccessSpecifier(cursor)); - QString baseClassName = getBaseClassName(clang_getCursorType(cursor)); - m_currentClass->addBaseClass(baseClassName, access); + const auto baseClass = getBaseClass(clang_getCursorType(cursor)); + m_currentClass->addBaseClass({baseClass.first, baseClass.second, access}); } static inline CXCursor definitionFromTypeRef(const CXCursor &typeRefCursor) @@ -1173,7 +1173,7 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) } else if (!d->m_currentField.isNull()) { d->qualifyTypeDef(cursor, d->m_currentField); } else if (d->m_withinUsingDeclaration && d->m_usingTypeRef.isEmpty()) { - d->m_usingTypeRef = d->getBaseClassName(clang_getCursorType(cursor)); + d->m_usingTypeRef = d->getBaseClass(clang_getCursorType(cursor)).first; } break; case CXCursor_CXXFinalAttr: diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp index 1ea9f45f6..7d3b9aa83 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp @@ -377,14 +377,6 @@ void _ClassModelItem::setTemplateParameters(const TemplateParameterList &templat m_templateParameters = templateParameters; } -void _ClassModelItem::addBaseClass(const QString &name, Access accessPolicy) -{ - _ClassModelItem::BaseClass baseClass; - baseClass.name = name; - baseClass.accessPolicy = accessPolicy; - m_baseClasses.append(baseClass); -} - bool _ClassModelItem::extendsClass(const QString &name) const { for (const BaseClass &bc : m_baseClasses) { diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.h b/sources/shiboken6/ApiExtractor/parser/codemodel.h index 76abd47cf..6527ab7bb 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.h @@ -266,6 +266,7 @@ public: struct BaseClass { QString name; + ClassModelItem klass; // Might be null in case of templates Access accessPolicy = Access::Public; }; @@ -288,7 +289,7 @@ public: void addUsingMember(const QString &className, const QString &memberName, Access accessPolicy); - void addBaseClass(const QString &name, Access accessPolicy); + void addBaseClass(const BaseClass &b) { m_baseClasses.append(b); } TemplateParameterList templateParameters() const; void setTemplateParameters(const TemplateParameterList &templateParameters); |