From e8422e5bed6c593c8a26b533f33103911a1d3da6 Mon Sep 17 00:00:00 2001 From: Cinder Date: Tue, 6 May 2014 11:09:50 -0600 Subject: Let's get started: some code policy cleanup, reference arguments where we can, correct spelling --- .../newview/app_settings/keywords_lsl_default.xml | 20 +++--- indra/newview/llpreviewscript.cpp | 79 ++++++++++------------ indra/newview/llpreviewscript.h | 1 - indra/newview/llsyntaxid.cpp | 17 ++--- indra/newview/llsyntaxid.h | 8 +-- 5 files changed, 57 insertions(+), 68 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 83801a7e1e..53a89f0f09 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -89,7 +89,7 @@ vector tooltip - A vector is a data type that contains a set of three float values.\nVectors are used to represent colours (RGB), positions, and directions/velocities. + A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. constants @@ -852,7 +852,7 @@ value 0x2 tooltip - The object colour has changed. + The object color has changed. CHANGED_INVENTORY @@ -4372,7 +4372,7 @@ value 3 tooltip - A vector <r, g, b> which determines the ending colour of the object. + A vector <r, g, b> which determines the ending color of the object. PSYS_PART_END_GLOW @@ -4426,7 +4426,7 @@ value 0x1 tooltip - Interpolate both the colour and alpha from the start value to the end value. + Interpolate both the color and alpha from the start value to the end value. PSYS_PART_INTERP_SCALE_MASK @@ -4471,7 +4471,7 @@ value 1 tooltip - A vector <r.r, g.g, b.b> which determines the starting colour of the object. + A vector <r.r, g.g, b.b> which determines the starting color of the object. PSYS_PART_START_GLOW @@ -9032,7 +9032,7 @@ tooltip - Returns the color on Face.\nReturns the colour of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the colour returned is the mean average of each channel. + Returns the color on Face.\nReturns the color of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the color returned is the mean average of each channel. llGetCreator @@ -15304,7 +15304,7 @@ arguments - Colour + Color type vector @@ -15323,7 +15323,7 @@ tooltip - Sets the color, for the face.\nSets the colour of the side specified. If Face is ALL_SIDES, sets the colour on all faces. + Sets the color, for the face.\nSets the color of the side specified. If Face is ALL_SIDES, sets the color on all faces. llSetContentType @@ -15671,7 +15671,7 @@ - Colour + Color type vector @@ -15690,7 +15690,7 @@ tooltip - If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the colour of the linked child's side, specified by LinkNumber. + If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the color of the linked child's side, specified by LinkNumber. llSetLinkMedia diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 1d95276c51..fae4aeb7bc 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -374,6 +374,7 @@ LLScriptEdCore::LLScriptEdCore( setXMLFilename("panel_script_ed.xml"); llassert_always(mContainer != NULL); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); } LLScriptEdCore::~LLScriptEdCore() @@ -389,6 +390,7 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; + mRegionChangedCallback.disconnect(); } BOOL LLScriptEdCore::postBuild() @@ -407,25 +409,20 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - mSyntaxIdLSL.initialise(); + LLSyntaxIdLSL::getInstance()->initialise(); - if (mSyntaxIdLSL.isDifferentVersion()) + if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { processLoaded(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are the same, no need to update highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; } - - // Set up a callback for region changes - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); - return TRUE; } @@ -434,7 +431,6 @@ void LLScriptEdCore::updateKeywords() if (mLive) { mEditor->clearSegments(); - mRegionChangedCallback.disconnect(); } else { @@ -444,61 +440,54 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - mSyntaxIdLSL.initialise(); - if (mSyntaxIdLSL.isLoaded()) + LLSyntaxIdLSL::getInstance()->initialise(); + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; } } void LLScriptEdCore::processKeywords() { - if (mSyntaxIdLSL.isLoaded()) + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { - LL_INFOS("SyntaxLSL") - << "Hashes are different, updating highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; mEditor->clearSegments(); - if (mSyntaxIdLSL.isLoaded()) - { - mEditor->initKeywords(); - mEditor->loadKeywords(); - - std::vector primary_keywords; - std::vector 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()) ); - } - } + mEditor->initKeywords(); + mEditor->loadKeywords(); - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + 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 (std::vector::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); + } } } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 3ac48ae9c4..966c149d3d 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -156,7 +156,6 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; - LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 14265fd3af..3f726fa8b5 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -127,13 +127,13 @@ LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName) : - mFilePath(LL_PATH_APP_SETTINGS) +LLSyntaxIdLSL::LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability) +: mFilePath(LL_PATH_APP_SETTINGS) { - mCapabilityName = capabilityName; - mFileNameCurrent = filenameDefault; - mFileNameDefault = filenameDefault; - mSimulatorFeature = simFeatureName; + mCapabilityName = capability; + mFileNameCurrent = filename; + mFileNameDefault = filename; + mSimulatorFeature = sim_feature; mSyntaxIdCurrent = LLUUID(); } @@ -321,6 +321,9 @@ void LLSyntaxIdLSL::initialise() //----------------------------------------------------------------------------- // isSupportedVersion //----------------------------------------------------------------------------- +const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; +const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); + bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) { bool isValid = false; @@ -328,8 +331,6 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) * If the schema used to store LSL keywords and hints changes, this value is incremented * Note that it should _not_ be changed if the keywords and hints _content_ changes. */ - const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; - const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) { diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 1f7e893b38..75cfc45380 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -75,7 +75,7 @@ private: public: LLSyntaxIdLSL(); - LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName); + LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability); bool checkSyntaxIdChanged(); bool fetching(); @@ -104,9 +104,9 @@ protected: void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } - void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } - void setFileNameDefault(std::string& name) { mFileNameDefault = name; } - void setFileNameNew(std::string name) { mFileNameNew = name; } + void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } + void setFileNameDefault(const std::string& name) { mFileNameDefault = name; } + void setFileNameNew(const std::string name) { mFileNameNew = name; } }; -- cgit v1.3 From 8501d6494bceeea962d7251d882ddc244a8daa7f Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 7 May 2014 19:58:56 -0600 Subject: Code policy --- indra/llui/llkeywords.cpp | 2 +- indra/llui/llkeywords.h | 2 +- .../newview/app_settings/keywords_lsl_default.xml | 2 +- indra/newview/llpreviewscript.cpp | 4 +-- indra/newview/llpreviewscript.h | 2 +- indra/newview/llscripteditor.cpp | 2 +- indra/newview/llsyntaxid.cpp | 38 ++++++++-------------- indra/newview/llsyntaxid.h | 24 ++++---------- 8 files changed, 27 insertions(+), 49 deletions(-) (limited to 'indra/newview') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index bae604e270..346b9a83bd 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -251,7 +251,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string& key_in) return LLUIColorTable::instance().getColor(color_group); } -void LLKeywords::initialise(LLSD SyntaxXML) +void LLKeywords::initialize(LLSD SyntaxXML) { mSyntax = SyntaxXML; mLoaded = true; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index b17e9dd942..eecb327fee 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -115,7 +115,7 @@ public: bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - void initialise(LLSD SyntaxXML); + void initialize(LLSD SyntaxXML); void processTokens(); // Add the token as described diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 53a89f0f09..02823136ee 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -21,7 +21,7 @@ for tooltip - for loop\nfor (<initialiser>; <condition>; <post-iteration-statement>)\n{ ...\n} + for loop\nfor (<initializer>; <condition>; <post-iteration-statement>)\n{ ...\n} if diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index fae4aeb7bc..73dc19dd81 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -412,7 +412,7 @@ BOOL LLScriptEdCore::postBuild() LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { @@ -440,7 +440,7 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 966c149d3d..69a72325fc 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -77,7 +77,7 @@ protected: public: ~LLScriptEdCore(); - void initialiseKeywords(); + void initializeKeywords(); void initMenu(); void processKeywords(); void processLoaded(); diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 5d87f7ba0c..869368e72c 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -46,7 +46,7 @@ LLScriptEditor::LLScriptEditor(const Params& p) void LLScriptEditor::initKeywords() { - mKeywords.initialise(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); + mKeywords.initialize(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); } static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3f726fa8b5..3582ac024d 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -70,7 +70,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) << "Supported verson of syntax file." << LL_ENDL; LLSyntaxIdLSL::setKeywordsXml(content_ref); - LLSyntaxIdLSL::sInitialised = true; + LLSyntaxIdLSL::sInitialized = true; LLSyntaxIdLSL::sLoaded = true; LLSyntaxIdLSL::sLoadFailed = false; @@ -117,12 +117,12 @@ const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; -bool LLSyntaxIdLSL::sInitialised; +bool LLSyntaxIdLSL::sInitialized; LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; bool LLSyntaxIdLSL::sLoadFailed; bool LLSyntaxIdLSL::sVersionChanged; -LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; +LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor @@ -207,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() } else { - if ( mSyntaxIdCurrent.isNull() && isInitialised()) + if ( mSyntaxIdCurrent.isNull() && isInitialized()) { LL_INFOS("SyntaxLSL") << "It does not have LSLSyntaxId capability, remaining with default keywords file!" @@ -255,9 +255,9 @@ void LLSyntaxIdLSL::fetchKeywordsFile() //----------------------------------------------------------------------------- -// initialise +// initialize //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::initialise() +void LLSyntaxIdLSL::initialize() { mFileNameNew = mFileNameCurrent; mSyntaxIdNew = mSyntaxIdCurrent; @@ -309,7 +309,7 @@ void LLSyntaxIdLSL::initialise() loadDefaultKeywordsIntoLLSD(); } } - else if (!isInitialised()) + else if (!isInitialized()) { loadDefaultKeywordsIntoLLSD(); } @@ -355,8 +355,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; + LL_INFOS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); loadKeywordsIntoLLSD(); @@ -373,9 +372,7 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() */ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "Trying to open cached or default keyword file ;-)" - << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Trying to open cached or default keyword file" << LL_ENDL; // Is this the right thing to do, or should we leave the old content // even if it isn't entirely accurate anymore? @@ -389,9 +386,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() sLoaded = (bool)LLSDSerialize::fromXML(content, file); if (!sLoaded) { - LL_WARNS("SyntaxLSL") - << "Unable to deserialise file: " - << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; } else { @@ -399,15 +394,13 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { sKeywordsXml = content; sLoaded = true; - sInitialised = true; - LL_INFOS("SyntaxLSL") - << "Deserialised file: " << mFullFileSpec << LL_ENDL; + sInitialized = true; + LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } else { sLoaded = false; - LL_WARNS("SyntaxLSL") - << "Unknown or unsupported version of syntax file." << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } } @@ -422,8 +415,3 @@ boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fet { return sFileFetchedSignal.connect(cb); } - -void LLSyntaxIdLSL::removeFileFetchedCallback(boost::signals2::connection callback) -{ - sFileFetchedSignal.disconnect(callback); -} diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 75cfc45380..b68f3f4237 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -36,23 +36,18 @@ #include "llsingleton.h" #include "llviewerregion.h" - -/** - * @file llsyntaxid.h - * @brief Tracks the file needed to decorate the current sim's version of LSL. - */ -class LLSyntaxIdLSL: public LLSingleton +class LLSyntaxIdLSL : public LLSingleton { friend class fetchKeywordsFileResponder; public: typedef boost::signals2::signal file_fetched_signal_t; - static const std::string CAPABILITY_NAME; - static const std::string FILENAME_DEFAULT; - static const std::string SIMULATOR_FEATURE; + static const std::string CAPABILITY_NAME; + static const std::string FILENAME_DEFAULT; + static const std::string SIMULATOR_FEATURE; protected: - static bool sInitialised; + static bool sInitialized; static LLSD sKeywordsXml; static bool sLoaded; static bool sLoadFailed; @@ -85,16 +80,15 @@ public: LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } bool isDifferentVersion() const { return sVersionChanged; } - bool isInitialised() const { return sInitialised; } + bool isInitialized() const { return sInitialized; } - void initialise(); + void initialize(); bool isLoaded() { return sLoaded; } static bool isSupportedVersion(const LLSD& content); static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); - void removeFileFetchedCallback(boost::signals2::connection callback); protected: @@ -110,10 +104,6 @@ protected: }; -/** - * @file llsyntaxid.h - * @brief Handles responses for the LSLSyntax capability's get call. Is a friend of LLSyntaxIdLSL - */ class fetchKeywordsFileResponder : public LLHTTPClient::Responder { public: -- cgit v1.3