diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-22 15:26:42 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-23 21:03:37 +0100 |
| commit | 4cb23c7edbb66f80e6749efbdec7154bf1637d35 (patch) | |
| tree | d60b5e1920fd914f91a30db8e5e052ff99a0f612 | |
| parent | 2b14cba81265bbeb31b35dc4e04ccd3f6e29c4ee (diff) | |
shiboken6: Parse the notify specification from Q_PROPERTY
To be used for documentation purposes.
Task-number: PYSIDE-1106
Task-number: PYSIDE-1019
Pick-to: 6.4
Change-Id: I833193be0007dbdba2e3fde75c64dfc2a85a4ef7
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
7 files changed, 34 insertions, 3 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index aa57c1b06..4eff0ee62 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -1384,6 +1384,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 78f52a8e0..e1f8e774d 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 2baca18d4..1ae0e1f1a 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -663,6 +663,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 4cbc06c0a..8e18d2338 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 bad7cdf91..bdbd7fa22 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 cdba25148..10f9b7267 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 5e44a918d..1ffbb1cfc 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.h +++ b/sources/shiboken6/ApiExtractor/propertyspec.h @@ -74,6 +74,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); |
