From 364ca4e55fd99ad0da15cd6fa176c2009f52b729 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 30 Sep 2010 16:13:56 -0700 Subject: added macro for easier static registration --- indra/llxuixml/llregistry.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llregistry.h b/indra/llxuixml/llregistry.h index eee9933739..80e654854a 100644 --- a/indra/llxuixml/llregistry.h +++ b/indra/llxuixml/llregistry.h @@ -343,4 +343,9 @@ private: ScopedRegistrar* mStaticScope; }; +// helper macro for doing static registration +#define GLUED_TOKEN(x, y) x ## y +#define GLUE_TOKENS(x, y) GLUED_TOKEN(x, y) +#define LLREGISTER_STATIC(REGISTRY, KEY, VALUE) static REGISTRY::StaticRegistrar GLUE_TOKENS(reg, __COUNTER__)(KEY, VALUE); + #endif -- cgit v1.2.3 From e7834520c725de122f2e62387e2563723735ab4e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 30 Sep 2010 16:43:16 -0700 Subject: fixed line ending --- indra/llxuixml/llregistry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llregistry.h b/indra/llxuixml/llregistry.h index 80e654854a..546cf38eb5 100644 --- a/indra/llxuixml/llregistry.h +++ b/indra/llxuixml/llregistry.h @@ -343,8 +343,8 @@ private: ScopedRegistrar* mStaticScope; }; -// helper macro for doing static registration -#define GLUED_TOKEN(x, y) x ## y +// helper macro for doing static registration +#define GLUED_TOKEN(x, y) x ## y #define GLUE_TOKENS(x, y) GLUED_TOKEN(x, y) #define LLREGISTER_STATIC(REGISTRY, KEY, VALUE) static REGISTRY::StaticRegistrar GLUE_TOKENS(reg, __COUNTER__)(KEY, VALUE); -- cgit v1.2.3 From 94fbf6805435f98c09a132c807fe3a13aa882b54 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Fri, 1 Oct 2010 16:15:35 -0700 Subject: Fix for build issue on the mac. --- indra/llxuixml/llregistry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llregistry.h b/indra/llxuixml/llregistry.h index 546cf38eb5..36ce6a97b7 100644 --- a/indra/llxuixml/llregistry.h +++ b/indra/llxuixml/llregistry.h @@ -346,6 +346,6 @@ private: // helper macro for doing static registration #define GLUED_TOKEN(x, y) x ## y #define GLUE_TOKENS(x, y) GLUED_TOKEN(x, y) -#define LLREGISTER_STATIC(REGISTRY, KEY, VALUE) static REGISTRY::StaticRegistrar GLUE_TOKENS(reg, __COUNTER__)(KEY, VALUE); +#define LLREGISTER_STATIC(REGISTRY, KEY, VALUE) static REGISTRY::StaticRegistrar GLUE_TOKENS(reg, __LINE__)(KEY, VALUE); #endif -- cgit v1.2.3 From 7a387f25250cc8cfc3b62c4ae845d1a67f4990b3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 5 Oct 2010 14:31:25 -0700 Subject: tighter packing of boolean params by shuffling member variables --- indra/llxuixml/llinitparam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 8cb5bd80fc..ad9b584632 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -303,8 +303,8 @@ namespace LLInitParam private: friend class BaseBlock; - bool mIsProvided; U16 mEnclosingBlockOffset; + bool mIsProvided; }; // various callbacks and constraints associated with an individual param -- cgit v1.2.3 From 5647e745989d6c3e4387ec990a35c4308dd6b929 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 6 Oct 2010 16:56:38 -0700 Subject: added param block support for empty/undefined elements in XML/LLSD respectively. This way or LLSD["foo"]; both define a default constructed value for the parameter named foo, useful in the Multiple case --- indra/llxuixml/llinitparam.cpp | 7 +++++ indra/llxuixml/llinitparam.h | 3 ++ indra/llxuixml/llxuiparser.cpp | 63 +++++++++++++++++++++++++++++++++++++++--- indra/llxuixml/llxuiparser.h | 6 +++- 4 files changed, 74 insertions(+), 5 deletions(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index 2c92539387..7ffcd91879 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -312,6 +312,13 @@ namespace LLInitParam } } + // if no match, and no names left on stack, this is just an existence assertion of this block + // verify by calling readValue with NoValue type, an inherently unparseable type + if (!names_left) + { + return p.readValue(NoValue()); + } + return false; } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index ad9b584632..66ef8e65cd 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -278,6 +278,9 @@ namespace LLInitParam S32 mParseGeneration; }; + // used to indicate no matching value to a given name when parsing + struct NoValue{}; + class BaseBlock; class Param diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index e1ad9a5c71..723a20f382 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -382,6 +382,7 @@ LLXUIParser::LLXUIParser() { if (sXUIReadFuncs.empty()) { + registerParserFuncs(readNoValue, writeNoValue); registerParserFuncs(readBoolValue, writeBoolValue); registerParserFuncs(readStringValue, writeStringValue); registerParserFuncs(readU8Value, writeU8Value); @@ -400,6 +401,7 @@ LLXUIParser::LLXUIParser() } static LLFastTimer::DeclareTimer FTM_PARSE_XUI("XUI Parsing"); +const LLXMLNodePtr DUMMY_NODE = new LLXMLNode(); void LLXUIParser::readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename, bool silent) { @@ -426,6 +428,17 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) boost::char_separator sep("."); bool values_parsed = false; + bool silent = mCurReadDepth > 0; + + if (nodep->getFirstChild().isNull() + && nodep->mAttributes.empty() + && nodep->getSanitizedValue().empty()) + { + // empty node, just parse as NoValue + mCurReadNode = DUMMY_NODE; + return block.submitValue(mNameStack, *this, silent); + } + // submit attributes for current node values_parsed |= readAttributes(nodep, block); @@ -438,7 +451,6 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); // child nodes are not necessarily valid parameters (could be a child widget) // so don't complain once we've recursed - bool silent = mCurReadDepth > 0; if (!block.submitValue(mNameStack, *this, true)) { mNameStack.pop_back(); @@ -543,6 +555,7 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo boost::char_separator sep("."); bool any_parsed = false; + bool silent = mCurReadDepth > 0; for(LLXMLAttribList::const_iterator attribute_it = nodep->mAttributes.begin(); attribute_it != nodep->mAttributes.end(); @@ -561,7 +574,6 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo } // child nodes are not necessarily valid attributes, so don't complain once we've recursed - bool silent = mCurReadDepth > 0; any_parsed |= block.submitValue(mNameStack, *this, silent); while(num_tokens_pushed-- > 0) @@ -628,6 +640,19 @@ LLXMLNodePtr LLXUIParser::getNode(const name_stack_t& stack) return (out_node == mWriteRootNode ? LLXMLNodePtr(NULL) : out_node); } +bool LLXUIParser::readNoValue(Parser& parser, void* val_ptr) +{ + LLXUIParser& self = static_cast(parser); + return self.mCurReadNode == DUMMY_NODE; +} + +bool LLXUIParser::writeNoValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +{ + // just create node + LLXUIParser& self = static_cast(parser); + LLXMLNodePtr node = self.getNode(stack); + return node.notNull(); +} bool LLXUIParser::readBoolValue(Parser& parser, void* val_ptr) { @@ -1043,6 +1068,8 @@ static LLInitParam::Parser::parser_read_func_map_t sSimpleXUIReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sSimpleXUIWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sSimpleXUIInspectFuncs; +const char* NO_VALUE_MARKER = "no_value"; + LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t element_cb) : Parser(sSimpleXUIReadFuncs, sSimpleXUIWriteFuncs, sSimpleXUIInspectFuncs), mLastWriteGeneration(-1), @@ -1051,6 +1078,7 @@ LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t { if (sSimpleXUIReadFuncs.empty()) { + registerParserFuncs(readNoValue); registerParserFuncs(readBoolValue); registerParserFuncs(readStringValue); registerParserFuncs(readU8Value); @@ -1114,6 +1142,8 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl return false; } + mEmptyLeafNode.push_back(false); + if( !XML_ParseBuffer(mParser, bytes_read, TRUE ) ) { LL_WARNS("ReadXUI") << "Error while parsing file " << filename << LL_ENDL; @@ -1121,6 +1151,8 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl return false; } + mEmptyLeafNode.pop_back(); + XML_ParserFree( mParser ); return true; } @@ -1205,8 +1237,14 @@ void LLSimpleXUIParser::startElement(const char *name, const char **atts) } } + // parent node is not empty + mEmptyLeafNode.back() = false; + // we are empty if we have no attributes + mEmptyLeafNode.push_back(atts[0] == NULL); + mTokenSizeStack.push_back(num_tokens_pushed); readAttributes(atts); + } bool LLSimpleXUIParser::readAttributes(const char **atts) @@ -1240,7 +1278,7 @@ bool LLSimpleXUIParser::readAttributes(const char **atts) return any_parsed; } -void LLSimpleXUIParser::processText() +bool LLSimpleXUIParser::processText() { if (!mTextContents.empty()) { @@ -1253,12 +1291,22 @@ void LLSimpleXUIParser::processText() mNameStack.pop_back(); } mTextContents.clear(); + return true; } + return false; } void LLSimpleXUIParser::endElement(const char *name) { - processText(); + bool has_text = processText(); + + // no text, attributes, or children + if (!has_text && mEmptyLeafNode.back()) + { + // submit this as a valueless name (even though there might be text contents we haven't seen yet) + mCurAttributeValueBegin = NO_VALUE_MARKER; + mOutputStack.back().first->submitValue(mNameStack, *this, mParseSilently); + } if (--mOutputStack.back().second == 0) { @@ -1276,6 +1324,7 @@ void LLSimpleXUIParser::endElement(const char *name) mNameStack.pop_back(); } mScope.pop_back(); + mEmptyLeafNode.pop_back(); } void LLSimpleXUIParser::characterData(const char *s, int len) @@ -1322,6 +1371,12 @@ void LLSimpleXUIParser::parserError(const std::string& message) #endif } +bool LLSimpleXUIParser::readNoValue(Parser& parser, void* val_ptr) +{ + LLSimpleXUIParser& self = static_cast(parser); + return self.mCurAttributeValueBegin == NO_VALUE_MARKER; +} + bool LLSimpleXUIParser::readBoolValue(Parser& parser, void* val_ptr) { LLSimpleXUIParser& self = static_cast(parser); diff --git a/indra/llxuixml/llxuiparser.h b/indra/llxuixml/llxuiparser.h index 5c613b0c69..7a748d8aea 100644 --- a/indra/llxuixml/llxuiparser.h +++ b/indra/llxuixml/llxuiparser.h @@ -116,6 +116,7 @@ private: bool readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block); //reader helper functions + static bool readNoValue(Parser& parser, void* val_ptr); static bool readBoolValue(Parser& parser, void* val_ptr); static bool readStringValue(Parser& parser, void* val_ptr); static bool readU8Value(Parser& parser, void* val_ptr); @@ -132,6 +133,7 @@ private: static bool readSDValue(Parser& parser, void* val_ptr); //writer helper functions + static bool writeNoValue(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeBoolValue(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeStringValue(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeU8Value(Parser& parser, const void* val_ptr, const name_stack_t&); @@ -194,6 +196,7 @@ public: private: //reader helper functions + static bool readNoValue(Parser&, void* val_ptr); static bool readBoolValue(Parser&, void* val_ptr); static bool readStringValue(Parser&, void* val_ptr); static bool readU8Value(Parser&, void* val_ptr); @@ -218,7 +221,7 @@ private: void endElement(const char *name); void characterData(const char *s, int len); bool readAttributes(const char **atts); - void processText(); + bool processText(); Parser::name_stack_t mNameStack; struct XML_ParserStruct* mParser; @@ -230,6 +233,7 @@ private: const char* mCurAttributeValueBegin; std::vector mTokenSizeStack; std::vector mScope; + std::vector mEmptyLeafNode; element_start_callback_t mElementCB; std::vector > mOutputStack; -- cgit v1.2.3 From a21be75f605822310d819dcb5c35157676b4f740 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Wed, 6 Oct 2010 17:07:14 -0700 Subject: Fix for a compile error. Reviwed by Richard. --- indra/llxuixml/llinitparam.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index 7ffcd91879..bf2de9360a 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -316,7 +316,8 @@ namespace LLInitParam // verify by calling readValue with NoValue type, an inherently unparseable type if (!names_left) { - return p.readValue(NoValue()); + NoValue no_value; + return p.readValue(no_value); } return false; -- cgit v1.2.3 From 6c0e9432d027dfb363baf4eaff79a835e3e75b37 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 8 Oct 2010 12:18:16 -0700 Subject: potential fix for linux build --- indra/llxuixml/llinitparam.cpp | 4 ++-- indra/llxuixml/llinitparam.h | 2 +- indra/llxuixml/llxuiparser.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llxuixml') diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index bf2de9360a..fcdbaa4309 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -313,10 +313,10 @@ namespace LLInitParam } // if no match, and no names left on stack, this is just an existence assertion of this block - // verify by calling readValue with NoValue type, an inherently unparseable type + // verify by calling readValue with NoParamValue type, an inherently unparseable type if (!names_left) { - NoValue no_value; + NoParamValue no_value; return p.readValue(no_value); } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 66ef8e65cd..1f9045754a 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -279,7 +279,7 @@ namespace LLInitParam }; // used to indicate no matching value to a given name when parsing - struct NoValue{}; + struct NoParamValue{}; class BaseBlock; diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 723a20f382..b321eaf7a6 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -382,7 +382,7 @@ LLXUIParser::LLXUIParser() { if (sXUIReadFuncs.empty()) { - registerParserFuncs(readNoValue, writeNoValue); + registerParserFuncs(readNoValue, writeNoValue); registerParserFuncs(readBoolValue, writeBoolValue); registerParserFuncs(readStringValue, writeStringValue); registerParserFuncs(readU8Value, writeU8Value); @@ -1078,7 +1078,7 @@ LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t { if (sSimpleXUIReadFuncs.empty()) { - registerParserFuncs(readNoValue); + registerParserFuncs(readNoValue); registerParserFuncs(readBoolValue); registerParserFuncs(readStringValue); registerParserFuncs(readU8Value); -- cgit v1.2.3