diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-22 15:26:42 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-23 21:43:30 +0000 |
commit | 22bba4418b8922ef2747608455a1326e15b51639 (patch) | |
tree | 867aa5006bba9585249035efe3f82070966b5f3a | |
parent | c9538c7cccf88e478e65af20610968df8de7d582 (diff) |
shiboken6: Parse the notify specification from Q_PROPERTY
To be used for documentation purposes.
Task-number: PYSIDE-1106
Task-number: PYSIDE-1019
Change-Id: I833193be0007dbdba2e3fde75c64dfc2a85a4ef7
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 4cb23c7edbb66f80e6749efbdec7154bf1637d35)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
7 files changed, 34 insertions, 3 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index 6ceb9ad3a..86ef34552 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -1385,6 +1385,11 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, metaFunction->setPropertySpecIndex(propertyFunction.index); } break; + case AbstractMetaClass::PropertyFunction::Notify: + if (metaFunction->isSignal()) { + *metaFunction += AbstractMetaFunction::PropertyNotify; + metaFunction->setPropertySpecIndex(propertyFunction.index); + } } } diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.h b/sources/shiboken6/ApiExtractor/abstractmetafunction.h index 888d52b66..bcd13e066 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetafunction.h +++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.h @@ -103,6 +103,7 @@ public: PropertyReader = 0x00000100, PropertyWriter = 0x00000200, PropertyResetter = 0x00000400, + PropertyNotify = 0x00000800, Invokable = 0x00001000, diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index 36aa0c02b..cf93e5b03 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -668,6 +668,8 @@ AbstractMetaClass::PropertyFunctionSearchResult return PropertyFunctionSearchResult{i, PropertyFunction::Write}; if (name == propertySpec.reset()) return PropertyFunctionSearchResult{i, PropertyFunction::Reset}; + if (name == propertySpec.notify()) + return PropertyFunctionSearchResult{i, PropertyFunction::Notify}; } return PropertyFunctionSearchResult{-1, PropertyFunction::Read}; } diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.h b/sources/shiboken6/ApiExtractor/abstractmetalang.h index ca1b272e5..025ce6a8b 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.h @@ -268,7 +268,8 @@ public: { Read, Write, - Reset + Reset, + Notify }; struct PropertyFunctionSearchResult { diff --git a/sources/shiboken6/ApiExtractor/complextypeentry.h b/sources/shiboken6/ApiExtractor/complextypeentry.h index 9e46634bc..4a112d48d 100644 --- a/sources/shiboken6/ApiExtractor/complextypeentry.h +++ b/sources/shiboken6/ApiExtractor/complextypeentry.h @@ -28,6 +28,7 @@ struct TypeSystemProperty QString write; QString reset; QString designable; + QString notify; // Q_PROPERTY/C++ only // Indicates whether actual code is generated instead of relying on libpyside. bool generateGetSetDef = false; }; diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp index c9eca3fad..8860269a4 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.cpp +++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp @@ -31,6 +31,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 +42,7 @@ public: QString m_write; QString m_designable; QString m_reset; + QString m_notify; AbstractMetaType m_type; int m_index = -1; // Indicates whether actual code is generated instead of relying on libpyside. @@ -135,6 +137,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 +176,14 @@ 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 }; static const QHash<QString, PropertyToken> tokenLookup = { {QStringLiteral("READ"), PropertyToken::Read}, {QStringLiteral("WRITE"), PropertyToken::Write}, {QStringLiteral("DESIGNABLE"), PropertyToken::Designable}, - {QStringLiteral("RESET"), PropertyToken::Reset} + {QStringLiteral("RESET"), PropertyToken::Reset}, + {QStringLiteral("NOTIFY"), PropertyToken::Notify} }; errorMessage->clear(); @@ -212,6 +226,10 @@ 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::None: break; } diff --git a/sources/shiboken6/ApiExtractor/propertyspec.h b/sources/shiboken6/ApiExtractor/propertyspec.h index b32d6c08a..d1de93afd 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.h +++ b/sources/shiboken6/ApiExtractor/propertyspec.h @@ -72,6 +72,9 @@ public: QString reset() const; void setReset(const QString &reset); + QString notify() const; // Q_PROPERTY/C++ only + void setNotify(const QString ¬ify); + int index() const; void setIndex(int index); |