aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-09 14:04:54 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-13 10:38:16 +0200
commit7211180820d76814c7060d39d7ce0e9902865e14 (patch)
tree2b526a10c80a8d018d040e2c6e7465b6abf46754 /sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
parent3d98daaa90e9c7f7784d1a388d97039fcdeffdf1 (diff)
shiboken2: Re-add support for parsing Q_PROPERTY
Following how qdoc does it, define Q_PROPERTY as a static assert with the stringified macro content in a ','-operator and parse it with clang. Task-number: PYSIDE-1019 Change-Id: Idcf53f1cd1c1cb29f4320444f446e9abad33d251 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.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
index 263c0a0bb..d08720934 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
@@ -1117,6 +1117,19 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor)
if (!d->m_currentFunction.isNull())
d->m_currentFunction->setOverride(true);
break;
+ case CXCursor_StaticAssert:
+ // Check for Q_PROPERTY() (see PySide2/global.h.in for an explanation
+ // how it is defined, and qdoc).
+ if (clang_isDeclaration(cursor.kind) && !d->m_currentClass.isNull()) {
+ auto snippet = getCodeSnippet(cursor);
+ const auto length = snippet.second - snippet.first;
+ if (length > 12 && *(snippet.second - 1) == ')'
+ && std::strncmp(snippet.first, "Q_PROPERTY(", 11) == 0) {
+ const QString qProperty = QString::fromUtf8(snippet.first + 11, length - 12);
+ d->m_currentClass->addPropertyDeclaration(qProperty);
+ }
+ }
+ break;
default:
break;
}