diff options
author | Todd Fiala <todd.fiala@gmail.com> | 2016-08-11 23:51:28 +0000 |
---|---|---|
committer | Todd Fiala <todd.fiala@gmail.com> | 2016-08-11 23:51:28 +0000 |
commit | e1cfbc79420fee0b71bad62f8d413b68a0eca91e (patch) | |
tree | ab91f6f91be4051731e37ed69ca9ff8c7bdad1ff /lldb/source/Interpreter/CommandObject.cpp | |
parent | 1602421c852d9d7fddbe8c5f014d7861a7848865 (diff) | |
download | llvm-e1cfbc79420fee0b71bad62f8d413b68a0eca91e.zip llvm-e1cfbc79420fee0b71bad62f8d413b68a0eca91e.tar.gz llvm-e1cfbc79420fee0b71bad62f8d413b68a0eca91e.tar.bz2 |
Decoupled Options from CommandInterpreter.
Options used to store a reference to the CommandInterpreter instance
in the base Options class. This made it impossible to parse options
independent of a CommandInterpreter.
This change removes the reference from the base class. Instead, it
modifies the options-parsing-related methods to take an
ExecutionContext pointer, which the options may inspect if they need
to do so.
Closes https://reviews.llvm.org/D23416
Reviewers: clayborg, jingham
llvm-svn: 278440
Diffstat (limited to 'lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 75e4292..3fd2d37 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -159,18 +159,23 @@ CommandObject::ParseOptions if (options != nullptr) { Error error; - options->NotifyOptionParsingStarting(); + + auto exe_ctx = GetCommandInterpreter().GetExecutionContext(); + options->NotifyOptionParsingStarting(&exe_ctx); // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1, // so we need to push a dummy value into position zero. args.Unshift("dummy_string"); - error = args.ParseOptions (*options); + const bool require_validation = true; + error = args.ParseOptions(*options, &exe_ctx, + GetCommandInterpreter().GetPlatform(true), + require_validation); // The "dummy_string" will have already been removed by ParseOptions, // so no need to remove it. if (error.Success()) - error = options->NotifyOptionParsingFinished(); + error = options->NotifyOptionParsingFinished(&exe_ctx); if (error.Success()) { @@ -188,7 +193,10 @@ CommandObject::ParseOptions else { // No error string, output the usage information into result - options->GenerateOptionUsage (result.GetErrorStream(), this); + options->GenerateOptionUsage(result.GetErrorStream(), this, + GetCommandInterpreter() + .GetDebugger() + .GetTerminalWidth()); } } result.SetStatus (eReturnStatusFailed); @@ -393,6 +401,7 @@ CommandObject::HandleCompletion cursor_char_position, match_start_point, max_return_elements, + GetCommandInterpreter(), word_complete, matches); if (handled_by_options) @@ -438,7 +447,9 @@ CommandObject::HelpTextContainsWord (const char *search_word, && GetOptions() != nullptr) { StreamString usage_help; - GetOptions()->GenerateOptionUsage (usage_help, this); + GetOptions()->GenerateOptionUsage(usage_help, this, + GetCommandInterpreter() + .GetDebugger().GetTerminalWidth()); if (usage_help.GetSize() > 0) { const char *usage_text = usage_help.GetData(); @@ -929,7 +940,9 @@ CommandObject::GenerateHelpText (Stream &output_strm) Options *options = GetOptions(); if (options != nullptr) { - options->GenerateOptionUsage(output_strm, this); + options->GenerateOptionUsage(output_strm, this, + GetCommandInterpreter() + .GetDebugger().GetTerminalWidth()); } const char *long_help = GetHelpLong(); if ((long_help != nullptr) && (strlen(long_help) > 0)) |