diff options
author | Enrico Granata <egranata@apple.com> | 2016-03-14 19:00:21 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-03-14 19:00:21 +0000 |
commit | 3e271af415abaed8d988990dd49b55eb6a95c81b (patch) | |
tree | 32f6b68d3a146abac67e8ef6d91885f2176956ff /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | 5af4d20372e968e026305d826c216cd3839bc8dd (diff) | |
download | bcm5719-llvm-3e271af415abaed8d988990dd49b55eb6a95c81b.tar.gz bcm5719-llvm-3e271af415abaed8d988990dd49b55eb6a95c81b.zip |
More of the alias refactoring work! CommandAlias is now a CommandObject
llvm-svn: 263468
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index ec43fd6fabd..ffe5a57e94d 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -772,7 +772,7 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo { CommandAliasMap::iterator alias_pos = m_alias_dict.find(cmd); if (alias_pos != m_alias_dict.end()) - command_sp = alias_pos->second->GetUnderlyingCommand(); + command_sp = ((CommandAlias*)alias_pos->second.get())->GetUnderlyingCommand(); } if (HasUserCommands()) @@ -823,7 +823,7 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo cmd.assign(matches->GetStringAtIndex (num_cmd_matches)); CommandAliasMap::iterator alias_pos = m_alias_dict.find(cmd); if (alias_pos != m_alias_dict.end()) - alias_match_sp = alias_pos->second->GetUnderlyingCommand(); + alias_match_sp = ((CommandAlias*)alias_pos->second.get())->GetUnderlyingCommand(); } if (HasUserCommands()) @@ -1057,11 +1057,17 @@ CommandInterpreter::AddAlias (const char *alias_name, if (command_obj_sp.get()) assert((this == &command_obj_sp->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter"); - if (auto cmd_alias = CommandAlias::GetCommandAlias(command_obj_sp, args_string)) + std::unique_ptr<CommandAlias> command_alias_up(new CommandAlias(*this, + command_obj_sp, + args_string, + alias_name)); + + if (command_alias_up && command_alias_up->IsValid()) { - m_alias_dict[alias_name] = std::move(cmd_alias); + m_alias_dict[alias_name] = CommandObjectSP(command_alias_up.release()); return true; } + return false; } @@ -1144,15 +1150,8 @@ CommandInterpreter::GetHelp (CommandReturnObject &result, for (auto alias_pos = m_alias_dict.begin(); alias_pos != m_alias_dict.end(); ++alias_pos) { - StreamString sstr; - StreamString translation_and_help; - std::string entry_name = alias_pos->first; - std::string second_entry = alias_pos->second->GetUnderlyingCommand()->GetCommandName(); - alias_pos->second->GetAliasExpansion(sstr); - - translation_and_help.Printf ("(%s) %s", sstr.GetData(), alias_pos->second->GetUnderlyingCommand()->GetHelp()); - OutputFormattedHelpText (result.GetOutputStream(), alias_pos->first.c_str(), "--", - translation_and_help.GetData(), max_len); + OutputFormattedHelpText (result.GetOutputStream(), alias_pos->first.c_str(), "--", alias_pos->second->GetHelp(), + max_len); } result.AppendMessage(""); } @@ -1996,7 +1995,7 @@ CommandInterpreter::GetAlias (const char *alias_name) auto pos = m_alias_dict.find(alias); if (pos != m_alias_dict.end()) - return pos->second.get(); + return (CommandAlias*)pos->second.get(); return nullptr; } |