diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-06 09:41:41 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-06 11:17:26 +0000 |
commit | 5dec41a724e9967c27eec0a7a0bc36a0b718d310 (patch) | |
tree | b2a32a96d3b69370ec25447f733d55b48650b21b /sources/shiboken2/ApiExtractor | |
parent | f16328b8705f39a10216356d3c14f28607f62a72 (diff) |
shiboken: Handle enum class forward declarations
Add the enumeration to the scope stack only if it actually has values.
This occurs for the first time in Qt 5.12, which introduces a forward
declaration of enum class QCborSimpleType at
src/corelib/kernel/qmetatype.h:65.
Task-number: PYSIDE-487
Change-Id: I5798eb8e47bcd4d21dc554dc5cdd257c7163ca90
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | 5 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/parser/codemodel.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 5192e9e76..b2dd7c844 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -729,7 +729,6 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) d->m_currentEnum->setSigned(isSigned(clang_getEnumDeclIntegerType(cursor).kind)); if (!qSharedPointerDynamicCast<_ClassModelItem>(d->m_scopeStack.back()).isNull()) d->m_currentEnum->setAccessPolicy(accessPolicy(clang_getCXXAccessSpecifier(cursor))); - d->m_scopeStack.back()->addEnum(d->m_currentEnum); } break; case CXCursor_EnumConstantDecl: { @@ -912,6 +911,10 @@ bool Builder::endToken(const CXCursor &cursor) d->m_currentFunctionType = CodeModel::Normal; break; case CXCursor_EnumDecl: + // Add enum only if values were encountered, otherwise assume it + // is a forward declaration of an enum class. + if (!d->m_currentEnum.isNull() && d->m_currentEnum->hasValues()) + d->m_scopeStack.back()->addEnum(d->m_currentEnum); d->m_currentEnum.clear(); break; case CXCursor_VarDecl: diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h index d93aa10d9..20f513e1e 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h @@ -646,6 +646,7 @@ public: CodeModel::AccessPolicy accessPolicy() const; void setAccessPolicy(CodeModel::AccessPolicy accessPolicy); + bool hasValues() const { return !m_enumerators.isEmpty(); } EnumeratorList enumerators() const; void addEnumerator(EnumeratorModelItem item); |