aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-23 07:37:12 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-23 14:06:46 +0200
commita8b52c80ac54602001b3988ea5f37805c6fe4eb2 (patch)
treee60fb37afd0c6dfb0c184a9d9ab81132ce7ca69d /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parent8526bf4f922df87a0c51d9447bf498a3290dfdbf (diff)
shiboken2: Add a way of specifying properties in typesystem XML
Add a list of TypeSystemProperty to ComplexTypeEntry, parse it from XML and add those properties in AbstractMetaBuilderPrivate::parseQ_Properties(). Task-number: PYSIDE-1019 Change-Id: Idf6ecde7c9de6bf1e56be423921672152e97de70 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index d9cf69e05..4197c4cfa 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -2790,7 +2790,8 @@ void AbstractMetaBuilderPrivate::parseQ_Properties(AbstractMetaClass *metaClass,
{
const QStringList scopes = currentScope()->qualifiedName();
QString errorMessage;
- for (int i = 0; i < declarations.size(); ++i) {
+ int i = 0;
+ for (; i < declarations.size(); ++i) {
if (auto spec = QPropertySpec::parseQ_Property(this, metaClass, declarations.at(i), scopes, &errorMessage)) {
spec->setIndex(i);
metaClass->addPropertySpec(spec);
@@ -2801,6 +2802,26 @@ void AbstractMetaBuilderPrivate::parseQ_Properties(AbstractMetaClass *metaClass,
qCWarning(lcShiboken, "%s", qPrintable(message));
}
}
+
+ // User-added properties
+ auto typeEntry = metaClass->typeEntry();
+ for (const TypeSystemProperty &tp : typeEntry->properties()) {
+ QPropertySpec *spec = nullptr;
+ if (metaClass->propertySpecByName(tp.name))
+ errorMessage = msgPropertyExists(metaClass->name(), tp.name);
+ else
+ spec = QPropertySpec::fromTypeSystemProperty(this, metaClass, tp, scopes, &errorMessage);
+
+ if (spec) {
+ spec->setIndex(i++);
+ metaClass->addPropertySpec(spec);
+ } else {
+ QString message;
+ QTextStream str(&message);
+ str << typeEntry->sourceLocation() << errorMessage;
+ qCWarning(lcShiboken, "%s", qPrintable(message));
+ }
+ }
}
static AbstractMetaFunction* findCopyCtor(AbstractMetaClass* cls)