From a8b52c80ac54602001b3988ea5f37805c6fe4eb2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 23 Sep 2020 07:37:12 +0200 Subject: 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 --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp') 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) -- cgit v1.2.3