diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/propertyspec.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/propertyspec.cpp | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp index 54ac6fdab..32b756fad 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.cpp +++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp @@ -5,9 +5,10 @@ #include "abstractmetalang.h" #include "abstractmetabuilder_p.h" #include "abstractmetatype.h" -#include "codemodel.h" +#include "documentation.h" #include "messages.h" #include "complextypeentry.h" +#include "typeinfo.h" #include "qtcompat.h" @@ -31,6 +32,7 @@ public: m_write(ts.write), m_designable(ts.designable), m_reset(ts.reset), + m_notify(ts.notify), m_type(type), m_generateGetSetDef(ts.generateGetSetDef) { @@ -41,6 +43,8 @@ public: QString m_write; QString m_designable; QString m_reset; + QString m_notify; + Documentation m_documentation; AbstractMetaType m_type; int m_index = -1; // Indicates whether actual code is generated instead of relying on libpyside. @@ -55,8 +59,8 @@ QPropertySpec::QPropertySpec(const TypeSystemProperty &ts, QPropertySpec::QPropertySpec(const QPropertySpec &) = default; QPropertySpec &QPropertySpec::operator=(const QPropertySpec &) = default; -QPropertySpec::QPropertySpec(QPropertySpec &&) = default; -QPropertySpec &QPropertySpec::operator=(QPropertySpec &&) = default; +QPropertySpec::QPropertySpec(QPropertySpec &&) noexcept = default; +QPropertySpec &QPropertySpec::operator=(QPropertySpec &&) noexcept = default; QPropertySpec::~QPropertySpec() = default; const AbstractMetaType &QPropertySpec::type() const @@ -70,7 +74,7 @@ void QPropertySpec::setType(const AbstractMetaType &t) d->m_type = t; } -const TypeEntry *QPropertySpec::typeEntry() const +TypeEntryCPtr QPropertySpec::typeEntry() const { return d->m_type.typeEntry(); } @@ -86,6 +90,17 @@ void QPropertySpec::setName(const QString &name) d->m_name = name; } +Documentation QPropertySpec::documentation() const +{ + return d->m_documentation; +} + +void QPropertySpec::setDocumentation(const Documentation &doc) +{ + if (d->m_documentation != doc) + d->m_documentation = doc; +} + QString QPropertySpec::read() const { return d->m_read; @@ -135,6 +150,17 @@ void QPropertySpec::setReset(const QString &reset) d->m_reset = reset; } +QString QPropertySpec::notify() const +{ + return d->m_notify; +} + +void QPropertySpec::setNotify(const QString ¬ify) +{ + if (d->m_notify != notify) + d->m_notify = notify; +} + int QPropertySpec::index() const { return d->m_index; @@ -163,13 +189,15 @@ void QPropertySpec::setGenerateGetSetDef(bool generateGetSetDef) TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString &declarationIn, QString *errorMessage) { - enum class PropertyToken { None, Read, Write, Designable, Reset }; + enum class PropertyToken { None, Read, Write, Designable, Reset, Notify, Member }; static const QHash<QString, PropertyToken> tokenLookup = { - {QStringLiteral("READ"), PropertyToken::Read}, - {QStringLiteral("WRITE"), PropertyToken::Write}, - {QStringLiteral("DESIGNABLE"), PropertyToken::Designable}, - {QStringLiteral("RESET"), PropertyToken::Reset} + {"READ"_L1, PropertyToken::Read}, + {"WRITE"_L1, PropertyToken::Write}, + {"DESIGNABLE"_L1, PropertyToken::Designable}, + {"RESET"_L1, PropertyToken::Reset}, + {"NOTIFY"_L1, PropertyToken::Notify}, + {"MEMBER"_L1, PropertyToken::Member} }; errorMessage->clear(); @@ -192,13 +220,13 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString return result; } - const int firstToken = int(it - propertyTokens.cbegin()); + const auto firstToken = qsizetype(it - propertyTokens.cbegin()); if (firstToken < 2) { *errorMessage = u"Insufficient number of tokens in property specification"_s; return result; } - for (int pos = firstToken; pos + 1 < propertyTokens.size(); pos += 2) { + for (qsizetype pos = firstToken; pos + 1 < propertyTokens.size(); pos += 2) { switch (tokenLookup.value(propertyTokens.at(pos))) { case PropertyToken::Read: result.read = propertyTokens.at(pos + 1); @@ -212,16 +240,24 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString case PropertyToken::Designable: result.designable = propertyTokens.at(pos + 1); break; + case PropertyToken::Notify: + result.notify = propertyTokens.at(pos + 1); + break; + case PropertyToken::Member: + // Ignore MEMBER tokens introduced by QTBUG-16852 as Python + // properties are anyways generated for fields. + return {}; + case PropertyToken::None: break; } } - const int namePos = firstToken - 1; + const auto namePos = firstToken - 1; result.name = propertyTokens.at(namePos); result.type = propertyTokens.constFirst(); - for (int pos = 1; pos < namePos; ++pos) + for (qsizetype pos = 1; pos < namePos; ++pos) result.type += u' ' + propertyTokens.at(pos); // Fix errors like "Q_PROPERTY(QXYSeries *series .." to be of type "QXYSeries*" @@ -238,7 +274,7 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString // the AbstractMetaType from the type string. std::optional<QPropertySpec> QPropertySpec::fromTypeSystemProperty(AbstractMetaBuilderPrivate *b, - AbstractMetaClass *metaClass, + const AbstractMetaClassPtr &metaClass, const TypeSystemProperty &ts, const QStringList &scopes, QString *errorMessage) @@ -254,7 +290,7 @@ std::optional<QPropertySpec> auto type = b->translateType(info, metaClass, {}, &typeError); if (!type.has_value()) { const QStringList qualifiedName = info.qualifiedName(); - for (int j = scopes.size(); j >= 0 && !type; --j) { + for (auto j = scopes.size(); j >= 0 && !type; --j) { info.setQualifiedName(scopes.mid(0, j) + qualifiedName); type = b->translateType(info, metaClass, {}, &typeError); } @@ -271,7 +307,7 @@ std::optional<QPropertySpec> // via TypeSystemProperty. std::optional<QPropertySpec> QPropertySpec::parseQ_Property(AbstractMetaBuilderPrivate *b, - AbstractMetaClass *metaClass, + const AbstractMetaClassPtr &metaClass, const QString &declarationIn, const QStringList &scopes, QString *errorMessage) @@ -294,6 +330,8 @@ void QPropertySpec::formatDebug(QDebug &debug) const debug << ", reset=" << d->m_reset; if (!d->m_designable.isEmpty()) debug << ", designable=" << d->m_designable; + if (!d->m_documentation.isEmpty()) + debug << ", doc=\"" << d->m_documentation << '"'; } QDebug operator<<(QDebug d, const QPropertySpec &p) |