From 7e6e3d20f334547d8cea78e8e0b37106efebe028 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Nov 2011 13:48:38 -0800 Subject: added Lazy modifier to params to support recursion ChoiceBlock can now derive from another param block Params with name/value support can be assigned directly in C++ code using param = "named_value" --- indra/llxuixml/llxuiparser.cpp | 258 +++++++++++++++++++++++++++++++---------- 1 file changed, 197 insertions(+), 61 deletions(-) (limited to 'indra/llxuixml/llxuiparser.cpp') diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 878f992178..cdf578113a 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -59,28 +59,26 @@ const char* NO_VALUE_MARKER = "no_value"; const S32 LINE_NUMBER_HERE = 0; -struct MaxOccur : public LLInitParam::ChoiceBlock +struct MaxOccursValues : public LLInitParam::TypeValuesHelper { - Alternative count; - Alternative unbounded; - - MaxOccur() - : unbounded("", "unbounded") - {} + using TypeValuesHelper::operator =; + typedef std::string name_t; + static void declareValues() + { + declare("unbounded", U32_MAX); + } }; struct Occurs : public LLInitParam::Block { - Optional minOccurs; - Optional maxOccurs; + Optional minOccurs; + Optional maxOccurs; + Multiple foo; Occurs() - : minOccurs("minOccurs"), - maxOccurs("maxOccurs") - { - minOccurs = 0; - maxOccurs.unbounded.choose(); - } + : minOccurs("minOccurs", 0), + maxOccurs("maxOccurs", U32_MAX) + {} }; @@ -103,18 +101,15 @@ namespace LLInitParam }; } -struct Name : public LLInitParam::Block -{ - Mandatory name; - - Name() - : name("name") - {} -}; +struct Element; +struct Group; +struct Choice; +struct Sequence; +struct Any; struct Attribute : public LLInitParam::Block { - Mandatory name; + Mandatory name; Mandatory type; Mandatory use; @@ -122,41 +117,170 @@ struct Attribute : public LLInitParam::Block : name("name"), type("type"), use("use") + {} +}; + +struct Any : public LLInitParam::Block +{ + Optional _namespace; + + Any() + : _namespace("namespace") + {} +}; + +struct All : public LLInitParam::Block +{ + Multiple> elements; + + All() + : elements("element") { + maxOccurs = 1; } }; -struct ComplexType : public LLInitParam::Block +struct Choice : public LLInitParam::ChoiceBlock +{ + Alternative> element; + Alternative> group; + Alternative> choice; + Alternative> sequence; + Alternative> any; + + Choice() + : element("element"), + group("group"), + choice("choice"), + sequence("sequence"), + any("any") + {} + +}; + +struct Sequence : public LLInitParam::ChoiceBlock +{ + Alternative> element; + Alternative> group; + Alternative> choice; + Alternative> sequence; + Alternative> any; +}; + +struct GroupContents : public LLInitParam::ChoiceBlock { - Multiple attribute; - //Multiple elements; - Optional mixed; + Alternative all; + Alternative choice; + Alternative sequence; + + GroupContents() + : all("all"), + choice("choice"), + sequence("sequence") + {} +}; + +struct Group : public LLInitParam::Block +{ + Optional name, + ref; + + Group() + : name("name"), + ref("ref") + {} +}; + +struct Restriction : public LLInitParam::Block +{ +}; + +struct Extension : public LLInitParam::Block +{ +}; + +struct SimpleContent : public LLInitParam::ChoiceBlock +{ + Alternative restriction; + Alternative extension; + + SimpleContent() + : restriction("restriction"), + extension("extension") + {} +}; + +struct SimpleType : public LLInitParam::Block +{ + // TODO +}; + +struct ComplexContent : public LLInitParam::Block +{ + Optional mixed; + + ComplexContent() + : mixed("mixed", true) + {} +}; + +struct ComplexTypeContents : public LLInitParam::ChoiceBlock +{ + Alternative simple_content; + Alternative complex_content; + Alternative group; + Alternative all; + Alternative choice; + Alternative sequence; + + ComplexTypeContents() + : simple_content("simpleContent"), + complex_content("complexContent"), + group("group"), + all("all"), + choice("choice"), + sequence("sequence") + {} +}; + +struct ComplexType : public LLInitParam::Block +{ + Optional name; + Optional mixed; + + Multiple attribute; + Multiple> elements; ComplexType() - : attribute("xs:attribute"), - //elements("xs:element"), + : name("name"), + attribute("xs:attribute"), + elements("xs:element"), mixed("mixed") { - mixed = true; } }; -struct Element : public LLInitParam::Block +struct ElementContents : public LLInitParam::ChoiceBlock { - Mandatory complexType; - Mandatory name; + Alternative simpleType; + Alternative complexType; - Element() - : complexType("xs:complexType") + ElementContents() + : simpleType("simpleType"), + complexType("complexType") {} }; -struct Elements : public LLInitParam::Block +struct Element : public LLInitParam::Block { - Multiple elements; + Optional name, + ref, + type; - Elements() - : elements("xs:element") + Element() + : name("xs:name"), + ref("xs:ref"), + type("xs:type") {} }; @@ -164,28 +288,32 @@ struct Schema : public LLInitParam::Block { private: Mandatory targetNamespace, - xmlns; + xmlns, + xs; public: Optional attributeFormDefault, - elementFormDefault, - xs; + elementFormDefault; - Optional elements; + Mandatory root_element; void setNameSpace(const std::string& ns) {targetNamespace = ns; xmlns = ns;} - Schema() + Schema(const std::string& ns = LLStringUtil::null) : attributeFormDefault("attributeFormDefault"), elementFormDefault("elementFormDefault"), xs("xmlns:xs"), targetNamespace("targetNamespace"), xmlns("xmlns"), - elements("xs:choice") + root_element("xs:element") { attributeFormDefault = "unqualified"; elementFormDefault = "qualified"; xs = "http://www.w3.org/2001/XMLSchema"; + if (!ns.empty()) + { + setNameSpace(ns); + }; } }; @@ -214,22 +342,30 @@ LLXSDWriter::LLXSDWriter() void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace) { + Schema schema(xml_namespace); + + schema.root_element.name = type_name; + Choice& choice = schema.root_element.complexType.choice; + + choice.minOccurs = 0; + choice.maxOccurs = "unbounded"; + mSchemaNode = node; - node->setName("xs:schema"); - node->createChild("attributeFormDefault", true)->setStringValue("unqualified"); - node->createChild("elementFormDefault", true)->setStringValue("qualified"); - node->createChild("targetNamespace", true)->setStringValue(xml_namespace); - node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema"); - node->createChild("xmlns", true)->setStringValue(xml_namespace); - - node = node->createChild("xs:complexType", false); - node->createChild("name", true)->setStringValue(type_name); - node->createChild("mixed", true)->setStringValue("true"); - - mAttributeNode = node; - mElementNode = node->createChild("xs:choice", false); - mElementNode->createChild("minOccurs", true)->setStringValue("0"); - mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded"); + //node->setName("xs:schema"); + //node->createChild("attributeFormDefault", true)->setStringValue("unqualified"); + //node->createChild("elementFormDefault", true)->setStringValue("qualified"); + //node->createChild("targetNamespace", true)->setStringValue(xml_namespace); + //node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema"); + //node->createChild("xmlns", true)->setStringValue(xml_namespace); + + //node = node->createChild("xs:complexType", false); + //node->createChild("name", true)->setStringValue(type_name); + //node->createChild("mixed", true)->setStringValue("true"); + + //mAttributeNode = node; + //mElementNode = node->createChild("xs:choice", false); + //mElementNode->createChild("minOccurs", true)->setStringValue("0"); + //mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded"); block.inspectBlock(*this); // duplicate element choices -- cgit v1.2.3 From 2ee4bae1a39814467e4bd361211f7836266af880 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 16 Nov 2011 12:28:10 -0800 Subject: support for assignment of named values to params, works with string-typed params as well as () operator --- indra/llxuixml/llxuiparser.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llxuixml/llxuiparser.cpp') diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index cdf578113a..90c2671242 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -61,8 +61,6 @@ const S32 LINE_NUMBER_HERE = 0; struct MaxOccursValues : public LLInitParam::TypeValuesHelper { - using TypeValuesHelper::operator =; - typedef std::string name_t; static void declareValues() { declare("unbounded", U32_MAX); @@ -73,11 +71,11 @@ struct Occurs : public LLInitParam::Block { Optional minOccurs; Optional maxOccurs; - Multiple foo; Occurs() : minOccurs("minOccurs", 0), maxOccurs("maxOccurs", U32_MAX) + {} }; -- cgit v1.2.3 From 2851cd519338ef4a1fde15da8d4015ab4380d6cb Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 28 Nov 2011 11:33:49 -0700 Subject: a try fix for sh-2651: [crashhunters] Crash after google translate failure and sh-2658: crash in LLPluginMessage::parse --- indra/llxuixml/llxuiparser.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llxuixml/llxuiparser.cpp') diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 878f992178..5a525f84a8 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -1247,6 +1247,7 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl if( !file.isOpen() ) { LL_WARNS("ReadXUI") << "Unable to open file " << filename << LL_ENDL; + XML_ParserFree( mParser ); return false; } -- cgit v1.2.3 From 770538f992a42cdda091f93e8b318e35372aaad2 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 1 Dec 2011 10:42:15 -0800 Subject: Build fixes for mac, hopefully Linux too --- indra/llxuixml/llxuiparser.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/llxuixml/llxuiparser.cpp') diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 90c2671242..58654dcc21 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -129,7 +129,7 @@ struct Any : public LLInitParam::Block struct All : public LLInitParam::Block { - Multiple> elements; + Multiple< Lazy > elements; All() : elements("element") @@ -140,11 +140,11 @@ struct All : public LLInitParam::Block struct Choice : public LLInitParam::ChoiceBlock { - Alternative> element; - Alternative> group; - Alternative> choice; - Alternative> sequence; - Alternative> any; + Alternative< Lazy > element; + Alternative< Lazy > group; + Alternative< Lazy > choice; + Alternative< Lazy > sequence; + Alternative< Lazy > any; Choice() : element("element"), @@ -158,11 +158,11 @@ struct Choice : public LLInitParam::ChoiceBlock struct Sequence : public LLInitParam::ChoiceBlock { - Alternative> element; - Alternative> group; - Alternative> choice; - Alternative> sequence; - Alternative> any; + Alternative< Lazy > element; + Alternative< Lazy > group; + Alternative< Lazy > choice; + Alternative< Lazy > sequence; + Alternative< Lazy > any; }; struct GroupContents : public LLInitParam::ChoiceBlock @@ -247,7 +247,7 @@ struct ComplexType : public LLInitParam::Block Optional mixed; Multiple attribute; - Multiple> elements; + Multiple< Lazy > elements; ComplexType() : name("name"), -- cgit v1.2.3