forked from Imagelibrary/binutils-gdb
Use accessor for mi_parse::args
This changes mi_parse::args to be a private member, retrieved via accessor. It also changes this member to be a std::string. This makes it simpler for a subsequent patch to implement different behavior for argument parsing.
This commit is contained in:
@@ -49,11 +49,11 @@ struct mi_command_mi : public mi_command
|
||||
with arguments contained within PARSE. */
|
||||
void invoke (struct mi_parse *parse) const override
|
||||
{
|
||||
mi_parse_argv (parse->args, parse);
|
||||
mi_parse_argv (parse->args (), parse);
|
||||
|
||||
if (parse->argv == nullptr)
|
||||
error (_("Problem parsing arguments: %s %s"), parse->command,
|
||||
parse->args);
|
||||
parse->args ());
|
||||
|
||||
this->m_argv_function (parse->command, parse->argv, parse->argc);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ struct mi_command_cli : public mi_command
|
||||
is passed through to the CLI function as its argument string. */
|
||||
void invoke (struct mi_parse *parse) const override
|
||||
{
|
||||
const char *args = m_args_p ? parse->args : nullptr;
|
||||
const char *args = m_args_p ? parse->args () : nullptr;
|
||||
mi_execute_cli_command (m_cli_name, m_args_p, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1813,7 +1813,7 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
|
||||
if (mi_debug_p)
|
||||
gdb_printf (gdb_stdlog,
|
||||
" token=`%s' command=`%s' args=`%s'\n",
|
||||
context->token, context->command, context->args);
|
||||
context->token, context->command, context->args ());
|
||||
|
||||
mi_cmd_execute (context);
|
||||
|
||||
|
||||
@@ -212,7 +212,6 @@ mi_parse::~mi_parse ()
|
||||
{
|
||||
xfree (command);
|
||||
xfree (token);
|
||||
xfree (args);
|
||||
freeargv (argv);
|
||||
}
|
||||
|
||||
@@ -346,7 +345,7 @@ mi_parse (const char *cmd, char **token)
|
||||
}
|
||||
|
||||
/* Save the rest of the arguments for the command. */
|
||||
parse->args = xstrdup (chp);
|
||||
parse->set_args (chp);
|
||||
|
||||
/* Fully parsed, flag as an MI command. */
|
||||
parse->op = MI_COMMAND;
|
||||
|
||||
@@ -46,12 +46,19 @@ struct mi_parse
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (mi_parse);
|
||||
|
||||
/* Return the full argument string, as used by commands which are
|
||||
implemented as CLI commands. */
|
||||
const char *args () const
|
||||
{ return m_args.c_str (); }
|
||||
|
||||
void set_args (const char *args)
|
||||
{ m_args = args; }
|
||||
|
||||
enum mi_command_type op = MI_COMMAND;
|
||||
char *command = nullptr;
|
||||
char *token = nullptr;
|
||||
const struct mi_command *cmd = nullptr;
|
||||
struct mi_timestamp *cmd_start = nullptr;
|
||||
char *args = nullptr;
|
||||
char **argv = nullptr;
|
||||
int argc = 0;
|
||||
int all = 0;
|
||||
@@ -62,6 +69,10 @@ struct mi_parse
|
||||
/* The language that should be used to evaluate the MI command.
|
||||
Ignored if set to language_unknown. */
|
||||
enum language language = language_unknown;
|
||||
|
||||
private:
|
||||
|
||||
std::string m_args;
|
||||
};
|
||||
|
||||
/* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is
|
||||
|
||||
@@ -355,10 +355,11 @@ mi_command_py::invoke (struct mi_parse *parse) const
|
||||
|
||||
pymicmd_debug_printf ("this = %p, name = %s", this, name ());
|
||||
|
||||
mi_parse_argv (parse->args, parse);
|
||||
mi_parse_argv (parse->args (), parse);
|
||||
|
||||
if (parse->argv == nullptr)
|
||||
error (_("Problem parsing arguments: %s %s"), parse->command, parse->args);
|
||||
error (_("Problem parsing arguments: %s %s"), parse->command,
|
||||
parse->args ());
|
||||
|
||||
|
||||
gdbpy_enter enter_py;
|
||||
|
||||
Reference in New Issue
Block a user