diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-23 07:37:12 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-23 14:06:46 +0200 |
commit | a8b52c80ac54602001b3988ea5f37805c6fe4eb2 (patch) | |
tree | e60fb37afd0c6dfb0c184a9d9ab81132ce7ca69d /sources/shiboken2/ApiExtractor/typesystemparser.cpp | |
parent | 8526bf4f922df87a0c51d9447bf498a3290dfdbf (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/typesystemparser.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystemparser.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp index 44616da0a..04aadbb63 100644 --- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp @@ -366,6 +366,7 @@ ENUM_LOOKUP_BEGIN(StackElement::ElementType, Qt::CaseInsensitive, {u"object-type", StackElement::ObjectTypeEntry}, {u"parent", StackElement::ParentOwner}, {u"primitive-type", StackElement::PrimitiveTypeEntry}, + {u"property", StackElement::Property}, {u"reference-count", StackElement::ReferenceCount}, {u"reject-enum-value", StackElement::RejectEnumValue}, {u"rejection", StackElement::Rejection}, @@ -2235,6 +2236,36 @@ bool TypeSystemParser::parseAddFunction(const QXmlStreamReader &, return true; } +bool TypeSystemParser::parseProperty(const QXmlStreamReader &, const StackElement &topElement, + QXmlStreamAttributes *attributes) +{ + if ((topElement.type & StackElement::ComplexTypeEntryMask) == 0) { + m_error = QString::fromLatin1("Add property requires a complex type as parent" + ", was=%1").arg(topElement.type, 0, 16); + return false; + } + + TypeSystemProperty property; + for (int i = attributes->size() - 1; i >= 0; --i) { + const auto name = attributes->at(i).qualifiedName(); + if (name == nameAttribute()) { + property.name = attributes->takeAt(i).value().toString(); + } else if (name == QLatin1String("get")) { + property.read = attributes->takeAt(i).value().toString(); + } else if (name == QLatin1String("type")) { + property.type = attributes->takeAt(i).value().toString(); + } else if (name == QLatin1String("set")) { + property.write = attributes->takeAt(i).value().toString(); + } + } + if (!property.isValid()) { + m_error = QLatin1String("<property> element is missing required attibutes (name/type/get)."); + return false; + } + static_cast<ComplexTypeEntry *>(topElement.entry)->addProperty(property); + return true; +} + bool TypeSystemParser::parseModifyFunction(const QXmlStreamReader &reader, const StackElement &topElement, QXmlStreamAttributes *attributes) @@ -3000,6 +3031,10 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader) if (!parseAddFunction(reader, topElement, &attributes)) return false; break; + case StackElement::Property: + if (!parseProperty(reader, topElement, &attributes)) + return false; + break; case StackElement::ModifyFunction: if (!parseModifyFunction(reader, topElement, &attributes)) return false; |