diff options
author | Cinder <cinder.roxley@phoenixviewer.com> | 2014-06-09 15:14:09 -0600 |
---|---|---|
committer | Cinder <cinder.roxley@phoenixviewer.com> | 2014-06-09 15:14:09 -0600 |
commit | 41f6c5ce4899b3ae57aefa564ee22ff84fa698ce (patch) | |
tree | 7f75bec5313e46a7afca5d264299163403865138 /indra/newview/llpreviewscript.cpp | |
parent | 58bf0dd580456f2df23c463f24791f6d580604b1 (diff) |
Greatly simplify LLSyntaxIdLSL:
* Move file fetched callback to the singleton and handle all syntax id changes within the singleton
* Remove a fair number of bool checks and method relying more on callbacks to drive syntax changes.
* Don't pretty print the cache file to conserve space and to speed up xml to llsd parsing
* Clean up includes
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 95 |
1 files changed, 30 insertions, 65 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 76cb1c1ebc..9ff0ece7d9 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -399,13 +399,9 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; - if (mRegionChangedCallback.connected()) + if (mSyntaxIDConnection.connected()) { - mRegionChangedCallback.disconnect(); - } - if (mFileFetchedCallback.connected()) - { - mFileFetchedCallback.disconnect(); + mSyntaxIDConnection.disconnect(); } } @@ -425,79 +421,48 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mFileFetchedCallback = LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + mSyntaxIDConnection = LLSyntaxIdLSL::getInstance()->addSyntaxIDCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL LLSyntaxIdLSL::getInstance()->initialize(); - - if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) - { - processLoaded(); - } - else - { - processKeywords(); - } - - if (mLive) - { - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::processLoaded, this)); - } + processKeywords(); return TRUE; } -void LLScriptEdCore::processLoaded() -{ - LLSyntaxIdLSL::getInstance()->initialize(); - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - processKeywords(); - } - else - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; - } -} - void LLScriptEdCore::processKeywords() { - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; - - mEditor->clearSegments(); - - mEditor->initKeywords(); - mEditor->loadKeywords(); - - string_vec_t primary_keywords; - string_vec_t secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - } - for (string_vec_t::const_iterator iter = primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + LL_DEBUGS("SyntaxLSL") << "Processing keywords" << LL_ENDL; + mEditor->clearSegments(); + mEditor->initKeywords(); + mEditor->loadKeywords(); + + string_vec_t primary_keywords; + string_vec_t secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) { - mFunctions->add(*iter); + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - for (string_vec_t::const_iterator iter = secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } } + for (string_vec_t::const_iterator iter = primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + for (string_vec_t::const_iterator iter = secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } void LLScriptEdCore::initMenu() |