aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-24 11:10:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-28 11:19:29 +0200
commitcb073f6eee9e21b62d7c14e0357beb6cecf33e31 (patch)
tree36a32fae9cf3f9c8d505a8dbaf31b228b08844f9 /sources/shiboken2/ApiExtractor
parent5a7429cc895824a4eafd27e1a5c95b40bba86bdf (diff)
shiboken2: Generate properties as fields
- Add an XML attribute specifying whether code is to be generated to the XML properties. - Split the generator functions for field setters and getters apart so that they can be used for generating property setters and getters. - Generate code for all properties from XML when the PySide extension is not used, otherwise only for those with the attribute set. Task-number: PYSIDE-1019 Change-Id: Iab2ba38b90038edc667a233c23c7113fdc6fb438 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h5
-rw-r--r--sources/shiboken2/ApiExtractor/propertyspec.cpp3
-rw-r--r--sources/shiboken2/ApiExtractor/propertyspec.h6
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h2
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.cpp5
5 files changed, 16 insertions, 5 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 268546d6c..466464807 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -1592,10 +1592,7 @@ public:
m_propertySpecs << spec;
}
- QVector<QPropertySpec *> propertySpecs() const
- {
- return m_propertySpecs;
- }
+ const QVector<QPropertySpec *> &propertySpecs() const { return m_propertySpecs; }
QPropertySpec *propertySpecByName(const QString &name) const;
QPropertySpec *propertySpecForRead(const QString &name) const;
diff --git a/sources/shiboken2/ApiExtractor/propertyspec.cpp b/sources/shiboken2/ApiExtractor/propertyspec.cpp
index fcb8286bf..f86a31d5b 100644
--- a/sources/shiboken2/ApiExtractor/propertyspec.cpp
+++ b/sources/shiboken2/ApiExtractor/propertyspec.cpp
@@ -48,7 +48,8 @@ QPropertySpec::QPropertySpec(const TypeSystemProperty &ts,
m_write(ts.write),
m_designable(ts.designable),
m_reset(ts.reset),
- m_type(type)
+ m_type(type),
+ m_generateGetSetDef(ts.generateGetSetDef)
{
}
diff --git a/sources/shiboken2/ApiExtractor/propertyspec.h b/sources/shiboken2/ApiExtractor/propertyspec.h
index 4abe75c84..611d4726e 100644
--- a/sources/shiboken2/ApiExtractor/propertyspec.h
+++ b/sources/shiboken2/ApiExtractor/propertyspec.h
@@ -79,6 +79,7 @@ public:
QString write() const { return m_write; }
void setWrite(const QString &write) { m_write = write; }
+ bool hasWrite() const { return !m_write.isEmpty(); }
QString designable() const { return m_designable; }
void setDesignable(const QString &designable) { m_designable = designable; }
@@ -89,6 +90,9 @@ public:
int index() const { return m_index; }
void setIndex(int index) {m_index = index; }
+ bool generateGetSetDef() const { return m_generateGetSetDef; }
+ void setGenerateGetSetDef(bool generateGetSetDef) { m_generateGetSetDef = generateGetSetDef; }
+
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const;
#endif
@@ -101,6 +105,8 @@ private:
QString m_reset;
const AbstractMetaType *m_type = nullptr;
int m_index = -1;
+ // Indicates whether actual code is generated instead of relying on libpyside.
+ bool m_generateGetSetDef = false;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 0c8f85738..8c4f1dc0e 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -563,6 +563,8 @@ struct TypeSystemProperty
QString write;
QString reset;
QString designable;
+ // Indicates whether actual code is generated instead of relying on libpyside.
+ bool generateGetSetDef = false;
};
class TypeEntry
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
index 04aadbb63..27e613280 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
@@ -70,6 +70,7 @@ static inline QString formatAttribute() { return QStringLiteral("format"); }
static inline QString generateUsingAttribute() { return QStringLiteral("generate-using"); }
static inline QString classAttribute() { return QStringLiteral("class"); }
static inline QString generateAttribute() { return QStringLiteral("generate"); }
+static inline QString generateGetSetDefAttribute() { return QStringLiteral("generate-getsetdef"); }
static inline QString genericClassAttribute() { return QStringLiteral("generic-class"); }
static inline QString indexAttribute() { return QStringLiteral("index"); }
static inline QString invalidateAfterUseAttribute() { return QStringLiteral("invalidate-after-use"); }
@@ -2256,6 +2257,10 @@ bool TypeSystemParser::parseProperty(const QXmlStreamReader &, const StackElemen
property.type = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("set")) {
property.write = attributes->takeAt(i).value().toString();
+ } else if (name == generateGetSetDefAttribute()) {
+ property.generateGetSetDef =
+ convertBoolean(attributes->takeAt(i).value(),
+ generateGetSetDefAttribute(), false);
}
}
if (!property.isValid()) {