diff options
5 files changed, 64 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/global.h.in b/sources/pyside2/PySide2/global.h.in index ae1b103f5..a23b0f332 100644 --- a/sources/pyside2/PySide2/global.h.in +++ b/sources/pyside2/PySide2/global.h.in @@ -40,6 +40,13 @@ // Make "signals:", "slots:" visible as access specifiers #define QT_ANNOTATE_ACCESS_SPECIFIER(a) __attribute__((annotate(#a))) +// Q_PROPERTY is defined as class annotation which does not work since a +// sequence of properties will to expand to a sequence of annotations +// annotating nothing, causing clang to complain. Instead, define it away in a +// static assert with the stringified argument in a ','-operator (cf qdoc). + +#define QT_ANNOTATE_CLASS(type,...) static_assert(sizeof(#__VA_ARGS__),#type); + #include <QtCore/qnamespace.h> #if @ENABLE_X11@ diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index e9a2c2b57..a202c42d5 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -2619,6 +2619,15 @@ void AbstractMetaClass::format(QDebug &d) const d << (i ? ',' : '<') << instantiatedTypes.at(i)->name(); d << ">\""; } + if (const int count = m_propertySpecs.size()) { + d << ", properties (" << count << "): ["; + for (int i = 0; i < count; ++i) { + if (i) + d << ", "; + m_propertySpecs.at(i)->formatDebug(d); + } + d << ']'; + } } void AbstractMetaClass::formatMembers(QDebug &d) const @@ -2725,3 +2734,28 @@ QString AbstractMetaEnum::package() const { return m_typeEntry->targetLangPackage(); } + +#ifndef QT_NO_DEBUG_STREAM +void QPropertySpec::formatDebug(QDebug &d) const +{ + d << '#' << m_index << " \"" << m_name << "\" (" << m_type->qualifiedCppName() + << "), read=" << m_read; + if (!m_write.isEmpty()) + d << ", write=" << m_write; + if (!m_reset.isEmpty()) + d << ", reset=" << m_reset; + if (!m_designable.isEmpty()) + d << ", esignable=" << m_designable; +} + +QDebug operator<<(QDebug d, const QPropertySpec &p) +{ + QDebugStateSaver s(d); + d.noquote(); + d.nospace(); + d << "QPropertySpec("; + p.formatDebug(d); + d << ')'; + return d; +} +#endif // QT_NO_DEBUG_STREAM diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index 830631e68..8169c4a30 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -1807,6 +1807,10 @@ public: m_index = index; } +#ifndef QT_NO_DEBUG_STREAM + void formatDebug(QDebug &d) const; +#endif + private: QString m_name; QString m_read; @@ -1817,4 +1821,8 @@ private: int m_index = -1; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const QPropertySpec &p); +#endif + #endif // ABSTRACTMETALANG_H 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; } diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index e5a6e074c..3b9521e82 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -789,6 +789,8 @@ void _ClassModelItem::formatDebug(QDebug &d) const } formatModelItemList(d, ", templateParameters=", m_templateParameters); formatScopeItemsDebug(d); + if (!m_propertyDeclarations.isEmpty()) + d << ", Properties=" << m_propertyDeclarations; } #endif // !QT_NO_DEBUG_STREAM |