From 7183cecd14fbdc3cd31e1482248fabec7b23b1fb Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 5 Feb 2013 16:37:37 +0000 Subject: STORM-1831 merging in previous work --- indra/llui/llkeywords.cpp | 558 +++++++++++++++++++++++++++++++++------------- 1 file changed, 407 insertions(+), 151 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index c1cd04186b..2ff0298ba6 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llkeywords.cpp * @brief Keyword list for LSL * * $LicenseInfo:firstyear=2000&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -29,12 +29,12 @@ #include #include +#include "lldir.h" #include "llkeywords.h" +#include "llsdserialize.h" #include "lltexteditor.h" #include "llstl.h" -#include -const U32 KEYWORD_FILE_CURRENT_VERSION = 2; inline BOOL LLKeywordToken::isHead(const llwchar* s) const { @@ -53,10 +53,6 @@ inline BOOL LLKeywordToken::isHead(const llwchar* s) const return res; } -LLKeywords::LLKeywords() : mLoaded(FALSE) -{ -} - inline BOOL LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; @@ -73,6 +69,12 @@ inline BOOL LLKeywordToken::isTail(const llwchar* s) const return res; } +LLKeywords::LLKeywords() : mLoaded(FALSE) +{ + setFilenameColors( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_colors.xml") ); + setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_tokens.xml") ); +} + LLKeywords::~LLKeywords() { std::for_each(mWordTokenMap.begin(), mWordTokenMap.end(), DeletePairedPointer()); @@ -80,180 +82,418 @@ LLKeywords::~LLKeywords() std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); } -BOOL LLKeywords::loadFromFile( const std::string& filename ) + + +void LLKeywords::addColorGroup(const std::string key_in, const LLColor3 color) { - mLoaded = FALSE; + WStringMapIndex key ( utf8str_to_wstring(key_in) ); + mColorGroupMap[key] = color; +} - //////////////////////////////////////////////////////////// - // File header +// Add the token as described +void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, + const std::string& key_in, + const LLColor3& color, + const std::string& tool_tip_in, + const std::string& delimiter_in) +{ + std::string tip_text = tool_tip_in; + LLStringUtil::replaceString(tip_text, "\\n", "\n" ); + LLStringUtil::replaceString(tip_text, "\t", " " ); + if (tip_text =="") + { + tip_text = "[no info]"; + } + LLWString tool_tip = utf8str_to_wstring(tip_text); - const S32 BUFFER_SIZE = 1024; - char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */ + LLWString key = utf8str_to_wstring(key_in); + LLWString delimiter = utf8str_to_wstring(delimiter_in); + switch(type) + { + case LLKeywordToken::TT_CONSTANT: + case LLKeywordToken::TT_EVENT: + case LLKeywordToken::TT_FLOW: + case LLKeywordToken::TT_FUNCTION: + case LLKeywordToken::TT_LABEL: + case LLKeywordToken::TT_SECTION: + case LLKeywordToken::TT_TYPE: + case LLKeywordToken::TT_WORD: + mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null); + break; - llifstream file; - file.open(filename); /* Flawfinder: ignore */ - if( file.fail() ) + case LLKeywordToken::TT_LINE: + mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null)); + break; + + case LLKeywordToken::TT_TWO_SIDED_DELIMITER: + case LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS: + case LLKeywordToken::TT_ONE_SIDED_DELIMITER: + mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, delimiter)); + break; + + default: + llassert(0); + } +} + +std::string LLKeywords::getArguments(LLSD& arguments) +{ + std::string args = ""; + if (arguments.isArray()) { - llinfos << "LLKeywords::loadFromFile() Unable to open file: " << filename << llendl; - return mLoaded; + int count = 0; + do + { + LLSD arg = arguments[count]; + args += arg.get("type").asString() + " " + arg.get("name").asString(); + ++count; + if (arguments.size() - count > 0) + { + args += ", "; + } + } while (count < arguments.size()); } + else + { + LL_WARNS("Arguments") << "Not an array! Invalid LLSD passed to function.\n" << arguments << LL_ENDL; + } + return args == "" ? " void " : args; +} - // Identifying string - file >> buffer; - if( strcmp( buffer, "llkeywords" ) ) +std::string LLKeywords::getAttribute(const std::string& key) +{ + attribute_iterator_t it = mAttributes.find(key); + return (it != mAttributes.end()) ? it->second : ""; +} + +LLColor3 LLKeywords::getColorGroup(const std::string key_in) +{ + // LLColor3 initialises to Black (0,0,0) + LLColor3 Colour; + WStringMapIndex key ( utf8str_to_wstring(key_in) ); + group_color_map_t::iterator it = mColorGroupMap.find(key); + if (it == mColorGroupMap.end()) + { + LL_WARNS("Colour lookup") << "'" << key_in << "' not found!" << LL_ENDL; + } + else { - llinfos << filename << " does not appear to be a keyword file" << llendl; - return mLoaded; + Colour = it->second; } - // Check file version - file >> buffer; - U32 version_num; - file >> version_num; - if( strcmp(buffer, "version") || version_num != (U32)KEYWORD_FILE_CURRENT_VERSION ) + return Colour; +} + +BOOL LLKeywords::initialise() +{ + mReady = false; + + if (! loadIntoLLSD(mFilenameColors, mColors) ) { - llinfos << filename << " does not appear to be a version " << KEYWORD_FILE_CURRENT_VERSION << " keyword file" << llendl; - return mLoaded; + LL_ERRS("") << "Failed to load color data, cannot continue!" << LL_ENDL; + } + else if (! loadIntoLLSD(mFilenameSyntax, mSyntax) ) + { + LL_ERRS("") << "Failed to load syntax data from '" << mFilenameSyntax << "', cannot continue!" << LL_ENDL; + } + else + { + mReady = true; } - // start of line (SOL) - std::string SOL_COMMENT("#"); - std::string SOL_WORD("[word "); - std::string SOL_LINE("[line "); - std::string SOL_ONE_SIDED_DELIMITER("[one_sided_delimiter "); - std::string SOL_TWO_SIDED_DELIMITER("[two_sided_delimiter "); - std::string SOL_DOUBLE_QUOTATION_MARKS("[double_quotation_marks "); + if (ready()) + { + processColors(); + } + else + { + LL_ERRS("") << LL_ENDL; + LL_ERRS("") << "Failed to load one or both data files, cannot continue!" << LL_ENDL; + } + return mReady; +} - LLColor3 cur_color( 1, 0, 0 ); - LLKeywordToken::TOKEN_TYPE cur_type = LLKeywordToken::WORD; +BOOL LLKeywords::loadFromFile() +{ + processTokens(); + return true; +} - while (!file.eof()) +/** + * @brief Load xml serialised LLSD + * @desc Opens the specified filespec and attempts to deserialise the + * contained data to the specified LLSD object. + * @return Returns boolean true/false indicating success or failure. + */ +BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +{ + mLoaded = false; + llifstream file; + file.open(filename); + if(file.is_open()) { - buffer[0] = 0; - file.getline( buffer, BUFFER_SIZE ); - std::string line(buffer); - if( line.find(SOL_COMMENT) == 0 ) - { - continue; - } - else if( line.find(SOL_WORD) == 0 ) + mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); + if (!mLoaded) { - cur_color = readColor( line.substr(SOL_WORD.size()) ); - cur_type = LLKeywordToken::WORD; - continue; + LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; } - else if( line.find(SOL_LINE) == 0 ) + else { - cur_color = readColor( line.substr(SOL_LINE.size()) ); - cur_type = LLKeywordToken::LINE; - continue; - } - else if( line.find(SOL_TWO_SIDED_DELIMITER) == 0 ) - { - cur_color = readColor( line.substr(SOL_TWO_SIDED_DELIMITER.size()) ); - cur_type = LLKeywordToken::TWO_SIDED_DELIMITER; - continue; - } - else if( line.find(SOL_DOUBLE_QUOTATION_MARKS) == 0 ) - { - cur_color = readColor( line.substr(SOL_DOUBLE_QUOTATION_MARKS.size()) ); - cur_type = LLKeywordToken::DOUBLE_QUOTATION_MARKS; - continue; - } - else if( line.find(SOL_ONE_SIDED_DELIMITER) == 0 ) - { - cur_color = readColor( line.substr(SOL_ONE_SIDED_DELIMITER.size()) ); - cur_type = LLKeywordToken::ONE_SIDED_DELIMITER; - continue; + LL_INFOS("") << "Deserialised file: " << filename << LL_ENDL; } + } + else + { + LL_WARNS("") << "Unable to open file: " << filename << LL_ENDL; + } + return mLoaded; +} + +/** + * @brief Start processing the colour LLSD from its beginning. + * + */ +std::string LLKeywords::processColors() +{ + return processColors(mColors, ""); +} - std::string token_buffer( line ); - LLStringUtil::trim(token_buffer); - - typedef boost::tokenizer > tokenizer; - boost::char_separator sep_word("", " \t"); - tokenizer word_tokens(token_buffer, sep_word); - tokenizer::iterator token_word_iter = word_tokens.begin(); +/** + * @brief Recursively process the colour LLSD from an arbitrary level. + * @desc Process the supplied LLSD for colour data. The strPrefix is a string + * of hyphen separated keys from previous levels. + */ +std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefix) +{ + if (settings.isMap() || (! settings.isMap() && strPrefix != "") ) + { + LLSD llsd_map = settings; - if( !token_buffer.empty() && token_word_iter != word_tokens.end() ) + LLSD::map_iterator my_iter = llsd_map.beginMap(); + for ( ; my_iter != llsd_map.endMap(); ++my_iter) { - // first word is the keyword or a left delimiter - std::string keyword = (*token_word_iter); - LLStringUtil::trim(keyword); + std::string strGroup = strPrefix; + const LLSD::String& key = my_iter->first; + LLSD& value = my_iter->second; - // second word may be a right delimiter - std::string delimiter; - if (cur_type == LLKeywordToken::TWO_SIDED_DELIMITER) + if (key == "color") { - while (delimiter.length() == 0 && ++token_word_iter != word_tokens.end()) + if (value.isMap() || value.isArray()) + { + addColorGroup(strGroup, readColor(value)); + } + else { - delimiter = *token_word_iter; - LLStringUtil::trim(delimiter); + LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; } } - else if (cur_type == LLKeywordToken::DOUBLE_QUOTATION_MARKS) + else if (value.isMap()) + { + strGroup += (strGroup.length() == 0) ? my_iter->first : "-" + my_iter->first; + strGroup = processColors(value, strGroup); + } + else { - // Closing delimiter is identical to the opening one. - delimiter = keyword; + LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; } + } + } + return strPrefix; +} - // following words are tooltip - std::string tool_tip; - while (++token_word_iter != word_tokens.end()) +void LLKeywords::processTokens() +{ + // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD + std::string delimiter; + addToken(LLKeywordToken::TT_LINE, "@", getColorGroup("misc-flow-label"), "Label\nTarget for jump statement", delimiter ); + addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment\nNon-functional commentary or disabled code", delimiter ); + addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment\nNon-functional commentary or disabled code (multi-line)", "*/" ); + addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); + + LLSD::map_iterator outerIt = mSyntax.beginMap(); + for ( ; outerIt != mSyntax.endMap(); ++outerIt) + { + // TODO Collapse the 'if's into two, those that call 'processTokens' directly and an else if (for 'misc') that doesn't + if (outerIt->first == "constants") + { + if (outerIt->second.isMap()) + { + processTokensGroup(outerIt->second, "constants"); + } + else + { + LL_ERRS("Tokens-Constants") << "No constants map to process!" << LL_ENDL; + } + } + else if(outerIt->first == "misc") + { + if (outerIt->second.isMap()) { - tool_tip += (*token_word_iter); + LLSD::map_iterator innerIt = outerIt->second.beginMap(); + for ( ; innerIt != outerIt->second.endMap(); ++innerIt) + { + processTokensGroup(innerIt->second, "misc-" + innerIt->first); + } } - LLStringUtil::trim(tool_tip); - - if( !tool_tip.empty() ) + else { - // Replace : with \n for multi-line tool tips. - LLStringUtil::replaceChar( tool_tip, ':', '\n' ); - addToken(cur_type, keyword, cur_color, tool_tip, delimiter ); + LL_ERRS("Tokens-Misc") << "No misc map to process!" << LL_ENDL; + } + } + else if(outerIt->first == "events") + { + if (outerIt->second.isMap()) + { + processTokensGroup(outerIt->second, "events"); } else { - addToken(cur_type, keyword, cur_color, LLStringUtil::null, delimiter ); + LL_ERRS("Tokens-Events") << "No event map to process!" << LL_ENDL; } } + else if(outerIt->first == "functions") + { + if (outerIt->second.isMap()) + { + processTokensGroup(outerIt->second, "functions"); + } + else + { + LL_ERRS("Tokens-Functions") << "No function map to process!" << LL_ENDL; + } + } + else if(outerIt->first == "types") + { + if (outerIt->second.isArray()) + { + processTokensGroup(outerIt->second, "types"); + } + else + { + LL_ERRS("Tokens-Types") << "No types array to process!" << LL_ENDL; + } + } + else + { + LL_ERRS("Tokens") << "Unknown token group '" << outerIt->first << "'" << LL_ENDL; + } } - - file.close(); - - mLoaded = TRUE; - return mLoaded; + LL_INFOS("") << LL_ENDL; } -// Add the token as described -void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, - const std::string& key_in, - const LLColor3& color, - const std::string& tool_tip_in, - const std::string& delimiter_in) +void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { - LLWString key = utf8str_to_wstring(key_in); - LLWString tool_tip = utf8str_to_wstring(tool_tip_in); - LLWString delimiter = utf8str_to_wstring(delimiter_in); - switch(type) + LLColor3 Color = getColorGroup(Group); + LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; + + LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; + // If a new token type is added here, it must also be added to the 'addToken' method + if (Group == "constants") { - case LLKeywordToken::WORD: - mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null); - break; + token_type = LLKeywordToken::TT_CONSTANT; + } + else if (Group == "events") + { + token_type = LLKeywordToken::TT_EVENT; + } + else if (Group == "misc-flow-control") + { + token_type = LLKeywordToken::TT_FLOW; + } + else if (Group == "functions") + { + token_type = LLKeywordToken::TT_FUNCTION; + } + else if (Group == "misc-flow-label") + { + token_type = LLKeywordToken::TT_LABEL; + } + else if (Group == "misc-sections") + { + token_type = LLKeywordToken::TT_SECTION; + } + else if (Group == "types") + { + token_type = LLKeywordToken::TT_TYPE; + } - case LLKeywordToken::LINE: - mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null)); - break; + if (Tokens.isMap()) // constants, events, functions, and misc + { + LLSD::map_iterator outerIt = Tokens.beginMap(); + for ( ; outerIt != Tokens.endMap(); ++outerIt) + { + if (outerIt->second.isMap()) + { + mAttributes.clear(); + LLSD arguments = LLSD (); + LLSD::map_iterator innerIt = outerIt->second.beginMap(); + for ( ; innerIt != outerIt->second.endMap(); ++innerIt) + { + if (innerIt->first != "arguments") + { + mAttributes[innerIt->first] = innerIt->second.asString(); + } + else if (innerIt->second.isArray()) + { + arguments = innerIt->second; + } + } - case LLKeywordToken::TWO_SIDED_DELIMITER: - case LLKeywordToken::DOUBLE_QUOTATION_MARKS: - case LLKeywordToken::ONE_SIDED_DELIMITER: - mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, delimiter)); - break; + std::string tooltip = ""; + if (token_type == LLKeywordToken::TT_CONSTANT) + { + Color = getColorGroup(Group + "-" + getAttribute("type")); + tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); + } + else if (token_type == LLKeywordToken::TT_EVENT) + { + tooltip = outerIt->first + "(" + getArguments(arguments) + ")"; + } + else if (token_type == LLKeywordToken::TT_FLOW) + { + tooltip = "flow baby"; + } + else if (token_type == LLKeywordToken::TT_FUNCTION) + { + tooltip = getAttribute("return") + " " + outerIt->first + "(" + getArguments(arguments) + ");"; + tooltip += "\nEnergy: "; + tooltip += getAttribute("energy") == "" ? "0.0" : getAttribute("energy"); + if (getAttribute("sleep") != "") + { + tooltip += ", Sleep: " + getAttribute("sleep"); + } + } + else if (token_type == LLKeywordToken::TT_SECTION) + { + tooltip = "section"; + } - default: - llassert(0); + if (getAttribute("summry") != "") + { + tooltip += "\n" + getAttribute("summary"); + } + else if (getAttribute("description") != "") + { + tooltip += "\n" + getAttribute("description"); + } + + addToken(token_type, outerIt->first, Color, tooltip); + } + } + } + else if (Tokens.isArray()) // types + { + for (int count = 0; count < Tokens.size(); ++count) + { + addToken(token_type, Tokens[count], Color, ""); + } + } + else + { + LL_INFOS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; } } + LLKeywords::WStringMapIndex::WStringMapIndex(const WStringMapIndex& other) { if(other.mOwner) @@ -298,13 +538,13 @@ bool LLKeywords::WStringMapIndex::operator<(const LLKeywords::WStringMapIndex &o { // NOTE: Since this is only used to organize a std::map, it doesn't matter if it uses correct collate order or not. // The comparison only needs to strictly order all possible strings, and be stable. - + bool result = false; const llwchar* self_iter = mData; const llwchar* self_end = mData + mLength; const llwchar* other_iter = other.mData; const llwchar* other_end = other.mData + other.mLength; - + while(true) { if(other_iter >= other_end) @@ -319,7 +559,7 @@ bool LLKeywords::WStringMapIndex::operator<(const LLKeywords::WStringMapIndex &o { // self is shorter than other. result = true; - break; + break; } else if(*self_iter != *other_iter) { @@ -331,7 +571,7 @@ bool LLKeywords::WStringMapIndex::operator<(const LLKeywords::WStringMapIndex &o self_iter++; other_iter++; } - + return result; } @@ -347,6 +587,22 @@ LLColor3 LLKeywords::readColor( const std::string& s ) return LLColor3( r, g, b ); } +LLColor3 LLKeywords::readColor(LLSD& sd) +{ + if (sd.isArray()) + { + return LLColor3 (sd); + } + else if (sd.isMap()) + { + return LLColor3 ( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal() ); + } + else + { + return LLColor3::black; + } +} + LLFastTimer::DeclareTimer FTM_SYNTAX_COLORING("Syntax Coloring"); // Walk through a string, applying the rules specified by the keyword token list and @@ -360,10 +616,10 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW { return; } - + S32 text_len = wtext.size() + 1; - seg_list->push_back( new LLNormalTextSegment( defaultColor, 0, text_len, editor ) ); + seg_list->push_back( new LLNormalTextSegment( defaultColor, 0, text_len, editor ) ); const llwchar* base = wtext.c_str(); const llwchar* cur = base; @@ -398,7 +654,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW continue; } - // cur is now at the first non-whitespace character of a new line + // cur is now at the first non-whitespace character of a new line // Line start tokens { @@ -416,7 +672,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW cur++; } S32 seg_end = cur - base; - + //create segments from seg_start to seg_end insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, defaultColor, editor); line_done = TRUE; // to break out of second loop. @@ -461,14 +717,14 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW seg_start = cur - base; cur += cur_delimiter->getLengthHead(); - + LLKeywordToken::TOKEN_TYPE type = cur_delimiter->getType(); - if( type == LLKeywordToken::TWO_SIDED_DELIMITER || type == LLKeywordToken::DOUBLE_QUOTATION_MARKS ) + if( type == LLKeywordToken::TT_TWO_SIDED_DELIMITER || type == LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS ) { while( *cur && !cur_delimiter->isTail(cur)) { // Check for an escape sequence. - if (type == LLKeywordToken::DOUBLE_QUOTATION_MARKS && *cur == '\\') + if (type == LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS && *cur == '\\') { // Count the number of backslashes. S32 num_backslashes = 0; @@ -515,7 +771,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW } else { - llassert( cur_delimiter->getType() == LLKeywordToken::ONE_SIDED_DELIMITER ); + llassert( cur_delimiter->getType() == LLKeywordToken::TT_ONE_SIDED_DELIMITER ); // Left side is the delimiter. Right side is eol or eof. while( *cur && ('\n' != *cur) ) { @@ -561,7 +817,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, defaultColor, editor); } - cur += seg_len; + cur += seg_len; continue; } } @@ -577,7 +833,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW void LLKeywords::insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* cur_token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor ) { std::string::size_type pos = wtext.find('\n',seg_start); - + while (pos!=-1 && pos < (std::string::size_type)seg_end) { if (pos!=seg_start) @@ -656,7 +912,7 @@ void LLKeywords::dump() void LLKeywordToken::dump() { - llinfos << "[" << + llinfos << "[" << mColor.mV[VX] << ", " << mColor.mV[VY] << ", " << mColor.mV[VZ] << "] [" << -- cgit v1.2.3 From 582babac2f1acd7f558fa4bf13034c5f306fe115 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Feb 2013 21:50:38 +0000 Subject: STORM-1831 Changes to LLSD structure and corresponding processing in llkeywords. Plus some formating clean ups. --- indra/llui/llkeywords.cpp | 99 ++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 45 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 2ff0298ba6..0481948a09 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -111,8 +111,8 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, switch(type) { case LLKeywordToken::TT_CONSTANT: + case LLKeywordToken::TT_CONTROL: case LLKeywordToken::TT_EVENT: - case LLKeywordToken::TT_FLOW: case LLKeywordToken::TT_FUNCTION: case LLKeywordToken::TT_LABEL: case LLKeywordToken::TT_SECTION: @@ -139,23 +139,23 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, std::string LLKeywords::getArguments(LLSD& arguments) { std::string args = ""; - if (arguments.isArray()) + if (arguments.isMap()) { - int count = 0; - do + int count = arguments.size(); + LLSD::map_iterator argsIt = arguments.beginMap(); + for ( ; argsIt != arguments.endMap(); ++argsIt) { - LLSD arg = arguments[count]; - args += arg.get("type").asString() + " " + arg.get("name").asString(); - ++count; - if (arguments.size() - count > 0) - { - args += ", "; - } - } while (count < arguments.size()); + LLSD arg = argsIt->second; + args += arg.get("type").asString() + " " + argsIt->first; + if (count-- > 1) + { + args += ", "; + } + } } - else + else if (!arguments.isUndefined()) { - LL_WARNS("Arguments") << "Not an array! Invalid LLSD passed to function.\n" << arguments << LL_ENDL; + LL_WARNS("Arguments") << "Not a map! Invalid LLSD passed to function.\n" << arguments << LL_ENDL; } return args == "" ? " void " : args; } @@ -305,7 +305,7 @@ void LLKeywords::processTokens() { // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD std::string delimiter; - addToken(LLKeywordToken::TT_LINE, "@", getColorGroup("misc-flow-label"), "Label\nTarget for jump statement", delimiter ); + addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("label"), "Label\nTarget for jump statement", delimiter ); addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment\nNon-functional commentary or disabled code", delimiter ); addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment\nNon-functional commentary or disabled code (multi-line)", "*/" ); addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); @@ -325,6 +325,17 @@ void LLKeywords::processTokens() LL_ERRS("Tokens-Constants") << "No constants map to process!" << LL_ENDL; } } + else if (outerIt->first == "controls") + { + if (outerIt->second.isMap()) + { + processTokensGroup(outerIt->second, "controls"); + } + else + { + LL_ERRS("Tokens-Controls") << "No controls map to process!" << LL_ENDL; + } + } else if(outerIt->first == "misc") { if (outerIt->second.isMap()) @@ -364,7 +375,7 @@ void LLKeywords::processTokens() } else if(outerIt->first == "types") { - if (outerIt->second.isArray()) + if (outerIt->second.isMap()) { processTokensGroup(outerIt->second, "types"); } @@ -392,50 +403,51 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { token_type = LLKeywordToken::TT_CONSTANT; } - else if (Group == "events") + else if (Group == "controls") { - token_type = LLKeywordToken::TT_EVENT; + token_type = LLKeywordToken::TT_CONTROL; } - else if (Group == "misc-flow-control") + else if (Group == "events") { - token_type = LLKeywordToken::TT_FLOW; + token_type = LLKeywordToken::TT_EVENT; } else if (Group == "functions") { token_type = LLKeywordToken::TT_FUNCTION; } - else if (Group == "misc-flow-label") + else if (Group == "label") { token_type = LLKeywordToken::TT_LABEL; } - else if (Group == "misc-sections") - { - token_type = LLKeywordToken::TT_SECTION; - } else if (Group == "types") { token_type = LLKeywordToken::TT_TYPE; } - if (Tokens.isMap()) // constants, events, functions, and misc + if (Tokens.isMap()) { LLSD::map_iterator outerIt = Tokens.beginMap(); for ( ; outerIt != Tokens.endMap(); ++outerIt) { + Color = getColorGroup(Group); if (outerIt->second.isMap()) { mAttributes.clear(); + bool deprecated = false; LLSD arguments = LLSD (); LLSD::map_iterator innerIt = outerIt->second.beginMap(); for ( ; innerIt != outerIt->second.endMap(); ++innerIt) { - if (innerIt->first != "arguments") - { - mAttributes[innerIt->first] = innerIt->second.asString(); + if (innerIt->first == "arguments") + { + if (innerIt->second.isMap()) + { + arguments = innerIt->second; + } } - else if (innerIt->second.isArray()) + else { - arguments = innerIt->second; + mAttributes[innerIt->first] = innerIt->second.asString(); } } @@ -449,10 +461,6 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { tooltip = outerIt->first + "(" + getArguments(arguments) + ")"; } - else if (token_type == LLKeywordToken::TT_FLOW) - { - tooltip = "flow baby"; - } else if (token_type == LLKeywordToken::TT_FUNCTION) { tooltip = getAttribute("return") + " " + outerIt->first + "(" + getArguments(arguments) + ");"; @@ -463,25 +471,26 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) tooltip += ", Sleep: " + getAttribute("sleep"); } } - else if (token_type == LLKeywordToken::TT_SECTION) - { - tooltip = "section"; - } - if (getAttribute("summry") != "") + if (getAttribute("tooltip") != "") { - tooltip += "\n" + getAttribute("summary"); + if (tooltip != "") + { + tooltip += "\n"; + } + tooltip += getAttribute("tooltip"); } - else if (getAttribute("description") != "") + + deprecated = getAttribute("deprecated") == "true" ? true : false; + if (deprecated) { - tooltip += "\n" + getAttribute("description"); + Color = getColorGroup("deprecated"); } - addToken(token_type, outerIt->first, Color, tooltip); } } } - else if (Tokens.isArray()) // types + else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness { for (int count = 0; count < Tokens.size(); ++count) { -- cgit v1.2.3 From 9db5ed51f00f98f2567882d525d9d547cac3ed62 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 14 Feb 2013 16:54:24 +0000 Subject: STORM-1831 Refactoring serial if's to be prettier ;-) + Minor edit to comment tootips --- indra/llui/llkeywords.cpp | 63 ++++++----------------------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 0481948a09..d738d5127f 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -306,37 +306,14 @@ void LLKeywords::processTokens() // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD std::string delimiter; addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("label"), "Label\nTarget for jump statement", delimiter ); - addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment\nNon-functional commentary or disabled code", delimiter ); - addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment\nNon-functional commentary or disabled code (multi-line)", "*/" ); + addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment (single-line)\nNon-functional commentary or disabled code", delimiter ); + addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" ); addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); LLSD::map_iterator outerIt = mSyntax.beginMap(); for ( ; outerIt != mSyntax.endMap(); ++outerIt) { - // TODO Collapse the 'if's into two, those that call 'processTokens' directly and an else if (for 'misc') that doesn't - if (outerIt->first == "constants") - { - if (outerIt->second.isMap()) - { - processTokensGroup(outerIt->second, "constants"); - } - else - { - LL_ERRS("Tokens-Constants") << "No constants map to process!" << LL_ENDL; - } - } - else if (outerIt->first == "controls") - { - if (outerIt->second.isMap()) - { - processTokensGroup(outerIt->second, "controls"); - } - else - { - LL_ERRS("Tokens-Controls") << "No controls map to process!" << LL_ENDL; - } - } - else if(outerIt->first == "misc") + if (outerIt->first == "misc") { if (outerIt->second.isMap()) { @@ -348,46 +325,20 @@ void LLKeywords::processTokens() } else { - LL_ERRS("Tokens-Misc") << "No misc map to process!" << LL_ENDL; - } - } - else if(outerIt->first == "events") - { - if (outerIt->second.isMap()) - { - processTokensGroup(outerIt->second, "events"); - } - else - { - LL_ERRS("Tokens-Events") << "No event map to process!" << LL_ENDL; - } - } - else if(outerIt->first == "functions") - { - if (outerIt->second.isMap()) - { - processTokensGroup(outerIt->second, "functions"); - } - else - { - LL_ERRS("Tokens-Functions") << "No function map to process!" << LL_ENDL; + LL_ERRS("LSL-Tokens-Processing") << "Map for misc entries is missing! Ignoring." << LL_ENDL; } } - else if(outerIt->first == "types") + else { if (outerIt->second.isMap()) { - processTokensGroup(outerIt->second, "types"); + processTokensGroup(outerIt->second, outerIt->first); } else { - LL_ERRS("Tokens-Types") << "No types array to process!" << LL_ENDL; + LL_ERRS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; } } - else - { - LL_ERRS("Tokens") << "Unknown token group '" << outerIt->first << "'" << LL_ENDL; - } } LL_INFOS("") << LL_ENDL; } -- cgit v1.2.3 From 14b00fc6bfc298b423e03e2efe6ca811798043ee Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 14 Feb 2013 18:34:13 +0000 Subject: STORM-1831 Removing an unnecessary assignment. --- indra/llui/llkeywords.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index d738d5127f..5305826c8a 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -145,8 +145,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) LLSD::map_iterator argsIt = arguments.beginMap(); for ( ; argsIt != arguments.endMap(); ++argsIt) { - LLSD arg = argsIt->second; - args += arg.get("type").asString() + " " + argsIt->first; + args += argsIt->second.get("type").asString() + " " + argsIt->first; if (count-- > 1) { args += ", "; -- cgit v1.2.3 From 7d5ed4f7477c2c564f0e9dededf7131ed42d55b8 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 27 Jun 2013 21:28:52 +0100 Subject: Moving LSL highlighting colour info into .../skins/default/colors.xml where it makes more sense than its own xml file. Changing other functions to read it. --- indra/llui/llkeywords.cpp | 90 +++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 43 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index b7eb4c63bc..521134f26c 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -71,7 +71,6 @@ inline BOOL LLKeywordToken::isTail(const llwchar* s) const LLKeywords::LLKeywords() : mLoaded(FALSE) { - setFilenameColors( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_colors.xml") ); setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_tokens.xml") ); } @@ -84,7 +83,7 @@ LLKeywords::~LLKeywords() -void LLKeywords::addColorGroup(const std::string key_in, const LLColor3 color) +void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) { WStringMapIndex key ( utf8str_to_wstring(key_in) ); mColorGroupMap[key] = color; @@ -93,7 +92,7 @@ void LLKeywords::addColorGroup(const std::string key_in, const LLColor3 color) // Add the token as described void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, const std::string& key_in, - const LLColor3& color, + const LLColor4& color, const std::string& tool_tip_in, const std::string& delimiter_in) { @@ -165,33 +164,47 @@ std::string LLKeywords::getAttribute(const std::string& key) return (it != mAttributes.end()) ? it->second : ""; } -LLColor3 LLKeywords::getColorGroup(const std::string key_in) +LLColor4 LLKeywords::getColorGroup(const std::string key_in) { - // LLColor3 initialises to Black (0,0,0) - LLColor3 Colour; - WStringMapIndex key ( utf8str_to_wstring(key_in) ); - group_color_map_t::iterator it = mColorGroupMap.find(key); - if (it == mColorGroupMap.end()) - { - LL_WARNS("Colour lookup") << "'" << key_in << "' not found!" << LL_ENDL; - } - else - { - Colour = it->second; - } - - return Colour; + std::string ColourGroup = "Black"; + if (key_in == "constants-float") { + ColourGroup = "SyntaxLslConstantFloat"; + } else if (key_in == "constants-integer") { + ColourGroup = "SyntaxLslConstantInteger"; + } else if (key_in == "constants-key") { + ColourGroup = "SyntaxLslConstantKey"; + } else if (key_in == "constants-string") { + ColourGroup = "SyntaxLslConstantRotation"; + } else if (key_in == "constants-string") { + ColourGroup = "SyntaxLslConstantString"; + } else if (key_in == "constants-vector") { + ColourGroup = "SyntaxLslConstantVector"; + } else if (key_in == "controls") { + ColourGroup = "SyntaxLslControlFlow"; + } else if (key_in == "events") { + ColourGroup = "SyntaxLslEvent"; + } else if (key_in == "functions") { + ColourGroup = "SyntaxLslFunction"; + } else if (key_in == "types") { + ColourGroup = "SyntaxLslDataType"; + } else if (key_in == "sections") { + ColourGroup = "SyntaxLslSection"; + } else if (key_in == "misc-double_quotation_marks") { + ColourGroup = "SyntaxLslStringLiteral"; + } else if (key_in == "misc-comments_1_sided") { + ColourGroup = "SyntaxLslComment1Sided"; + } else if (key_in == "misc-comments_2_sided") { + ColourGroup = "SyntaxLslComment2Sided"; + } + + return LLUIColorTable::instance().getColor(ColourGroup); } BOOL LLKeywords::initialise() { mReady = false; - if (! loadIntoLLSD(mFilenameColors, mColors) ) - { - LL_ERRS("") << "Failed to load color data, cannot continue!" << LL_ENDL; - } - else if (! loadIntoLLSD(mFilenameSyntax, mSyntax) ) + if (! loadIntoLLSD(mFilenameSyntax, mSyntax) ) { LL_ERRS("") << "Failed to load syntax data from '" << mFilenameSyntax << "', cannot continue!" << LL_ENDL; } @@ -199,16 +212,6 @@ BOOL LLKeywords::initialise() { mReady = true; } - - if (ready()) - { - processColors(); - } - else - { - LL_ERRS("") << LL_ENDL; - LL_ERRS("") << "Failed to load one or both data files, cannot continue!" << LL_ENDL; - } return mReady; } @@ -251,7 +254,7 @@ BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) /** * @brief Start processing the colour LLSD from its beginning. * - */ + * / std::string LLKeywords::processColors() { return processColors(mColors, ""); @@ -261,7 +264,7 @@ std::string LLKeywords::processColors() * @brief Recursively process the colour LLSD from an arbitrary level. * @desc Process the supplied LLSD for colour data. The strPrefix is a string * of hyphen separated keys from previous levels. - */ + * / std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefix) { if (settings.isMap() || (! settings.isMap() && strPrefix != "") ) @@ -299,12 +302,13 @@ std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefi } return strPrefix; } +*/ void LLKeywords::processTokens() { // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD std::string delimiter; - addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("label"), "Label\nTarget for jump statement", delimiter ); + addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("misc-flow-label"), "Label\nTarget for jump statement", delimiter ); addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment (single-line)\nNon-functional commentary or disabled code", delimiter ); addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" ); addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); @@ -344,7 +348,7 @@ void LLKeywords::processTokens() void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { - LLColor3 Color = getColorGroup(Group); + LLColor4 Color; LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; @@ -534,7 +538,7 @@ bool LLKeywords::WStringMapIndex::operator<(const LLKeywords::WStringMapIndex &o return result; } -LLColor3 LLKeywords::readColor( const std::string& s ) +LLColor4 LLKeywords::readColor( const std::string& s ) { F32 r, g, b; r = g = b = 0.0f; @@ -543,22 +547,22 @@ LLColor3 LLKeywords::readColor( const std::string& s ) { llinfos << " poorly formed color in keyword file" << llendl; } - return LLColor3( r, g, b ); + return LLColor4( r, g, b, 1.f); } -LLColor3 LLKeywords::readColor(LLSD& sd) +LLColor4 LLKeywords::readColor(LLSD& sd) { if (sd.isArray()) { - return LLColor3 (sd); + return LLColor4 (sd, 1.f); } else if (sd.isMap()) { - return LLColor3 ( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal() ); + return LLColor4 ( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f ); } else { - return LLColor3::black; + return LLColor4::black; } } -- cgit v1.2.3 From 02097397e06a6cf45c639823c7f633dffe3684e8 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 28 Jun 2013 18:29:59 +0100 Subject: Changing the way I commented out functions for later removal. TC doesn't like how I did it before :-( --- indra/llui/llkeywords.cpp | 104 +++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 521134f26c..315cf45f43 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -251,58 +251,58 @@ BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) return mLoaded; } -/** - * @brief Start processing the colour LLSD from its beginning. - * - * / -std::string LLKeywords::processColors() -{ - return processColors(mColors, ""); -} - -/** - * @brief Recursively process the colour LLSD from an arbitrary level. - * @desc Process the supplied LLSD for colour data. The strPrefix is a string - * of hyphen separated keys from previous levels. - * / -std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefix) -{ - if (settings.isMap() || (! settings.isMap() && strPrefix != "") ) - { - LLSD llsd_map = settings; - - LLSD::map_iterator my_iter = llsd_map.beginMap(); - for ( ; my_iter != llsd_map.endMap(); ++my_iter) - { - std::string strGroup = strPrefix; - const LLSD::String& key = my_iter->first; - LLSD& value = my_iter->second; - - if (key == "color") - { - if (value.isMap() || value.isArray()) - { - addColorGroup(strGroup, readColor(value)); - } - else - { - LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; - } - } - else if (value.isMap()) - { - strGroup += (strGroup.length() == 0) ? my_iter->first : "-" + my_iter->first; - strGroup = processColors(value, strGroup); - } - else - { - LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; - } - } - } - return strPrefix; -} -*/ +///** +// * @brief Start processing the colour LLSD from its beginning. +// * +// */ +//std::string LLKeywords::processColors() +//{ +// return processColors(mColors, ""); +//} + +///** +// * @brief Recursively process the colour LLSD from an arbitrary level. +// * @desc Process the supplied LLSD for colour data. The strPrefix is a string +// * of hyphen separated keys from previous levels. +// */ +//std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefix) +//{ +// if (settings.isMap() || (! settings.isMap() && strPrefix != "") ) +// { +// LLSD llsd_map = settings; + +// LLSD::map_iterator my_iter = llsd_map.beginMap(); +// for ( ; my_iter != llsd_map.endMap(); ++my_iter) +// { +// std::string strGroup = strPrefix; +// const LLSD::String& key = my_iter->first; +// LLSD& value = my_iter->second; +// +// if (key == "color") +// { +// if (value.isMap() || value.isArray()) +// { +// addColorGroup(strGroup, readColor(value)); +// } +// else +// { +// LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; +// } +// } +// else if (value.isMap()) +// { +// strGroup += (strGroup.length() == 0) ? my_iter->first : "-" + my_iter->first; +// strGroup = processColors(value, strGroup); +// } +// else +// { +// LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; +// } +// } +// } +// return strPrefix; +//} +//*/ void LLKeywords::processTokens() { -- cgit v1.2.3 From bccbcced5426d95353f07ec2e8bb12c0b1ec03bf Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 15 Oct 2013 21:56:20 +0100 Subject: Renaming file to better reflect it's actual usage for the future. --- indra/llui/llkeywords.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 93e8c084e9..33a8cc947d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -35,7 +35,6 @@ #include "lltexteditor.h" #include "llstl.h" - inline BOOL LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare @@ -71,7 +70,7 @@ inline BOOL LLKeywordToken::isTail(const llwchar* s) const LLKeywords::LLKeywords() : mLoaded(FALSE) { - setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_tokens.xml") ); + setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_default.xml") ); } LLKeywords::~LLKeywords() -- cgit v1.2.3 From 79645e6981a97224024c5226d8713dce9569d54a Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 21 Oct 2013 04:09:20 +0100 Subject: STORM-1831 First attempt at using SyntaxIdLSL capability. (incomplete) --- indra/llui/llkeywords.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 33a8cc947d..687c2fb31d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -29,7 +29,6 @@ #include #include -#include "lldir.h" #include "llkeywords.h" #include "llsdserialize.h" #include "lltexteditor.h" @@ -70,7 +69,7 @@ inline BOOL LLKeywordToken::isTail(const llwchar* s) const LLKeywords::LLKeywords() : mLoaded(FALSE) { - setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_default.xml") ); + //setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_default.xml") ); } LLKeywords::~LLKeywords() @@ -199,9 +198,10 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -BOOL LLKeywords::initialise() +BOOL LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; + setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); if (! loadIntoLLSD(mFilenameSyntax, mSyntax) ) { -- cgit v1.2.3 From 4af21580297dd85727ffdc5d4eee89ad58ead271 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:31:32 +0000 Subject: Adding method to load cached/default syntax file and method to access sKeyWordsXML. --- indra/llui/llkeywords.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 687c2fb31d..832264f074 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline BOOL LLKeywordToken::isHead(const llwchar* s) const +inline bool LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline BOOL LLKeywordToken::isHead(const llwchar* s) const return res; } -inline BOOL LLKeywordToken::isTail(const llwchar* s) const +inline bool LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -BOOL LLKeywords::initialise(ELLPath path, const std::string filename) +bool LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ BOOL LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -BOOL LLKeywords::loadFromFile() +bool LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ BOOL LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); + mLoaded = (bool)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; -- cgit v1.2.3 From 29b2129e1eec0dbbb909422e82766a58f14c5da3 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:32:08 +0000 Subject: Backed out changeset: e82d9467bec8 --- indra/llui/llkeywords.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 832264f074..687c2fb31d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline bool LLKeywordToken::isHead(const llwchar* s) const +inline BOOL LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline bool LLKeywordToken::isHead(const llwchar* s) const return res; } -inline bool LLKeywordToken::isTail(const llwchar* s) const +inline BOOL LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -bool LLKeywords::initialise(ELLPath path, const std::string filename) +BOOL LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ bool LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -bool LLKeywords::loadFromFile() +BOOL LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ bool LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (bool)LLSDSerialize::fromXML(data, file); + mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; -- cgit v1.2.3 From 5e27952ee4698006c86ebdca60c4eab305ddebac Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 20:24:13 +0000 Subject: storm-1831 Switch to use the llsyntaxid keywords LLSD directly --- indra/llui/llkeywords.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 687c2fb31d..ac95a20588 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -198,19 +198,10 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -BOOL LLKeywords::initialise(ELLPath path, const std::string filename) +bool LLKeywords::initialise(LLSD SyntaxXML) { - mReady = false; - setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); - - if (! loadIntoLLSD(mFilenameSyntax, mSyntax) ) - { - LL_ERRS("") << "Failed to load syntax data from '" << mFilenameSyntax << "', cannot continue!" << LL_ENDL; - } - else - { - mReady = true; - } + mSyntax = SyntaxXML; + mLoaded = mReady = true; return mReady; } -- cgit v1.2.3 From dc317ed70ac8b8344a745b4f43116460efdfdbca Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 21:58:17 +0000 Subject: Refactoring load routines to remove uneeded methods --- indra/llui/llkeywords.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index ac95a20588..65ede3e46f 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -205,42 +205,6 @@ bool LLKeywords::initialise(LLSD SyntaxXML) return mReady; } -BOOL LLKeywords::loadFromFile() -{ - processTokens(); - return true; -} - -/** - * @brief Load xml serialised LLSD - * @desc Opens the specified filespec and attempts to deserialise the - * contained data to the specified LLSD object. - * @return Returns boolean true/false indicating success or failure. - */ -BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) -{ - mLoaded = false; - llifstream file; - file.open(filename); - if(file.is_open()) - { - mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); - if (!mLoaded) - { - LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; - } - else - { - LL_INFOS("") << "Deserialised file: " << filename << LL_ENDL; - } - } - else - { - LL_WARNS("") << "Unable to open file: " << filename << LL_ENDL; - } - return mLoaded; -} - ///** // * @brief Start processing the colour LLSD from its beginning. // * -- cgit v1.2.3 From 3e41917403fb3519adac2343ca21a1f289596621 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Nov 2013 16:33:04 +0000 Subject: Removing no longer used member variable, adding method to reset the mLoaded status --- indra/llui/llkeywords.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 65ede3e46f..6aeaf4798b 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -201,8 +201,8 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) bool LLKeywords::initialise(LLSD SyntaxXML) { mSyntax = SyntaxXML; - mLoaded = mReady = true; - return mReady; + mLoaded = true; + return mLoaded; } ///** -- cgit v1.2.3 From fa5c3320cc9c50462b222b1b1197d9c16064983e Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 21 Nov 2013 19:55:38 +0000 Subject: storm-1831 Cleaning up colour LLSD processing code which is no longer used as colours come from the colors XML file. --- indra/llui/llkeywords.cpp | 58 +---------------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 6aeaf4798b..5f5810812e 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -67,10 +67,7 @@ inline BOOL LLKeywordToken::isTail(const llwchar* s) const return res; } -LLKeywords::LLKeywords() : mLoaded(FALSE) -{ - //setFilenameSyntax( gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords_lsl_default.xml") ); -} +LLKeywords::LLKeywords() : mLoaded(FALSE) { } LLKeywords::~LLKeywords() { @@ -205,59 +202,6 @@ bool LLKeywords::initialise(LLSD SyntaxXML) return mLoaded; } -///** -// * @brief Start processing the colour LLSD from its beginning. -// * -// */ -//std::string LLKeywords::processColors() -//{ -// return processColors(mColors, ""); -//} - -///** -// * @brief Recursively process the colour LLSD from an arbitrary level. -// * @desc Process the supplied LLSD for colour data. The strPrefix is a string -// * of hyphen separated keys from previous levels. -// */ -//std::string LLKeywords::processColors(LLSD &settings, const std::string strPrefix) -//{ -// if (settings.isMap() || (! settings.isMap() && strPrefix != "") ) -// { -// LLSD llsd_map = settings; - -// LLSD::map_iterator my_iter = llsd_map.beginMap(); -// for ( ; my_iter != llsd_map.endMap(); ++my_iter) -// { -// std::string strGroup = strPrefix; -// const LLSD::String& key = my_iter->first; -// LLSD& value = my_iter->second; -// -// if (key == "color") -// { -// if (value.isMap() || value.isArray()) -// { -// addColorGroup(strGroup, readColor(value)); -// } -// else -// { -// LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; -// } -// } -// else if (value.isMap()) -// { -// strGroup += (strGroup.length() == 0) ? my_iter->first : "-" + my_iter->first; -// strGroup = processColors(value, strGroup); -// } -// else -// { -// LL_WARNS("Invalid Color") << "Invalid Color Entry - first: '" << key << "' second: '" << value << "'" << LL_ENDL; -// } -// } -// } -// return strPrefix; -//} -//*/ - void LLKeywords::processTokens() { // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD -- cgit v1.2.3 From f6d86fcacf79c8147e2075db64caee7521f3b227 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 17 Dec 2013 18:23:09 +0000 Subject: Fixing some BOOL to bool and changing one function to void --- indra/llui/llkeywords.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 5f5810812e..393681be27 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,10 +34,10 @@ #include "lltexteditor.h" #include "llstl.h" -inline BOOL LLKeywordToken::isHead(const llwchar* s) const +inline bool LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare - BOOL res = TRUE; + bool res = TRUE; const llwchar* t = mToken.c_str(); S32 len = mToken.size(); for (S32 i=0; i Date: Sat, 4 Jan 2014 01:19:51 +0000 Subject: STORM-1831/STORM-2000 Changing LSL syntax schema to contain arguments in an array instead of a map element. --- indra/llui/llkeywords.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 393681be27..b7de4d5224 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -132,25 +132,40 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, std::string LLKeywords::getArguments(LLSD& arguments) { - std::string args = ""; - if (arguments.isMap()) + std::string argString = ""; + + if (arguments.isArray()) { - int count = arguments.size(); - LLSD::map_iterator argsIt = arguments.beginMap(); - for ( ; argsIt != arguments.endMap(); ++argsIt) + int argsCount = arguments.size(); + LLSD::array_iterator arrayIt = arguments.beginArray(); + for ( ; arrayIt != arguments.endArray(); ++arrayIt) { - args += argsIt->second.get("type").asString() + " " + argsIt->first; - if (count-- > 1) + LLSD& args = (*arrayIt); + if (args.isMap()) + { + LLSD::map_iterator argsIt = args.beginMap(); + for ( ; argsIt != args.endMap(); ++argsIt) { - args += ", "; + argString += argsIt->second.get("type").asString() + " " + argsIt->first; + if (argsCount-- > 1) + { + argString += ", "; + } } + } + else + { + LL_INFOS("SyntaxLSL") + << "Argument array does not comtain a map element!" << LL_ENDL; + } } } else if (!arguments.isUndefined()) { - LL_WARNS("Arguments") << "Not a map! Invalid LLSD passed to function.\n" << arguments << LL_ENDL; + LL_WARNS("SyntaxLSL") + << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } - return args == "" ? " void " : args; + return argString == "" ? " void " : argString; } std::string LLKeywords::getAttribute(const std::string& key) @@ -246,7 +261,6 @@ void LLKeywords::processTokens() void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { LLColor4 Color; - LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method @@ -275,12 +289,14 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) token_type = LLKeywordToken::TT_TYPE; } + Color = getColorGroup(Group); + LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; + if (Tokens.isMap()) { LLSD::map_iterator outerIt = Tokens.beginMap(); for ( ; outerIt != Tokens.endMap(); ++outerIt) { - Color = getColorGroup(Group); if (outerIt->second.isMap()) { mAttributes.clear(); @@ -291,7 +307,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { if (innerIt->first == "arguments") { - if (innerIt->second.isMap()) + if (innerIt->second.isArray()) { arguments = innerIt->second; } @@ -343,6 +359,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness { + LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here" << LL_ENDL; for (int count = 0; count < Tokens.size(); ++count) { addToken(token_type, Tokens[count], Color, ""); -- cgit v1.2.3 From 025e0b07ab716f2ab07f6a43bf19450fe08115c5 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 11 Jan 2014 03:19:34 +0000 Subject: Correcting int to U32 --- indra/llui/llkeywords.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index b7de4d5224..050573e699 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -136,7 +136,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) if (arguments.isArray()) { - int argsCount = arguments.size(); + U32 argsCount = arguments.size(); LLSD::array_iterator arrayIt = arguments.beginArray(); for ( ; arrayIt != arguments.endArray(); ++arrayIt) { -- cgit v1.2.3 From bc1cecd75435f29d360bc305ed3f20bc2d2dda7e Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 14 Jan 2014 00:22:41 +0000 Subject: Removing the value "void" from return types and empty argument lists. --- indra/llui/llkeywords.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 050573e699..9dd14f4a2f 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -165,7 +165,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } - return argString == "" ? " void " : argString; + return argString == "" ? "" : argString; } std::string LLKeywords::getAttribute(const std::string& key) -- cgit v1.2.3 From 8df2007187236d1b77ccec916fc63f0481cf599c Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 14 Jan 2014 03:45:14 +0000 Subject: storm-1831 Enabling highlighting of deprecated and god-mode functions. --- indra/llui/llkeywords.cpp | 94 +++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 32 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 9dd14f4a2f..fe91c74fa0 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -177,33 +177,68 @@ std::string LLKeywords::getAttribute(const std::string& key) LLColor4 LLKeywords::getColorGroup(const std::string key_in) { std::string ColourGroup = "Black"; - if (key_in == "constants-float") { + if (key_in == "constants-float") + { ColourGroup = "SyntaxLslConstantFloat"; - } else if (key_in == "constants-integer") { + } + else if (key_in == "constants-integer") + { ColourGroup = "SyntaxLslConstantInteger"; - } else if (key_in == "constants-key") { + } + else if (key_in == "constants-key") + { ColourGroup = "SyntaxLslConstantKey"; - } else if (key_in == "constants-string") { + } + else if (key_in == "constants-string") + { ColourGroup = "SyntaxLslConstantRotation"; - } else if (key_in == "constants-string") { + } + else if (key_in == "constants-string") + { ColourGroup = "SyntaxLslConstantString"; - } else if (key_in == "constants-vector") { + } + else if (key_in == "constants-vector") + { ColourGroup = "SyntaxLslConstantVector"; - } else if (key_in == "controls") { + } + else if (key_in == "controls") + { ColourGroup = "SyntaxLslControlFlow"; - } else if (key_in == "events") { + } + else if (key_in =="deprecated") + { + ColourGroup = "SyntaxLslDeprecated"; + } + else if (key_in == "events") + { ColourGroup = "SyntaxLslEvent"; - } else if (key_in == "functions") { + } + else if (key_in == "functions") + { ColourGroup = "SyntaxLslFunction"; - } else if (key_in == "types") { + } + else if (key_in =="god-mode") + { + ColourGroup = "SyntaxLslGodMode"; + } + else if (key_in == "types") + { ColourGroup = "SyntaxLslDataType"; - } else if (key_in == "sections") { + } + else if (key_in == "sections") + { ColourGroup = "SyntaxLslSection"; - } else if (key_in == "misc-double_quotation_marks") { + } + else if (key_in == "misc-double_quotation_marks") + { ColourGroup = "SyntaxLslStringLiteral"; - } else if (key_in == "misc-comments_1_sided") { + } + else if (key_in == "misc-comments_1_sided") + { ColourGroup = "SyntaxLslComment1Sided"; - } else if (key_in == "misc-comments_2_sided") { + } + else if (key_in == "misc-comments_2_sided") + { ColourGroup = "SyntaxLslComment2Sided"; } @@ -228,20 +263,9 @@ void LLKeywords::processTokens() LLSD::map_iterator outerIt = mSyntax.beginMap(); for ( ; outerIt != mSyntax.endMap(); ++outerIt) { - if (outerIt->first == "misc") + if (outerIt->first == "llsd-lsl-syntax-version") { - if (outerIt->second.isMap()) - { - LLSD::map_iterator innerIt = outerIt->second.beginMap(); - for ( ; innerIt != outerIt->second.endMap(); ++innerIt) - { - processTokensGroup(innerIt->second, "misc-" + innerIt->first); - } - } - else - { - LL_ERRS("LSL-Tokens-Processing") << "Map for misc entries is missing! Ignoring." << LL_ENDL; - } + LL_INFOS("SyntaxLSL") << "Skipping over version key." << LL_ENDL; } else { @@ -255,12 +279,15 @@ void LLKeywords::processTokens() } } } - LL_INFOS("") << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { LLColor4 Color; + LLColor4 ColorGroup; + LLColor4 ColorDeprecated = getColorGroup("deprecated"); + LLColor4 ColorGM = getColorGroup("god-mode"); LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method @@ -289,7 +316,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) token_type = LLKeywordToken::TT_TYPE; } - Color = getColorGroup(Group); + ColorGroup = getColorGroup(Group); LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; if (Tokens.isMap()) @@ -299,6 +326,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { if (outerIt->second.isMap()) { + Color = ColorGroup; mAttributes.clear(); bool deprecated = false; LLSD arguments = LLSD (); @@ -348,11 +376,13 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) tooltip += getAttribute("tooltip"); } - deprecated = getAttribute("deprecated") == "true" ? true : false; - if (deprecated) + Color = getAttribute("deprecated") == "true" ? ColorDeprecated : ColorGroup; + + if (getAttribute("god-mode") == "true") { - Color = getColorGroup("deprecated"); + Color = ColorGM; } + addToken(token_type, outerIt->first, Color, tooltip); } } -- cgit v1.2.3 From 11beaee5667a35196a481e6e2543123c63843821 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 14 Jan 2014 18:27:15 +0000 Subject: Fixing LL_INFOS out put for group colour that previous commit broke. --- indra/llui/llkeywords.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index fe91c74fa0..0395334b6e 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -317,7 +317,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } ColorGroup = getColorGroup(Group); - LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; + LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << ColorGroup << "'" << LL_ENDL; if (Tokens.isMap()) { -- cgit v1.2.3 From 81170ed939ce88ec9996ed5ecf2ae34684d199ec Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Wed, 15 Jan 2014 21:33:09 +0000 Subject: Adding error output for attributes containing MAP or ARRAY elements. --- indra/llui/llkeywords.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 0395334b6e..34dff22729 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -340,10 +340,14 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) arguments = innerIt->second; } } - else + else if (!innerIt->second.isMap() && !innerIt->second.isArray()) { mAttributes[innerIt->first] = innerIt->second.asString(); } + else + { + LL_ERRS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; + } } std::string tooltip = ""; -- cgit v1.2.3 From 93022725ea11dcae531440a3cce85b933a404c46 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 30 Jan 2014 15:32:04 +0000 Subject: minor white-space fixes --- indra/llui/llkeywords.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 34dff22729..fd4ef33f59 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -76,8 +76,6 @@ LLKeywords::~LLKeywords() std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); } - - void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) { WStringMapIndex key ( utf8str_to_wstring(key_in) ); @@ -94,7 +92,7 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, std::string tip_text = tool_tip_in; LLStringUtil::replaceString(tip_text, "\\n", "\n" ); LLStringUtil::replaceString(tip_text, "\t", " " ); - if (tip_text =="") + if (tip_text == "") { tip_text = "[no info]"; } -- cgit v1.2.3 From 00a99d9097131c02c6486112b32e57f534bf61be Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Feb 2014 16:47:27 +0000 Subject: Adding clear methods to remove any highlighting. --- indra/llui/llkeywords.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index fd4ef33f59..c5e8f76a73 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -128,6 +128,16 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, } } +void LLKeywords::clear() +{ + clearLoaded(); + mSyntax = LLSD(); + + std::for_each(mWordTokenMap.begin(), mWordTokenMap.end(), DeletePairedPointer()); + std::for_each(mLineTokenList.begin(), mLineTokenList.end(), DeletePointer()); + std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); +} + std::string LLKeywords::getArguments(LLSD& arguments) { std::string argString = ""; @@ -326,7 +336,6 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { Color = ColorGroup; mAttributes.clear(); - bool deprecated = false; LLSD arguments = LLSD (); LLSD::map_iterator innerIt = outerIt->second.beginMap(); for ( ; innerIt != outerIt->second.endMap(); ++innerIt) -- cgit v1.2.3 From a2c084849f6c977c4c1c3151e0762c0137d34d0d Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Mar 2014 16:11:59 +0000 Subject: storm-1831: Fixing constants not getting highlighted. Fixing ratation constant treated as string. Adding logging of unrecognised token groups. --- indra/llui/llkeywords.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index c5e8f76a73..6a349f3916 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -197,7 +197,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) { ColourGroup = "SyntaxLslConstantKey"; } - else if (key_in == "constants-string") + else if (key_in == "constants-rotation") { ColourGroup = "SyntaxLslConstantRotation"; } @@ -249,6 +249,10 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) { ColourGroup = "SyntaxLslComment2Sided"; } + else + { + LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognised!" << LL_ENDL; + } return LLUIColorTable::instance().getColor(ColourGroup); } @@ -334,7 +338,6 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { if (outerIt->second.isMap()) { - Color = ColorGroup; mAttributes.clear(); LLSD arguments = LLSD (); LLSD::map_iterator innerIt = outerIt->second.beginMap(); @@ -360,7 +363,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) std::string tooltip = ""; if (token_type == LLKeywordToken::TT_CONSTANT) { - Color = getColorGroup(Group + "-" + getAttribute("type")); + ColorGroup = getColorGroup(Group + "-" + getAttribute("type")); tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); } else if (token_type == LLKeywordToken::TT_EVENT) -- cgit v1.2.3 From 06bdcef531c79db7f6901e2c5f5f63b2f75ad4e5 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 9 Mar 2014 04:55:46 +0000 Subject: storm-1831 Fixing identificaton of label for highlighting. --- indra/llui/llkeywords.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 6a349f3916..a251c2e4f5 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -209,7 +209,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) { ColourGroup = "SyntaxLslConstantVector"; } - else if (key_in == "controls") + else if (key_in == "misc-flow-label") { ColourGroup = "SyntaxLslControlFlow"; } -- cgit v1.2.3 From 3ee3d4a8f4b74a5f0b75fa54cb8e1cef0b1ef28e Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 14 Mar 2014 16:19:21 -0400 Subject: correct logging levels (ERR causes a crash), and a minor style fix --- indra/llui/llkeywords.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index a251c2e4f5..9b924c84a9 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -163,15 +163,14 @@ std::string LLKeywords::getArguments(LLSD& arguments) } else { - LL_INFOS("SyntaxLSL") - << "Argument array does not comtain a map element!" << LL_ENDL; + LL_WARNS("SyntaxLSL") + << "Argument array comtains a non-map element!" << LL_ENDL; } } } else if (!arguments.isUndefined()) { - LL_WARNS("SyntaxLSL") - << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } return argString == "" ? "" : argString; } @@ -251,7 +250,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) } else { - LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognised!" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized!" << LL_ENDL; } return LLUIColorTable::instance().getColor(ColourGroup); @@ -287,7 +286,7 @@ void LLKeywords::processTokens() } else { - LL_ERRS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; + LL_WARNS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; } } } @@ -356,7 +355,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else { - LL_ERRS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; } } @@ -403,7 +402,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness { - LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; for (int count = 0; count < Tokens.size(); ++count) { addToken(token_type, Tokens[count], Color, ""); @@ -411,7 +410,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else { - LL_INFOS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; + LL_WARNS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; } } -- cgit v1.2.3 From bc7a579ba285fa64876a2bc116685f0357fe25dc Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 14 Mar 2014 16:33:47 -0400 Subject: STORM-1831 initialize LLKeywords::mLoaded in constructor (fixes black-on-black text in various places) --- indra/llui/llkeywords.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 9b924c84a9..b4932489b5 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -67,7 +67,10 @@ inline bool LLKeywordToken::isTail(const llwchar* s) const return res; } -LLKeywords::LLKeywords() { } +LLKeywords::LLKeywords() : + mLoaded(false) +{ +} LLKeywords::~LLKeywords() { -- cgit v1.2.3 From bd4f4ee7932797008ed15f8c0301f5a0e5911a64 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 19 Mar 2014 14:17:13 -0400 Subject: logging cleanup in support of debugging text editor problems --- indra/llui/llkeywords.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 82b50f43ab..a3e033d894 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -169,8 +169,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) } else { - LL_WARNS("SyntaxLSL") - << "Argument array comtains a non-map element!" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Argument array comtains a non-map element!" << LL_ENDL; } } } @@ -265,11 +264,16 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) void LLKeywords::initialise(LLSD SyntaxXML) { mSyntax = SyntaxXML; - mLoaded = TRUE; + mLoaded = true; } void LLKeywords::processTokens() { + if (!mLoaded) + { + return; + } + // Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD std::string delimiter; addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("misc-flow-label"), "Label\nTarget for jump statement", delimiter ); @@ -282,7 +286,7 @@ void LLKeywords::processTokens() { if (outerIt->first == "llsd-lsl-syntax-version") { - LL_INFOS("SyntaxLSL") << "Skipping over version key." << LL_ENDL; + // Skip over version key. } else { @@ -361,7 +365,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else { - LL_WARNS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not a valid attribute: " << innerIt->first << LL_ENDL; } } @@ -408,7 +412,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) } else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness { - LL_WARNS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; for (int count = 0; count < Tokens.size(); ++count) { addToken(token_type, Tokens[count], Color, ""); -- cgit v1.2.3 From 8bc42784122619e3f37afabbc5888821c3430369 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 28 Mar 2014 17:21:36 +0000 Subject: strom-1831: Cleaning out commented and unused code --- indra/llui/llkeywords.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 82b50f43ab..b495709ce0 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -134,16 +134,6 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, } } -void LLKeywords::clear() -{ - clearLoaded(); - mSyntax = LLSD(); - - std::for_each(mWordTokenMap.begin(), mWordTokenMap.end(), DeletePairedPointer()); - std::for_each(mLineTokenList.begin(), mLineTokenList.end(), DeletePointer()); - std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); -} - std::string LLKeywords::getArguments(LLSD& arguments) { std::string argString = ""; -- cgit v1.2.3 From 0039e80d7c625e466833b86df5767c723f698034 Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 16 Apr 2014 11:52:27 -0600 Subject: bool not U32 --- indra/llui/llkeywords.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 21129853de..e2ffd30f8d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -37,14 +37,14 @@ inline bool LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare - bool res = TRUE; + bool res = true; const llwchar* t = mToken.c_str(); S32 len = mToken.size(); for (S32 i=0; i Date: Fri, 18 Apr 2014 23:13:57 -0600 Subject: Move some more script editor functions from LLTextEditor to LLScriptEditor --- indra/llui/llkeywords.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui/llkeywords.cpp') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index e2ffd30f8d..07c84e57c0 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -89,7 +89,7 @@ void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) } // Add the token as described -void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, +void LLKeywords::addToken(LLKeywordToken::ETokenType type, const std::string& key_in, const LLColor4& color, const std::string& tool_tip_in, @@ -300,7 +300,7 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) LLColor4 ColorDeprecated = getColorGroup("deprecated"); LLColor4 ColorGM = getColorGroup("god-mode"); - LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; + LLKeywordToken::ETokenType token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method if (Group == "constants") { @@ -633,7 +633,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW seg_start = cur - base; cur += cur_delimiter->getLengthHead(); - LLKeywordToken::TOKEN_TYPE type = cur_delimiter->getType(); + LLKeywordToken::ETokenType type = cur_delimiter->getType(); if( type == LLKeywordToken::TT_TWO_SIDED_DELIMITER || type == LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS ) { while( *cur && !cur_delimiter->isTail(cur)) -- cgit v1.2.3