From ea02a6a80d52a030db71100856826eaff43ccce8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 6 Oct 2011 17:14:54 -0700 Subject: EXP-1301 : Init some members that were not initialized correctly --- indra/llui/lltoolbar.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c34fbcd4f5..1f5fa5f361 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -723,7 +723,10 @@ LLToolBarButton::LLToolBarButton(const Params& p) mId(""), mIsEnabledSignal(NULL), mIsRunningSignal(NULL), - mIsStartingSignal(NULL) + mIsStartingSignal(NULL), + mIsDragged(false), + mStartDragItemCallback(NULL), + mHandleDragItemCallback(NULL) { mButtonFlashRate = 0.0; mButtonFlashCount = 0; -- cgit v1.2.3 From 35d3fa12ba1b375a55c34680f9c8577ca3c4842c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Oct 2011 10:11:20 -0700 Subject: minor code cleanup --- indra/llui/llcommandmanager.cpp | 2 +- indra/llui/llfloater.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index b1147134c2..42aa9b333b 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -139,7 +139,7 @@ bool LLCommandManager::load() if (!commandsParams.validateBlock()) { - llerrs << "Unable to validate commands param block from file: " << commands_file << llendl; + llerrs << "Invalid commands file: " << commands_file << llendl; return false; } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index bc494e97f5..177344cde7 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -840,9 +840,9 @@ void LLFloater::applyRectControl() if (mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); - if (rect.getWidth() > 0 && rect.getHeight() > 0) + if (rect.notEmpty()) { - translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom); + setOrigin(rect.mLeft, rect.mBottom); if (mResizable) { reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); -- cgit v1.2.3 From fbe563fdf44c1843de29e189f05203fa4ab20d61 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Oct 2011 12:03:29 -0700 Subject: adjusted toolbar padding per spec --- indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml index 44da813f61..31a26dab7f 100644 --- a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml @@ -41,10 +41,10 @@ @@ -63,10 +63,10 @@ button_panel.bg_opaque_image="Rounded_Rect_Left" follows="right|top|bottom" name="toolbar_right" - height="500" width="30" left="0" - top="0" + top="10" + bottom="-10" side="right" button_display_mode="icons_only"> @@ -83,8 +83,8 @@ button_panel.bg_opaque_image="Rounded_Rect_Top" name="toolbar_bottom" height="30" - width="1024" - left="0" + left="40" + right="-40" top="0" side="bottom" follows="left|right|bottom" -- cgit v1.2.3 From ca2f043ffeb0b6f7c0a5ea171411c45f6dcc0bf4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Oct 2011 12:09:16 -0700 Subject: moved stand/stop flying buttons to above bottom toolbar --- indra/newview/skins/default/xui/en/main_view.xml | 9 --------- indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 14 +++++++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/indra/newview/skins/default/xui/en/main_view.xml b/indra/newview/skins/default/xui/en/main_view.xml index cf566d7d23..57baa7cdd3 100644 --- a/indra/newview/skins/default/xui/en/main_view.xml +++ b/indra/newview/skins/default/xui/en/main_view.xml @@ -90,15 +90,6 @@ top="0" visible="false" width="1024"/> - @@ -63,10 +63,10 @@ button_panel.bg_opaque_image="Rounded_Rect_Left" follows="right|top|bottom" name="toolbar_right" - height="500" + height="483" width="30" left="0" - top="0" + top="10" side="right" button_display_mode="icons_only"> @@ -83,8 +83,8 @@ button_panel.bg_opaque_image="Rounded_Rect_Top" name="toolbar_bottom" height="30" - width="1024" - left="0" + width="944" + left="40" top="0" side="bottom" follows="left|right|bottom" diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml index 613dc66762..d36b015005 100644 --- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml @@ -4,6 +4,7 @@ pad_top="1" pad_bottom="1" pad_between="1" + min_girth="24" mouse_opaque="false" read_only="false"> Date: Sun, 9 Oct 2011 15:52:45 -0700 Subject: EXP-1300 : drop tool animation. First shot. Works but still a bit hacky and with some bugs (tools can be duplicated at times). --- indra/llui/llcommandmanager.cpp | 2 +- indra/llui/llcommandmanager.h | 11 ++++-- indra/llui/lltoolbar.cpp | 83 +++++++++++++++++++++++++++++++++++------ indra/llui/lltoolbar.h | 4 +- indra/newview/lltoolbarview.cpp | 9 +++-- 5 files changed, 89 insertions(+), 20 deletions(-) diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 1b87f20d12..d8e035a320 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -41,7 +41,7 @@ // LLCommandId class // -const LLCommandId LLCommandId::null("null command"); +const LLCommandId LLCommandId::null = LLCommandId(); // // LLCommand class diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 8f9f956ec7..fdad7cd1b5 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -50,6 +50,12 @@ public: {} }; + LLCommandId() + : mName("null command") + { + mUUID = LLUUID::generateNewID(mName); + } + LLCommandId(const std::string& name) : mName(name) { @@ -62,10 +68,9 @@ public: mUUID = LLUUID::generateNewID(p.name); } - LLCommandId(const LLUUID& uuid) - : mName(""), + LLCommandId(const std::string& name, const LLUUID& uuid) + : mName(name), mUUID(uuid) - { } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5f7afb07fc..6332b2674a 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,6 +33,7 @@ #include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" +#include "llinventory.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! @@ -113,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; + mDraggedCommand = LLCommandId::null; + mRank = 0; } LLToolBar::~LLToolBar() @@ -203,17 +206,24 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); if (!command) return false; - + llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; + // Create the button and do the things that don't need ordering LLToolBarButton* button = createButton(commandId); mButtonPanel->addChild(button); - mButtonMap.insert(std::make_pair(commandId, button)); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); + // Insert the command and button in the right place in their respective lists if ((rank >= mButtonCommands.size()) || (rank < 0)) { // In that case, back load - mButtonCommands.push_back(commandId); + mButtonCommands.push_back(temp_command); mButtons.push_back(button); } else @@ -228,7 +238,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) rank--; } // ...then insert - mButtonCommands.insert(it_command,commandId); + mButtonCommands.insert(it_command,temp_command); mButtons.insert(it_button,button); } @@ -241,14 +251,20 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId) { if (!hasCommand(commandId)) return false; + llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; // First erase the map record - command_id_map::iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); mButtonMap.erase(it); // Now iterate on the commands and buttons to identify the relevant records std::list::iterator it_button = mButtons.begin(); command_id_list_t::iterator it_command = mButtonCommands.begin(); - while (*it_command != commandId) + while (*it_command != temp_command) { ++it_button; ++it_command; @@ -276,7 +292,12 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const { if (commandId != LLCommandId::null) { - command_id_map::const_iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid()); return (it != mButtonMap.end()); } @@ -289,7 +310,12 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) if (commandId != LLCommandId::null) { - command_id_map::iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); if (it != mButtonMap.end()) { it->second->setEnabled(enabled); @@ -507,7 +533,7 @@ void LLToolBar::updateLayoutAsNeeded() button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight()); } button->setShape(button_rect); - + buttons_in_row.push_back(button); row_running_length += button_length + mPadBetween; @@ -592,6 +618,12 @@ void LLToolBar::draw() } } } + // HACK!!! + if (!mDragAndDropTarget) + { + removeCommand(mDraggedCommand); + mDraggedCommand = LLCommandId::null; + } updateLayoutAsNeeded(); // rect may have shifted during layout @@ -622,7 +654,12 @@ void LLToolBar::createButtons() LLToolBarButton* button = createButton(command_id); mButtons.push_back(button); mButtonPanel->addChild(button); - mButtonMap.insert(std::make_pair(command_id, button)); + LLCommandId temp_command = command_id; + if (command_id.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); } mNeedsLayout = true; } @@ -713,7 +750,31 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, *accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO); // We'll use that flag to change the visual aspect of the toolbar target on draw() - mDragAndDropTarget = handled; + mDragAndDropTarget = false; + + // HACK!!! + if (!isReadOnly() && handled) + { + if (!drop) + { + LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; + LLAssetType::EType type = inv_item->getType(); + if (type == LLAssetType::AT_WIDGET) + { + mRank = getRankFromPosition(x, y); + mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID()); + removeCommand(mDraggedCommand); + addCommand(mDraggedCommand,mRank); + mDragAndDropTarget = true; + } + } + else + { + removeCommand(mDraggedCommand); + mDraggedCommand = LLCommandId::null; + } + + } return handled; } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index be0589f3c6..9e48dee608 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -184,6 +184,8 @@ protected: tool_handledrag_callback_t mHandleDragItemCallback; tool_handledrop_callback_t mHandleDropCallback; bool mDragAndDropTarget; + int mRank; + LLCommandId mDraggedCommand; public: // Methods used in loading and saving toolbar settings @@ -205,7 +207,7 @@ private: typedef std::list toolbar_button_list; toolbar_button_list mButtons; command_id_list_t mButtonCommands; - typedef std::map command_id_map; + typedef std::map command_id_map; command_id_map mButtonMap; LLToolBarEnums::ButtonType mButtonType; diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 8c7dc53af0..44b244f163 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -375,7 +375,7 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t //llinfos << "Merov debug : handleDropTool. Drop source is a widget -> drop it in place..." << llendl; // Get the command from its uuid LLCommandManager& mgr = LLCommandManager::instance(); - LLCommandId command_id(inv_item->getUUID()); + LLCommandId command_id("",inv_item->getUUID()); LLCommand* command = mgr.getCommand(command_id); if (command) { @@ -387,9 +387,10 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t } // Suppress the command from the toolbars (including the one it's dropped in, // this will handle move position). - gToolBarView->mToolbarLeft->removeCommand(command->id()); - gToolBarView->mToolbarRight->removeCommand(command->id()); - gToolBarView->mToolbarBottom->removeCommand(command->id()); + llinfos << "Merov debug : handleDropTool, " << command_id.name() << ", " << command_id.uuid() << llendl; + gToolBarView->mToolbarLeft->removeCommand(command_id); + gToolBarView->mToolbarRight->removeCommand(command_id); + gToolBarView->mToolbarBottom->removeCommand(command_id); // Now insert it in the toolbar at the detected rank if (!toolbar->isReadOnly()) { -- cgit v1.2.3 From e61569d71422931e0d1f8d7e2f6e4db13d8b03ba Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 14:08:14 -0700 Subject: added compound LLSD parsing to param blocks reviewed by Leslie --- indra/llui/llnotifications.cpp | 72 ++++------ indra/llui/llsdparam.cpp | 255 ++++++++++++++++++----------------- indra/llui/llsdparam.h | 66 ++++----- indra/llui/tests/llurlentry_stub.cpp | 2 +- indra/llui/tests/llurlentry_test.cpp | 1 - indra/llui/tests/llurlmatch_test.cpp | 4 +- indra/llxuixml/llinitparam.cpp | 52 ++++--- indra/llxuixml/llinitparam.h | 155 ++++++++++++--------- indra/llxuixml/llxuiparser.cpp | 50 ++++--- indra/llxuixml/llxuiparser.h | 36 +++-- indra/newview/llappviewer.cpp | 47 +++---- 11 files changed, 376 insertions(+), 364 deletions(-) diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index ffe5908a9d..8f7025a9a6 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -46,6 +46,7 @@ #include #include +#include const std::string NOTIFICATION_PERSIST_VERSION = "0.93"; @@ -416,23 +417,17 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundEffect = LLUUID(LLUI::sSettingGroups["config"]->getString(p.sound)); } - for(LLInitParam::ParamIterator::const_iterator it = p.unique.contexts.begin(), - end_it = p.unique.contexts.end(); - it != end_it; - ++it) + BOOST_FOREACH(const LLNotificationTemplate::UniquenessContext& context, p.unique.contexts) { - mUniqueContext.push_back(it->value); + mUniqueContext.push_back(context.value); } lldebugs << "notification \"" << mName << "\": tag count is " << p.tags.size() << llendl; - for(LLInitParam::ParamIterator::const_iterator it = p.tags.begin(), - end_it = p.tags.end(); - it != end_it; - ++it) + BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags) { - lldebugs << " tag \"" << std::string(it->value) << "\"" << llendl; - mTags.push_back(it->value); + lldebugs << " tag \"" << std::string(tag.value) << "\"" << llendl; + mTags.push_back(tag.value); } mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form)); @@ -1397,14 +1392,12 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter { form.ignore.text = replace; } - for (LLInitParam::ParamIterator::iterator it = form.form_elements.elements.begin(), - end_it = form.form_elements.elements.end(); - it != end_it; - ++it) + + BOOST_FOREACH(LLNotificationForm::FormElement& element, form.form_elements.elements) { - if (it->button.isChosen() && it->button.text() == pattern) + if (element.button.isChosen() && element.button.text() == pattern) { - it->button.text = replace; + element.button.text = replace; } } } @@ -1453,48 +1446,42 @@ bool LLNotifications::loadTemplates() mTemplates.clear(); - for(LLInitParam::ParamIterator::const_iterator it = params.strings.begin(), end_it = params.strings.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::GlobalString& string, params.strings) { - mGlobalStrings[it->name] = it->value; + mGlobalStrings[string.name] = string.value; } std::map form_templates; - for(LLInitParam::ParamIterator::const_iterator it = params.templates.begin(), end_it = params.templates.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::Template& notification_template, params.templates) { - form_templates[it->name] = it->form; + form_templates[notification_template.name] = notification_template.form; } - for(LLInitParam::ParamIterator::iterator it = params.notifications.begin(), end_it = params.notifications.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::Params& notification, params.notifications) { - if (it->form_ref.form_template.isChosen()) + if (notification.form_ref.form_template.isChosen()) { // replace form contents from template - it->form_ref.form = form_templates[it->form_ref.form_template.name]; - if(it->form_ref.form_template.yes_text.isProvided()) + notification.form_ref.form = form_templates[notification.form_ref.form_template.name]; + if(notification.form_ref.form_template.yes_text.isProvided()) { - replaceFormText(it->form_ref.form, "$yestext", it->form_ref.form_template.yes_text); + replaceFormText(notification.form_ref.form, "$yestext", notification.form_ref.form_template.yes_text); } - if(it->form_ref.form_template.no_text.isProvided()) + if(notification.form_ref.form_template.no_text.isProvided()) { - replaceFormText(it->form_ref.form, "$notext", it->form_ref.form_template.no_text); + replaceFormText(notification.form_ref.form, "$notext", notification.form_ref.form_template.no_text); } - if(it->form_ref.form_template.cancel_text.isProvided()) + if(notification.form_ref.form_template.cancel_text.isProvided()) { - replaceFormText(it->form_ref.form, "$canceltext", it->form_ref.form_template.cancel_text); + replaceFormText(notification.form_ref.form, "$canceltext", notification.form_ref.form_template.cancel_text); } - if(it->form_ref.form_template.ignore_text.isProvided()) + if(notification.form_ref.form_template.ignore_text.isProvided()) { - replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text); + replaceFormText(notification.form_ref.form, "$ignoretext", notification.form_ref.form_template.ignore_text); } } - mTemplates[it->name] = LLNotificationTemplatePtr(new LLNotificationTemplate(*it)); + mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification)); } return true; @@ -1517,12 +1504,9 @@ bool LLNotifications::loadVisibilityRules() mVisibilityRules.clear(); - for(LLInitParam::ParamIterator::iterator it = params.rules.begin(), - end_it = params.rules.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules) { - mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(*it))); + mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule))); } return true; diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 4b69360e33..83bed3e745 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -34,6 +34,7 @@ static LLInitParam::Parser::parser_read_func_map_t sReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs; +static const LLSD NO_VALUE_MARKER; // // LLParamSDParser @@ -60,29 +61,32 @@ LLParamSDParser::LLParamSDParser() } // special case handling of U32 due to ambiguous LLSD::assign overload -bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + sd_to_write.assign((S32)*((const U32*)val_ptr)); - sd_to_write->assign((S32)*((const U32*)val_ptr)); return true; } -bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); return true; } +void LLParamSDParser::submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack) +{ + mCurReadSD = &sd; + block.submitValue(name_stack, *this); +} void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent) { @@ -90,7 +94,8 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool mNameStack.clear(); setParseSilently(silent); - readSDValues(sd, block); + LLParamSDParserUtilities::readSDValues(boost::bind(&LLParamSDParser::submit, this, boost::ref(block), _1, _2), sd, mNameStack); + //readSDValues(sd, block); } void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) @@ -100,43 +105,6 @@ void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) block.serializeBlock(*this); } -const LLSD NO_VALUE_MARKER; - -void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block) -{ - if (sd.isMap()) - { - for (LLSD::map_const_iterator it = sd.beginMap(); - it != sd.endMap(); - ++it) - { - mNameStack.push_back(make_pair(it->first, newParseGeneration())); - readSDValues(it->second, block); - mNameStack.pop_back(); - } - } - else if (sd.isArray()) - { - for (LLSD::array_const_iterator it = sd.beginArray(); - it != sd.endArray(); - ++it) - { - mNameStack.back().second = newParseGeneration(); - readSDValues(*it, block); - } - } - else if (sd.isUndefined()) - { - mCurReadSD = &NO_VALUE_MARKER; - block.submitValue(mNameStack, *this); - } - else - { - mCurReadSD = &sd; - block.submitValue(mNameStack, *this); - } -} - /*virtual*/ std::string LLParamSDParser::getCurrentElementName() { std::string full_name = "sd"; @@ -150,81 +118,6 @@ void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block return full_name; } -LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) -{ - //TODO: implement nested LLSD writing - LLSD* sd_to_write = mWriteRootSD; - bool new_traversal = false; - for (name_stack_t::const_iterator it = name_stack.begin(), prev_it = mNameStack.begin(); - it != name_stack.end(); - ++it) - { - bool new_array_entry = false; - if (prev_it == mNameStack.end()) - { - new_traversal = true; - } - else - { - if (!new_traversal // have not diverged yet from previous trace - && prev_it->first == it->first // names match - && prev_it->second != it->second) // versions differ - { - // name stacks match, but version numbers differ in last place. - // create a different entry at this point using an LLSD array - new_array_entry = true; - } - if (prev_it->first != it->first // names differ - || prev_it->second != it->second) // versions differ - { - // at this point we have diverged from our last trace - // so any elements referenced here are new - new_traversal = true; - } - } - - LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; - - if (child_sd->isArray()) - { - if (new_traversal) - { - // write to new element at end - sd_to_write = &(*child_sd)[child_sd->size()]; - } - else - { - // write to last of existing elements, or first element if empty - sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)]; - } - } - else - { - if (new_array_entry && !child_sd->isArray()) - { - // copy child contents into first element of an array - LLSD new_array = LLSD::emptyArray(); - new_array.append(*child_sd); - // assign array to slot that previously held the single value - *child_sd = new_array; - // return next element in that array - sd_to_write = &((*child_sd)[1]); - } - else - { - sd_to_write = child_sd; - } - } - if (prev_it != mNameStack.end()) - { - ++prev_it; - } - } - mNameStack = name_stack; - - //llinfos << ll_pretty_print_sd(*mWriteRootSD) << llendl; - return sd_to_write; -} bool LLParamSDParser::readFlag(Parser& parser, void* val_ptr) { @@ -312,3 +205,125 @@ bool LLParamSDParser::readSD(Parser& parser, void* val_ptr) *((LLSD*)val_ptr) = *self.mCurReadSD; return true; } + +// static +LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range) +{ + LLSD* sd_to_write = &input; + + for (LLInitParam::Parser::name_stack_t::iterator it = name_stack_range.first; + it != name_stack_range.second; + ++it) + { + bool new_traversal = it->second; + + LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; + + if (child_sd->isArray()) + { + if (new_traversal) + { + // write to new element at end + sd_to_write = &(*child_sd)[child_sd->size()]; + } + else + { + // write to last of existing elements, or first element if empty + sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)]; + } + } + else + { + if (new_traversal + && child_sd->isDefined() + && !child_sd->isArray()) + { + // copy child contents into first element of an array + LLSD new_array = LLSD::emptyArray(); + new_array.append(*child_sd); + // assign array to slot that previously held the single value + *child_sd = new_array; + // return next element in that array + sd_to_write = &((*child_sd)[1]); + } + else + { + sd_to_write = child_sd; + } + } + it->second = false; + } + + return *sd_to_write; +} + +//static +void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack) +{ + if (sd.isMap()) + { + for (LLSD::map_const_iterator it = sd.beginMap(); + it != sd.endMap(); + ++it) + { + stack.push_back(make_pair(it->first, true)); + readSDValues(cb, it->second, stack); + stack.pop_back(); + } + } + else if (sd.isArray()) + { + for (LLSD::array_const_iterator it = sd.beginArray(); + it != sd.endArray(); + ++it) + { + stack.back().second = true; + readSDValues(cb, *it, stack); + } + } + else if (sd.isUndefined()) + { + if (!cb.empty()) + { + cb(NO_VALUE_MARKER, stack); + } + } + else + { + if (!cb.empty()) + { + cb(sd, stack); + } + } +} + +namespace LLInitParam +{ + // LLSD specialization + // block param interface + bool ParamValue, false>::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name) + { + LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack); + + LLSD::String string; + + if (p.readValue(string)) + { + sd = string; + return true; + } + return false; + } + + //static + void ParamValue, false>::serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack) + { + p.writeValue(sd.asString(), name_stack); + } + + void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const + { + // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) + LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue); + } +} diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index a371c28f68..265993ffb5 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -29,6 +29,15 @@ #define LL_LLSDPARAM_H #include "llinitparam.h" +#include "boost/function.hpp" + +struct LLParamSDParserUtilities +{ + static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range); + + typedef boost::function read_sd_cb_t; + static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t()); +}; class LLParamSDParser : public LLInitParam::Parser @@ -45,25 +54,22 @@ public: /*virtual*/ std::string getCurrentElementName(); private: - void readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block); + void submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack); template - static bool writeTypedValue(Parser& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) + static bool writeTypedValue(Parser& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); - sd_to_write->assign(*((const T*)val_ptr)); + sd_to_write.assign(*((const T*)val_ptr)); return true; } - LLSD* getSDWriteNode(const parser_t::name_stack_t& name_stack); - - static bool writeU32Param(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool writeFlag(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); + static bool writeU32Param(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack); + static bool writeFlag(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack); static bool readFlag(Parser& parser, void* val_ptr); static bool readS32(Parser& parser, void* val_ptr); @@ -85,29 +91,29 @@ private: template class LLSDParamAdapter : public T +{ +public: + LLSDParamAdapter() {} + LLSDParamAdapter(const LLSD& sd) { - public: - LLSDParamAdapter() {} - LLSDParamAdapter(const LLSD& sd) - { - LLParamSDParser parser; - parser.readSD(sd, *this); - } - - operator LLSD() const - { - LLParamSDParser parser; - LLSD sd; - parser.writeSD(sd, *this); - return sd; - } + LLParamSDParser parser; + parser.readSD(sd, *this); + } + + operator LLSD() const + { + LLParamSDParser parser; + LLSD sd; + parser.writeSD(sd, *this); + return sd; + } - LLSDParamAdapter(const T& val) - : T(val) - { - T::operator=(val); - } - }; + LLSDParamAdapter(const T& val) + : T(val) + { + T::operator=(val); + } +}; #endif // LL_LLSDPARAM_H diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index d522123260..c8303bfc89 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -124,7 +124,7 @@ namespace LLInitParam { descriptor.mCurrentBlockPtr = this; } - bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; } + bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_value, S32 max_value) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index 2f814f4200..c1fb050206 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -72,7 +72,6 @@ S32 LLUIImage::getHeight() const namespace LLInitParam { - S32 Parser::sNextParseGeneration = 0; BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index fb6a2eabf1..9dbccf125a 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -66,8 +66,6 @@ namespace LLInitParam BaseBlock::BaseBlock() {} BaseBlock::~BaseBlock() {} - S32 Parser::sNextParseGeneration = 0; - BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, @@ -98,7 +96,7 @@ namespace LLInitParam mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr)); } - bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; } + bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index 99016205c8..2520502cf1 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -62,7 +62,6 @@ namespace LLInitParam mInspectFunc(inspect_func), mMinCount(min_count), mMaxCount(max_count), - mGeneration(0), mUserData(NULL) {} @@ -75,7 +74,6 @@ namespace LLInitParam mInspectFunc(NULL), mMinCount(0), mMaxCount(0), - mGeneration(0), mUserData(NULL) {} @@ -87,8 +85,6 @@ namespace LLInitParam // // Parser // - S32 Parser::sNextParseGeneration = 0; - Parser::~Parser() {} @@ -162,9 +158,9 @@ namespace LLInitParam return (param_address - baseblock_address); } - bool BaseBlock::submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent) + bool BaseBlock::submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent) { - if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end()), -1)) + if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end()), true)) { if (!silent) { @@ -213,8 +209,7 @@ namespace LLInitParam // each param descriptor remembers its serial number // so we can inspect the same param under different names // and see that it has the same number - (*it)->mGeneration = parser.newParseGeneration(); - name_stack.push_back(std::make_pair("", (*it)->mGeneration)); + name_stack.push_back(std::make_pair("", true)); serialize_func(*param, parser, name_stack, diff_param); name_stack.pop_back(); } @@ -250,12 +245,7 @@ namespace LLInitParam continue; } - if (!duplicate) - { - it->second->mGeneration = parser.newParseGeneration(); - } - - name_stack.push_back(std::make_pair(it->first, it->second->mGeneration)); + name_stack.push_back(std::make_pair(it->first, !duplicate)); const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; serialize_func(*param, parser, name_stack, diff_param); name_stack.pop_back(); @@ -278,8 +268,7 @@ namespace LLInitParam ParamDescriptor::inspect_func_t inspect_func = (*it)->mInspectFunc; if (inspect_func) { - (*it)->mGeneration = parser.newParseGeneration(); - name_stack.push_back(std::make_pair("", (*it)->mGeneration)); + name_stack.push_back(std::make_pair("", true)); inspect_func(*param, parser, name_stack, (*it)->mMinCount, (*it)->mMaxCount); name_stack.pop_back(); } @@ -307,11 +296,7 @@ namespace LLInitParam } } - if (!duplicate) - { - it->second->mGeneration = parser.newParseGeneration(); - } - name_stack.push_back(std::make_pair(it->first, it->second->mGeneration)); + name_stack.push_back(std::make_pair(it->first, !duplicate)); inspect_func(*param, parser, name_stack, it->second->mMinCount, it->second->mMaxCount); name_stack.pop_back(); } @@ -320,16 +305,18 @@ namespace LLInitParam return true; } - bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 parent_generation) + bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool ignored) { BlockDescriptor& block_data = mostDerivedBlockDescriptor(); - bool names_left = name_stack.first != name_stack.second; + bool names_left = name_stack_range.first != name_stack_range.second; - S32 parse_generation = name_stack.first == name_stack.second ? -1 : name_stack.first->second; + bool new_name = names_left + ? name_stack_range.first->second + : true; if (names_left) { - const std::string& top_name = name_stack.first->first; + const std::string& top_name = name_stack_range.first->first; ParamDescriptor::deserialize_func_t deserialize_func = NULL; Param* paramp = NULL; @@ -341,9 +328,18 @@ namespace LLInitParam paramp = getParamFromHandle(found_it->second->mParamHandle); deserialize_func = found_it->second->mDeserializeFunc; - Parser::name_stack_range_t new_name_stack(name_stack.first, name_stack.second); + Parser::name_stack_range_t new_name_stack(name_stack_range.first, name_stack_range.second); ++new_name_stack.first; - return deserialize_func(*paramp, p, new_name_stack, parse_generation); + if (deserialize_func(*paramp, p, new_name_stack, new_name)) + { + // value is no longer new, we know about it now + name_stack_range.first->second = false; + return true; + } + else + { + return false; + } } } @@ -355,7 +351,7 @@ namespace LLInitParam Param* paramp = getParamFromHandle((*it)->mParamHandle); ParamDescriptor::deserialize_func_t deserialize_func = (*it)->mDeserializeFunc; - if (deserialize_func && deserialize_func(*paramp, p, name_stack, parse_generation)) + if (deserialize_func && deserialize_func(*paramp, p, name_stack_range, new_name)) { return true; } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 1a131d15a3..9245f588d9 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -214,13 +214,13 @@ namespace LLInitParam } }; - typedef std::vector > name_stack_t; - typedef std::pair name_stack_range_t; - typedef std::vector possible_values_t; + typedef std::vector > name_stack_t; + typedef std::pair name_stack_range_t; + typedef std::vector possible_values_t; typedef bool (*parser_read_func_t)(Parser& parser, void* output); - typedef bool (*parser_write_func_t)(Parser& parser, const void*, const name_stack_t&); - typedef boost::function parser_inspect_func_t; + typedef bool (*parser_write_func_t)(Parser& parser, const void*, name_stack_t&); + typedef boost::function parser_inspect_func_t; typedef std::map parser_read_func_map_t; typedef std::map parser_write_func_map_t; @@ -228,7 +228,6 @@ namespace LLInitParam Parser(parser_read_func_map_t& read_map, parser_write_func_map_t& write_map, parser_inspect_func_map_t& inspect_map) : mParseSilently(false), - mParseGeneration(sNextParseGeneration), mParserReadFuncs(&read_map), mParserWriteFuncs(&write_map), mParserInspectFuncs(&inspect_map) @@ -245,7 +244,7 @@ namespace LLInitParam return false; } - template bool writeValue(const T& param, const name_stack_t& name_stack) + template bool writeValue(const T& param, name_stack_t& name_stack) { parser_write_func_map_t::iterator found_it = mParserWriteFuncs->find(&typeid(T)); if (found_it != mParserWriteFuncs->end()) @@ -256,7 +255,7 @@ namespace LLInitParam } // dispatch inspection to registered inspection functions, for each parameter in a param block - template bool inspectValue(const name_stack_t& name_stack, S32 min_count, S32 max_count, const possible_values_t* possible_values) + template bool inspectValue(name_stack_t& name_stack, S32 min_count, S32 max_count, const possible_values_t* possible_values) { parser_inspect_func_map_t::iterator found_it = mParserInspectFuncs->find(&typeid(T)); if (found_it != mParserInspectFuncs->end()) @@ -272,10 +271,6 @@ namespace LLInitParam virtual void parserError(const std::string& message); void setParseSilently(bool silent) { mParseSilently = silent; } - S32 getParseGeneration() { return mParseGeneration; } - S32 newParseGeneration() { return mParseGeneration = ++sNextParseGeneration; } - - protected: template void registerParserFuncs(parser_read_func_t read_func, parser_write_func_t write_func = NULL) @@ -296,9 +291,6 @@ namespace LLInitParam parser_read_func_map_t* mParserReadFuncs; parser_write_func_map_t* mParserWriteFuncs; parser_inspect_func_map_t* mParserInspectFuncs; - S32 mParseGeneration; - - static S32 sNextParseGeneration; }; class BaseBlock; @@ -341,7 +333,7 @@ namespace LLInitParam }; typedef bool(*merge_func_t)(Param&, const Param&, bool); - typedef bool(*deserialize_func_t)(Param&, Parser&, const Parser::name_stack_range_t&, S32); + typedef bool(*deserialize_func_t)(Param&, Parser&, const Parser::name_stack_range_t&, bool); typedef void(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const Param* diff_param); typedef void(*inspect_func_t)(const Param&, Parser&, Parser::name_stack_t&, S32 min_count, S32 max_count); typedef bool(*validation_func_t)(const Param*); @@ -366,7 +358,6 @@ namespace LLInitParam validation_func_t mValidationFunc; S32 mMinCount; S32 mMaxCount; - S32 mGeneration; S32 mNumRefs; UserData* mUserData; }; @@ -447,7 +438,7 @@ namespace LLInitParam BaseBlock(); virtual ~BaseBlock(); - bool submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent=false); + bool submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent=false); param_handle_t getHandleFromParam(const Param* param) const; bool validateBlock(bool emit_errors = true) const; @@ -473,7 +464,7 @@ namespace LLInitParam S32 getLastChangeVersion() const { return mChangeVersion; } - bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation); + bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); void serializeBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const; @@ -593,8 +584,7 @@ namespace LLInitParam mKeyVersion(0), mValidatedVersion(-1), mValidated(false) - { - } + {} void setValue(value_assignment_t val) { @@ -672,11 +662,11 @@ namespace LLInitParam bool isProvided() const { return Param::anyProvided(); } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { self_t& typed_param = static_cast(param); // no further names in stack, attempt to parse value now - if (name_stack.first == name_stack.second) + if (name_stack_range.first == name_stack_range.second) { if (parser.readValue(typed_param.getValue())) { @@ -715,7 +705,7 @@ namespace LLInitParam if (!name_stack.empty()) { - name_stack.back().second = parser.newParseGeneration(); + name_stack.back().second = true; } std::string key = typed_param.getValueName(); @@ -811,11 +801,11 @@ namespace LLInitParam } } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { self_t& typed_param = static_cast(param); // attempt to parse block... - if(typed_param.deserializeBlock(parser, name_stack, generation)) + if(typed_param.deserializeBlock(parser, name_stack_range, new_name)) { typed_param.clearValueName(); typed_param.enclosingBlock().paramChanged(param, true); @@ -851,7 +841,7 @@ namespace LLInitParam if (!name_stack.empty()) { - name_stack.back().second = parser.newParseGeneration(); + name_stack.back().second = true; } std::string key = typed_param.getValueName(); @@ -943,7 +933,7 @@ namespace LLInitParam public: typedef TypedParam self_t; typedef ParamValue param_value_t; - typedef typename std::vector container_t; + typedef typename std::vector container_t; typedef const container_t& value_assignment_t; typedef VALUE_TYPE value_t; @@ -970,12 +960,12 @@ namespace LLInitParam bool isProvided() const { return Param::anyProvided(); } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, bool new_name) { self_t& typed_param = static_cast(param); value_t value; // no further names in stack, attempt to parse value now - if (name_stack.first == name_stack.second) + if (name_stack_range.first == name_stack_range.second) { // attempt to read value directly if (parser.readValue(value)) @@ -1015,7 +1005,7 @@ namespace LLInitParam ++it) { std::string key = it->getValue(); - name_stack.back().second = parser.newParseGeneration(); + name_stack.back().second = true; if(key.empty()) // not parsed via name values, write out value directly @@ -1132,8 +1122,7 @@ namespace LLInitParam typedef NAME_VALUE_LOOKUP name_value_lookup_t; TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) - : Param(block_descriptor.mCurrentBlockPtr), - mLastParseGeneration(0) + : Param(block_descriptor.mCurrentBlockPtr) { std::copy(value.begin(), value.end(), back_inserter(mValues)); @@ -1153,13 +1142,12 @@ namespace LLInitParam bool isProvided() const { return Param::anyProvided(); } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { self_t& typed_param = static_cast(param); bool new_value = false; - if (generation != typed_param.mLastParseGeneration - || typed_param.mValues.empty()) + if (new_name || typed_param.mValues.empty()) { new_value = true; typed_param.mValues.push_back(value_t()); @@ -1168,12 +1156,8 @@ namespace LLInitParam param_value_t& value = typed_param.mValues.back(); // attempt to parse block... - if(value.deserializeBlock(parser, name_stack, generation)) + if(value.deserializeBlock(parser, name_stack_range, new_name)) { - if (new_value) - { // successfully parsed new value, let's keep it - typed_param.mLastParseGeneration = generation; - } typed_param.enclosingBlock().paramChanged(param, true); typed_param.setProvided(true); return true; @@ -1187,11 +1171,6 @@ namespace LLInitParam // try to parse a per type named value if (name_value_lookup_t::getValueFromName(name, value.getValue())) { - if (new_value) - { // successfully parsed new value, let's keep it - typed_param.mLastParseGeneration = generation; - } - typed_param.mValues.back().setValueName(name); typed_param.mValues.back().mKeyVersion = value.getLastChangeVersion(); typed_param.enclosingBlock().paramChanged(param, true); @@ -1219,7 +1198,7 @@ namespace LLInitParam it != end_it; ++it) { - name_stack.back().second = parser.newParseGeneration(); + name_stack.back().second = true; std::string key = it->getValueName(); if (!key.empty() && it->mKeyVersion == it->getLastChangeVersion()) @@ -1317,8 +1296,6 @@ namespace LLInitParam } container_t mValues; - - S32 mLastParseGeneration; }; template @@ -1625,9 +1602,9 @@ namespace LLInitParam } } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { - if (name_stack.first == name_stack.second) + if (name_stack_range.first == name_stack_range.second) { //std::string message = llformat("Deprecated value %s ignored", getName().c_str()); //parser.parserWarning(message); @@ -1669,18 +1646,16 @@ namespace LLInitParam typedef Block super_t; BatchBlock() - : mLastParseGeneration(-1) {} - bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation) + bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name) { - if (generation != mLastParseGeneration) + if (new_name) { // reset block *static_cast(this) = defaultBatchValue(); - mLastParseGeneration = generation; } - return super_t::deserializeBlock(p, name_stack, generation); + return super_t::deserializeBlock(p, name_stack_range, new_name); } bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) @@ -1688,7 +1663,6 @@ namespace LLInitParam if (overwrite) { *static_cast(this) = defaultBatchValue(); - mLastParseGeneration = -1; // merge individual parameters into destination return super_t::mergeBlock(super_t::selfBlockDescriptor(), other, overwrite); } @@ -1700,19 +1674,20 @@ namespace LLInitParam static DERIVED_BLOCK default_value; return default_value; } - - S32 mLastParseGeneration; }; + // FIXME: this specialization is not currently used, as it only matches against the BatchBlock base class + // and not the derived class with the actual params template class ParamValue , NAME_VALUE_LOOKUP, true> - : public Param, + : public NAME_VALUE_LOOKUP, protected BatchBlock { + public: typedef BatchBlock block_t; typedef const BatchBlock& value_assignment_t; @@ -1734,7 +1709,6 @@ namespace LLInitParam void setValue(value_assignment_t val) { *this = val; - block_t::mLastParseGeneration = -1; } value_assignment_t getValue() const @@ -1764,6 +1738,59 @@ namespace LLInitParam mutable bool mValidated; // lazy validation flag }; + template <> + class ParamValue , + false> + : public TypeValues, + public BaseBlock + { + public: + typedef ParamValue, false> self_t; + typedef const LLSD& value_assignment_t; + + ParamValue() + : mKeyVersion(0), + mValidatedVersion(-1), + mValidated(false) + {} + + ParamValue(value_assignment_t other) + : mValue(other), + mKeyVersion(0), + mValidatedVersion(-1), + mValidated(false) + {} + + void setValue(value_assignment_t val) { mValue = val; } + + value_assignment_t getValue() const { return mValue; } + LLSD& getValue() { return mValue; } + + operator value_assignment_t() const { return mValue; } + value_assignment_t operator()() const { return mValue; } + + S32 mKeyVersion; + + // block param interface + bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); + void serializeBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), const BaseBlock* diff_block = NULL) const; + bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const + { + //TODO: implement LLSD params as schema type Any + return true; + } + + protected: + mutable S32 mValidatedVersion; + mutable bool mValidated; // lazy validation flag + + private: + static void serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack); + + LLSD mValue; + }; + template class CustomParamValue : public Block > >, @@ -1790,11 +1817,11 @@ namespace LLInitParam mValidated(false) {} - bool deserializeBlock(Parser& parser, Parser::name_stack_range_t name_stack, S32 generation) + bool deserializeBlock(Parser& parser, Parser::name_stack_range_t name_stack_range, bool new_name) { derived_t& typed_param = static_cast(*this); // try to parse direct value T - if (name_stack.first == name_stack.second) + if (name_stack_range.first == name_stack_range.second) { if(parser.readValue(typed_param.mValue)) { @@ -1808,7 +1835,7 @@ namespace LLInitParam } // fall back on parsing block components for T - return typed_param.BaseBlock::deserializeBlock(parser, name_stack, generation); + return typed_param.BaseBlock::deserializeBlock(parser, name_stack_range, new_name); } void serializeBlock(Parser& parser, Parser::name_stack_t name_stack = Parser::name_stack_t(), const BaseBlock* diff_block = NULL) const diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index c60f656c2c..1bb550d98f 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -513,7 +513,6 @@ static LLInitParam::Parser::parser_inspect_func_map_t sXUIInspectFuncs; // LLXUIParser::LLXUIParser() : Parser(sXUIReadFuncs, sXUIWriteFuncs, sXUIInspectFuncs), - mLastWriteGeneration(-1), mCurReadDepth(0) { if (sXUIReadFuncs.empty()) @@ -583,7 +582,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) if (!text_contents.empty()) { mCurReadNode = nodep; - mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mNameStack.push_back(std::make_pair(std::string("value"), true)); // child nodes are not necessarily valid parameters (could be a child widget) // so don't complain once we've recursed if (!block.submitValue(mNameStack, *this, true)) @@ -618,7 +617,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) // since there is no widget named "rect" if (child_name.find(".") == std::string::npos) { - mNameStack.push_back(std::make_pair(child_name, newParseGeneration())); + mNameStack.push_back(std::make_pair(child_name, true)); num_tokens_pushed++; } else @@ -654,7 +653,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_token_it; token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } } @@ -704,7 +703,7 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_tokens.begin(); token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } @@ -728,7 +727,7 @@ void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &bloc } // go from a stack of names to a specific XML node -LLXMLNodePtr LLXUIParser::getNode(const name_stack_t& stack) +LLXMLNodePtr LLXUIParser::getNode(name_stack_t& stack) { name_stack_t name_stack; for (name_stack_t::const_iterator it = stack.begin(); @@ -781,7 +780,7 @@ bool LLXUIParser::readFlag(Parser& parser, void* val_ptr) return self.mCurReadNode == DUMMY_NODE; } -bool LLXUIParser::writeFlag(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeFlag(Parser& parser, const void* val_ptr, name_stack_t& stack) { // just create node LLXUIParser& self = static_cast(parser); @@ -798,7 +797,7 @@ bool LLXUIParser::readBoolValue(Parser& parser, void* val_ptr) return success; } -bool LLXUIParser::writeBoolValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeBoolValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -817,7 +816,7 @@ bool LLXUIParser::readStringValue(Parser& parser, void* val_ptr) return true; } -bool LLXUIParser::writeStringValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeStringValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -855,7 +854,7 @@ bool LLXUIParser::readU8Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getByteValue(1, (U8*)val_ptr); } -bool LLXUIParser::writeU8Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU8Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -879,7 +878,7 @@ bool LLXUIParser::readS8Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeS8Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS8Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -903,7 +902,7 @@ bool LLXUIParser::readU16Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeU16Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU16Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -927,7 +926,7 @@ bool LLXUIParser::readS16Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeS16Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS16Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -945,7 +944,7 @@ bool LLXUIParser::readU32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getUnsignedValue(1, (U32*)val_ptr); } -bool LLXUIParser::writeU32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -963,7 +962,7 @@ bool LLXUIParser::readS32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getIntValue(1, (S32*)val_ptr); } -bool LLXUIParser::writeS32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -981,7 +980,7 @@ bool LLXUIParser::readF32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getFloatValue(1, (F32*)val_ptr); } -bool LLXUIParser::writeF32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeF32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -999,7 +998,7 @@ bool LLXUIParser::readF64Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getDoubleValue(1, (F64*)val_ptr); } -bool LLXUIParser::writeF64Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeF64Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1023,7 +1022,7 @@ bool LLXUIParser::readColor4Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeColor4Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeColor4Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1050,7 +1049,7 @@ bool LLXUIParser::readUIColorValue(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeUIColorValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeUIColorValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1079,7 +1078,7 @@ bool LLXUIParser::readUUIDValue(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeUUIDValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeUUIDValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1098,7 +1097,7 @@ bool LLXUIParser::readSDValue(Parser& parser, void* val_ptr) return true; } -bool LLXUIParser::writeSDValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeSDValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast(parser); @@ -1207,7 +1206,6 @@ const char* NO_VALUE_MARKER = "no_value"; LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t element_cb) : Parser(sSimpleXUIReadFuncs, sSimpleXUIWriteFuncs, sSimpleXUIInspectFuncs), - mLastWriteGeneration(-1), mCurReadDepth(0), mElementCB(element_cb) { @@ -1338,7 +1336,7 @@ void LLSimpleXUIParser::startElement(const char *name, const char **atts) { // compound attribute if (child_name.find(".") == std::string::npos) { - mNameStack.push_back(std::make_pair(child_name, newParseGeneration())); + mNameStack.push_back(std::make_pair(child_name, true)); num_tokens_pushed++; mScope.push_back(child_name); } @@ -1365,7 +1363,7 @@ void LLSimpleXUIParser::startElement(const char *name, const char **atts) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_token_it; token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } mScope.push_back(mNameStack.back().first); @@ -1398,7 +1396,7 @@ bool LLSimpleXUIParser::readAttributes(const char **atts) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_tokens.begin(); token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } @@ -1420,7 +1418,7 @@ bool LLSimpleXUIParser::processText() LLStringUtil::trim(mTextContents); if (!mTextContents.empty()) { - mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mNameStack.push_back(std::make_pair(std::string("value"), true)); mCurAttributeValueBegin = mTextContents.c_str(); mOutputStack.back().first->submitValue(mNameStack, *this, mParseSilently); mNameStack.pop_back(); diff --git a/indra/llxuixml/llxuiparser.h b/indra/llxuixml/llxuiparser.h index 42a79b4100..e0402523da 100644 --- a/indra/llxuixml/llxuiparser.h +++ b/indra/llxuixml/llxuiparser.h @@ -133,23 +133,23 @@ private: static bool readSDValue(Parser& parser, void* val_ptr); //writer helper functions - static bool writeFlag(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeBoolValue(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeStringValue(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeU8Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeS8Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeU16Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeS16Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeU32Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeS32Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeF32Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeF64Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeColor4Value(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeUIColorValue(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeUUIDValue(Parser& parser, const void* val_ptr, const name_stack_t&); - static bool writeSDValue(Parser& parser, const void* val_ptr, const name_stack_t&); - - LLXMLNodePtr getNode(const name_stack_t& stack); + static bool writeFlag(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeBoolValue(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeStringValue(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeU8Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeS8Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeU16Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeS16Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeU32Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeS32Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeF32Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeF64Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeColor4Value(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeUIColorValue(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeUUIDValue(Parser& parser, const void* val_ptr, name_stack_t&); + static bool writeSDValue(Parser& parser, const void* val_ptr, name_stack_t&); + + LLXMLNodePtr getNode(name_stack_t& stack); private: Parser::name_stack_t mNameStack; @@ -159,7 +159,6 @@ private: typedef std::map out_nodes_t; out_nodes_t mOutNodes; - S32 mLastWriteGeneration; LLXMLNodePtr mLastWrittenChild; S32 mCurReadDepth; std::string mCurFileName; @@ -226,7 +225,6 @@ private: Parser::name_stack_t mNameStack; struct XML_ParserStruct* mParser; - S32 mLastWriteGeneration; LLXMLNodePtr mLastWrittenChild; S32 mCurReadDepth; std::string mCurFileName; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index fa0b392f1b..5077a0a596 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -109,6 +109,7 @@ // Third party library includes #include +#include #if LL_WINDOWS @@ -2041,42 +2042,37 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, llerrs << "Invalid settings location list" << llendl; } - for(LLInitParam::ParamIterator::const_iterator it = mSettingsLocationList->groups.begin(), end_it = mSettingsLocationList->groups.end(); - it != end_it; - ++it) + BOOST_FOREACH(const SettingsGroup& group, mSettingsLocationList->groups) { // skip settings groups that aren't the one we requested - if (it->name() != location_key) continue; + if (group.name() != location_key) continue; - ELLPath path_index = (ELLPath)it->path_index(); + ELLPath path_index = (ELLPath)group.path_index(); if(path_index <= LL_PATH_NONE || path_index >= LL_PATH_LAST) { llerrs << "Out of range path index in app_settings/settings_files.xml" << llendl; return false; } - LLInitParam::ParamIterator::const_iterator file_it, end_file_it; - for (file_it = it->files.begin(), end_file_it = it->files.end(); - file_it != end_file_it; - ++file_it) + BOOST_FOREACH(const SettingsFile& file, group.files) { - llinfos << "Attempting to load settings for the group " << file_it->name() + llinfos << "Attempting to load settings for the group " << file.name() << " - from location " << location_key << llendl; - LLControlGroup* settings_group = LLControlGroup::getInstance(file_it->name); + LLControlGroup* settings_group = LLControlGroup::getInstance(file.name); if(!settings_group) { - llwarns << "No matching settings group for name " << file_it->name() << llendl; + llwarns << "No matching settings group for name " << file.name() << llendl; continue; } std::string full_settings_path; - if (file_it->file_name_setting.isProvided() - && gSavedSettings.controlExists(file_it->file_name_setting)) + if (file.file_name_setting.isProvided() + && gSavedSettings.controlExists(file.file_name_setting)) { // try to find filename stored in file_name_setting control - full_settings_path = gSavedSettings.getString(file_it->file_name_setting); + full_settings_path = gSavedSettings.getString(file.file_name_setting); if (full_settings_path.empty()) { continue; @@ -2090,16 +2086,16 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, else { // by default, use specified file name - full_settings_path = gDirUtilp->getExpandedFilename((ELLPath)path_index, file_it->file_name()); + full_settings_path = gDirUtilp->getExpandedFilename((ELLPath)path_index, file.file_name()); } - if(settings_group->loadFromFile(full_settings_path, set_defaults, file_it->persistent)) + if(settings_group->loadFromFile(full_settings_path, set_defaults, file.persistent)) { // success! llinfos << "Loaded settings file " << full_settings_path << llendl; } else { // failed to load - if(file_it->required) + if(file.required) { llerrs << "Error: Cannot load required settings file from: " << full_settings_path << llendl; return false; @@ -2122,20 +2118,15 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string LLAppViewer::getSettingsFilename(const std::string& location_key, const std::string& file) { - for(LLInitParam::ParamIterator::const_iterator it = mSettingsLocationList->groups.begin(), end_it = mSettingsLocationList->groups.end(); - it != end_it; - ++it) + BOOST_FOREACH(const SettingsGroup& group, mSettingsLocationList->groups) { - if (it->name() == location_key) + if (group.name() == location_key) { - LLInitParam::ParamIterator::const_iterator file_it, end_file_it; - for (file_it = it->files.begin(), end_file_it = it->files.end(); - file_it != end_file_it; - ++file_it) + BOOST_FOREACH(const SettingsFile& settings_file, group.files) { - if (file_it->name() == file) + if (settings_file.name() == file) { - return file_it->file_name; + return settings_file.file_name; } } } -- cgit v1.2.3 From da3c7da7a585ea14a5a494ac7f36e7714bc86ab8 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 15:04:00 -0700 Subject: side toolbar buttons are now squares again --- indra/llui/lltoolbar.h | 4 ++-- indra/newview/skins/default/xui/en/widgets/toolbar.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 9e48dee608..84fa7ec0df 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -47,8 +47,8 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional button_width; - Optional desired_height; + Optional button_width; + Optional desired_height; Params() : button_width("button_width"), diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml index d36b015005..60e7c34d84 100644 --- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml @@ -33,9 +33,9 @@ image_pressed="PushButton_Press" image_pressed_selected="PushButton_Selected_Press" image_selected="PushButton_Selected_Press" - desired_height="35" - button_width.min="35" - button_width.max="35" + desired_height="38" + button_width.min="38" + button_width.max="38" follows="left|top" label="" chrome="true" -- cgit v1.2.3 From 0526d673093b2279777dc8be5aae9cc33cb1c822 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 15:31:25 -0700 Subject: EXP-1312 FIX Floaters should appear in region not covered by toolbars moved floater snap region to middle of toolbars and constrained floaters to that snap region also made toybox floater pass all drag and drop events along to toolbar --- indra/llui/llfloater.cpp | 2 +- indra/newview/llfloatertoybox.cpp | 11 +++++++++++ indra/newview/llfloatertoybox.h | 5 +++++ indra/newview/skins/default/xui/en/main_view.xml | 7 ------- indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 7 +++++++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index cc49238a0b..cba14e21c3 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2549,7 +2549,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out } // move window fully onscreen - if (floater->translateIntoRect( getLocalRect(), allow_partial_outside )) + if (floater->translateIntoRect( getSnapRect(), allow_partial_outside )) { floater->clearSnapTarget(); } diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index 609041803a..fa60022911 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -120,5 +120,16 @@ void LLFloaterToybox::onBtnRestoreDefaults() LLToolBarView::loadDefaultToolbars(); } +BOOL LLFloaterToybox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + S32 local_x = x - mToolBar->getRect().mLeft; + S32 local_y = y - mToolBar->getRect().mBottom; + return mToolBar->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); +} + // eof diff --git a/indra/newview/llfloatertoybox.h b/indra/newview/llfloatertoybox.h index f7245506c5..f0a6cf1a8b 100644 --- a/indra/newview/llfloatertoybox.h +++ b/indra/newview/llfloatertoybox.h @@ -43,6 +43,11 @@ public: // virtuals BOOL postBuild(); void draw(); + /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); protected: void onBtnRestoreDefaults(); diff --git a/indra/newview/skins/default/xui/en/main_view.xml b/indra/newview/skins/default/xui/en/main_view.xml index 57baa7cdd3..96d070ae50 100644 --- a/indra/newview/skins/default/xui/en/main_view.xml +++ b/indra/newview/skins/default/xui/en/main_view.xml @@ -74,13 +74,6 @@ user_resize="false" name="hud container" width="500"> - + Date: Mon, 10 Oct 2011 15:44:31 -0700 Subject: Added picks command and icon. Changed toolbar button text layout to halign left. --- indra/newview/app_settings/commands.xml | 10 +++++ indra/newview/skins/default/textures/textures.xml | 45 +++++++++++---------- .../skins/default/textures/toolbar_icons/picks.png | Bin 0 -> 1368 bytes .../skins/default/xui/en/floater_toybox.xml | 1 + indra/newview/skins/default/xui/en/strings.xml | 2 + .../skins/default/xui/en/widgets/toolbar.xml | 2 + 6 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 indra/newview/skins/default/textures/toolbar_icons/picks.png diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index dab57d44bd..f5581baa19 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -152,6 +152,16 @@ is_running_function="Floater.IsOpen" is_running_parameters="people" /> + - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/textures/toolbar_icons/picks.png b/indra/newview/skins/default/textures/toolbar_icons/picks.png new file mode 100644 index 0000000000..4499bf562b Binary files /dev/null and b/indra/newview/skins/default/textures/toolbar_icons/picks.png differ diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml index 653788bd3c..90b7e906a5 100644 --- a/indra/newview/skins/default/xui/en/floater_toybox.xml +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -74,6 +74,7 @@ image_color="ButtonImageColor" image_color_disabled="ButtonImageColor" flash_color="ButtonUnselectedFgColor" + halign="left" hover_glow_amount="0.15" display_pressed_state="false" /> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index f021fdd6a1..d12dda88be 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3668,6 +3668,7 @@ Try enclosing path to the editor with double quotes. Mini-map Move People + Picks Places Preferences Profile @@ -3692,6 +3693,7 @@ Try enclosing path to the editor with double quotes. Show nearby people Moving your avatar Friends, groups, and nearby people + Favorite places Places you've saved Preferences Edit or view your profile diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml index 60e7c34d84..09967de7cc 100644 --- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml @@ -14,6 +14,7 @@ background_opaque="true"/> Date: Mon, 10 Oct 2011 15:53:44 -0700 Subject: Mac build fix --- indra/llui/llsdparam.cpp | 9 ++++++--- indra/llui/llsdparam.h | 3 ++- indra/llxuixml/llinitparam.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 83bed3e745..da50c0ff39 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -66,7 +66,8 @@ bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const voi LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); sd_to_write.assign((S32)*((const U32*)val_ptr)); return true; @@ -77,7 +78,8 @@ bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* v LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); return true; } @@ -324,6 +326,7 @@ namespace LLInitParam void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const { // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) - LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue); + Parser::name_stack_t stack; + LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, stack); } } diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index 265993ffb5..784358d038 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -62,7 +62,8 @@ private: LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + LLInitParam::Parser::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); sd_to_write.assign(*((const T*)val_ptr)); return true; diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 9245f588d9..06140d0931 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -960,7 +960,7 @@ namespace LLInitParam bool isProvided() const { return Param::anyProvided(); } - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, bool new_name) + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { self_t& typed_param = static_cast(param); value_t value; -- cgit v1.2.3 From 2d34dab6a3d3f4b8ad78aee941800fe8f5f27bd1 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 16:54:55 -0700 Subject: fixed toolbar serialization --- indra/llxuixml/llxuiparser.cpp | 26 ++++++++------------------ indra/llxuixml/llxuiparser.h | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 1bb550d98f..aee8fa8d8f 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -729,22 +729,11 @@ void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &bloc // go from a stack of names to a specific XML node LLXMLNodePtr LLXUIParser::getNode(name_stack_t& stack) { - name_stack_t name_stack; - for (name_stack_t::const_iterator it = stack.begin(); - it != stack.end(); - ++it) - { - if (!it->first.empty()) - { - name_stack.push_back(*it); - } - } - LLXMLNodePtr out_node = mWriteRootNode; - name_stack_t::const_iterator next_it = name_stack.begin(); - for (name_stack_t::const_iterator it = name_stack.begin(); - it != name_stack.end(); + name_stack_t::iterator next_it = stack.begin(); + for (name_stack_t::iterator it = stack.begin(); + it != stack.end(); it = next_it) { ++next_it; @@ -753,17 +742,18 @@ LLXMLNodePtr LLXUIParser::getNode(name_stack_t& stack) continue; } - out_nodes_t::iterator found_it = mOutNodes.lower_bound(it->second); + out_nodes_t::iterator found_it = mOutNodes.find(it->first); // node with this name not yet written - if (found_it == mOutNodes.end() || mOutNodes.key_comp()(found_it->first, it->second)) + if (found_it == mOutNodes.end() || it->second) { // make an attribute if we are the last element on the name stack - bool is_attribute = next_it == name_stack.end(); + bool is_attribute = next_it == stack.end(); LLXMLNodePtr new_node = new LLXMLNode(it->first.c_str(), is_attribute); out_node->addChild(new_node); - mOutNodes.insert(found_it, std::make_pair(it->second, new_node)); + mOutNodes[it->first] = new_node; out_node = new_node; + it->second = false; } else { diff --git a/indra/llxuixml/llxuiparser.h b/indra/llxuixml/llxuiparser.h index e0402523da..d7cd256967 100644 --- a/indra/llxuixml/llxuiparser.h +++ b/indra/llxuixml/llxuiparser.h @@ -157,7 +157,7 @@ private: // Root of the widget XML sub-tree, for example, "line_editor" LLXMLNodePtr mWriteRootNode; - typedef std::map out_nodes_t; + typedef std::map out_nodes_t; out_nodes_t mOutNodes; LLXMLNodePtr mLastWrittenChild; S32 mCurReadDepth; -- cgit v1.2.3