From c4da68ba28e742810d05d35f0a26ef1d9b8c5b6c Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 30 Jan 2015 03:09:37 +0100 Subject: stuff --- src/plugins/xml/XmlParser.cpp | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index 5e30fec..70ea48c 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -171,8 +171,10 @@ public: parent, structType, logger(), [](Handle parent, Handle structType, Logger &logger) { - structType.cast()->setParentStructure( - parent.cast(), logger); + if (parent != nullptr) { + structType.cast()->setParentStructure( + parent.cast(), logger); + } }); } @@ -201,7 +203,7 @@ public: // Read the argument values const std::string &name = args["name"].asString(); const std::string &type = args["type"].asString(); - const Variant &defaultValue = args["default"]; // Build! + const Variant &defaultValue = args["default"]; const bool optional = !(defaultValue.isObject() && defaultValue.asObject() == nullptr); @@ -210,12 +212,24 @@ public: structType->createAttribute(name, defaultValue, optional, logger()); attribute->setLocation(location()); - // Try to resolve the type - scope().resolve( - type, attribute, logger(), - [](Handle type, Handle attribute, Logger &logger) { - attribute.cast()->setType(type.cast(), logger); + // Try to resolve the type and default value + if (optional) { + scope().resolveTypeWithValue(type, attribute, attribute->getDefaultValue(), logger(), + [](Handle type, Handle attribute, + Logger &logger) { + if (type != nullptr) { + attribute.cast()->setType(type.cast(), logger); + } + }); + } else { + scope().resolveType(type, attribute, logger(), + [](Handle type, Handle attribute, + Logger &logger) { + if (type != nullptr) { + attribute.cast()->setType(type.cast(), logger); + } }); + } } void end() override {} @@ -242,11 +256,13 @@ public: constant->setLocation(location()); // Try to resolve the type - scope().resolve( - type, constant, logger(), - [](Handle type, Handle constant, Logger &logger) { - constant.cast()->setType(type.cast(), logger); - }); + scope().resolveTypeWithValue(type, constant, constant->getValue(), logger(), + [](Handle type, Handle constant, + Logger &logger) { + if (type != nullptr) { + constant.cast()->setType(type.cast(), logger); + } + }); } void end() override {} -- cgit v1.2.3