From 0463affed4d6ca08c0554974130aba83af13efa5 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 18 Jan 2015 18:22:51 +0100 Subject: Parsing struct attributes, added ability to reference other typesystems from a typesystem --- src/plugins/xml/XmlParser.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index cd220a9..bcac7d3 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -93,7 +93,7 @@ public: // Try to resolve the parent type and set it as parent structure if (!parent.empty()) { - scope().resolve(Utils::split(parent, '.'), logger(), + scope().resolve(parent, logger(), [structType](Handle parent, Logger &logger) mutable { structType->setParentStructure( @@ -125,13 +125,22 @@ public: void start(Variant::mapType &args) override { // Read the argument values - /* const std::string &name = args["name"].asString(); - const std::string &type = args["parent"].asString(); - const Variant &defaultValue = args["default"]; - const bool optional = !(defaultValue.isObject() && - defaultValue.asObject() == nullptr);*/ - - // Try to resolve the + const std::string &name = args["name"].asString(); + const std::string &type = args["type"].asString(); + const Variant &defaultValue = args["default"]; + const bool optional = + !(defaultValue.isObject() && defaultValue.asObject() == nullptr); + + Rooted structType = scope().getLeaf().cast(); + Rooted attribute = structType->createAttribute( + name, defaultValue, optional, logger()); + + // Try to resolve the type + scope().resolve(type, logger(), + [attribute](Handle type, Logger &logger) mutable { + attribute->setType(type, logger); + }, + location()); } void end() override {} -- cgit v1.2.3