*endp = arg;
}
-std::unique_ptr<struct mi_parse>
-mi_parse::make (const char *cmd, std::string *token)
+/* See mi-parse.h. */
+
+mi_parse::mi_parse (const char *cmd, std::string *token)
{
const char *chp;
- std::unique_ptr<struct mi_parse> parse (new struct mi_parse);
-
/* Before starting, skip leading white space. */
cmd = skip_spaces (cmd);
if (*chp != '-')
{
chp = skip_spaces (chp);
- parse->command = make_unique_xstrdup (chp);
- parse->op = CLI_COMMAND;
+ this->command = make_unique_xstrdup (chp);
+ this->op = CLI_COMMAND;
- return parse;
+ return;
}
/* Extract the command. */
for (; *chp && !isspace (*chp); chp++)
;
- parse->command = make_unique_xstrndup (tmp, chp - tmp);
+ this->command = make_unique_xstrndup (tmp, chp - tmp);
}
/* Find the command in the MI table. */
- parse->cmd = mi_cmd_lookup (parse->command.get ());
- if (parse->cmd == NULL)
+ this->cmd = mi_cmd_lookup (this->command.get ());
+ if (this->cmd == NULL)
throw_error (UNDEFINED_COMMAND_ERROR,
- _("Undefined MI command: %s"), parse->command.get ());
+ _("Undefined MI command: %s"), this->command.get ());
/* Skip white space following the command. */
chp = skip_spaces (chp);
if (strncmp (chp, "--all ", as) == 0)
{
- parse->all = 1;
+ this->all = 1;
chp += as;
}
/* See if --all is the last token in the input. */
if (strcmp (chp, "--all") == 0)
{
- parse->all = 1;
+ this->all = 1;
chp += strlen (chp);
}
if (strncmp (chp, "--thread-group ", tgs) == 0)
option = "--thread-group";
chp += tgs;
- parse->set_thread_group (chp, &endp);
+ this->set_thread_group (chp, &endp);
chp = endp;
}
else if (strncmp (chp, "--thread ", ts) == 0)
option = "--thread";
chp += ts;
- parse->set_thread (chp, &endp);
+ this->set_thread (chp, &endp);
chp = endp;
}
else if (strncmp (chp, "--frame ", fs) == 0)
option = "--frame";
chp += fs;
- parse->set_frame (chp, &endp);
+ this->set_frame (chp, &endp);
chp = endp;
}
else if (strncmp (chp, "--language ", ls) == 0)
{
option = "--language";
chp += ls;
- parse->set_language (chp, &chp);
+ this->set_language (chp, &chp);
}
else
break;
}
/* Save the rest of the arguments for the command. */
- parse->m_args = chp;
+ this->m_args = chp;
/* Fully parsed, flag as an MI command. */
- parse->op = MI_COMMAND;
- return parse;
+ this->op = MI_COMMAND;
}
/* See mi-parse.h. */
-std::unique_ptr<struct mi_parse>
-mi_parse::make (gdb::unique_xmalloc_ptr<char> command,
- std::vector<gdb::unique_xmalloc_ptr<char>> args)
+mi_parse::mi_parse (gdb::unique_xmalloc_ptr<char> command,
+ std::vector<gdb::unique_xmalloc_ptr<char>> args)
{
- std::unique_ptr<struct mi_parse> parse (new struct mi_parse);
-
- parse->command = std::move (command);
- parse->token = "";
+ this->command = std::move (command);
+ this->token = "";
- if (parse->command.get ()[0] != '-')
+ if (this->command.get ()[0] != '-')
throw_error (UNDEFINED_COMMAND_ERROR,
_("MI command '%s' does not start with '-'"),
- parse->command.get ());
+ this->command.get ());
/* Find the command in the MI table. */
- parse->cmd = mi_cmd_lookup (parse->command.get () + 1);
- if (parse->cmd == NULL)
+ this->cmd = mi_cmd_lookup (this->command.get () + 1);
+ if (this->cmd == NULL)
throw_error (UNDEFINED_COMMAND_ERROR,
- _("Undefined MI command: %s"), parse->command.get ());
+ _("Undefined MI command: %s"), this->command.get ());
/* This over-allocates slightly, but it seems unimportant. */
- parse->argv = XCNEWVEC (char *, args.size () + 1);
+ this->argv = XCNEWVEC (char *, args.size () + 1);
for (size_t i = 0; i < args.size (); ++i)
{
/* See if --all is the last token in the input. */
if (strcmp (chp, "--all") == 0)
{
- parse->all = 1;
+ this->all = 1;
}
else if (strcmp (chp, "--thread-group") == 0)
{
++i;
if (i == args.size ())
error ("No argument to '--thread-group'");
- parse->set_thread_group (args[i].get (), nullptr);
+ this->set_thread_group (args[i].get (), nullptr);
}
else if (strcmp (chp, "--thread") == 0)
{
++i;
if (i == args.size ())
error ("No argument to '--thread'");
- parse->set_thread (args[i].get (), nullptr);
+ this->set_thread (args[i].get (), nullptr);
}
else if (strcmp (chp, "--frame") == 0)
{
++i;
if (i == args.size ())
error ("No argument to '--frame'");
- parse->set_frame (args[i].get (), nullptr);
+ this->set_frame (args[i].get (), nullptr);
}
else if (strcmp (chp, "--language") == 0)
{
++i;
if (i == args.size ())
error ("No argument to '--language'");
- parse->set_language (args[i].get (), nullptr);
+ this->set_language (args[i].get (), nullptr);
}
else
- parse->argv[parse->argc++] = args[i].release ();
+ this->argv[this->argc++] = args[i].release ();
}
/* Fully parsed, flag as an MI command. */
- parse->op = MI_COMMAND;
- return parse;
+ this->op = MI_COMMAND;
}
enum print_values
struct mi_parse
{
- /* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is
+ /* Attempt to parse CMD creating a ``struct mi_parse''. If CMD is
invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS
and OP are initialized. Un-initialized fields are zero. *TOKEN is
- set to the token, even if an exception is thrown. It can be
- assigned to the TOKEN field of the resultant mi_parse object,
- to be freed by mi_parse_free. */
-
- static std::unique_ptr<struct mi_parse> make (const char *cmd,
- std::string *token);
+ set to the token, even if an exception is thrown. */
+ mi_parse (const char *cmd, std::string *token);
/* Create an mi_parse object given the command name and a vector
of arguments. Unlike with the other constructor, here the
arguments are treated "as is" -- no escape processing is
done. */
-
- static std::unique_ptr<struct mi_parse> make
- (gdb::unique_xmalloc_ptr<char> command,
- std::vector<gdb::unique_xmalloc_ptr<char>> args);
+ mi_parse (gdb::unique_xmalloc_ptr<char> command,
+ std::vector<gdb::unique_xmalloc_ptr<char>> args);
~mi_parse ();
private:
- mi_parse () = default;
-
/* Helper methods for parsing arguments. Each takes the argument
to be parsed. It will either set a member of this object, or
throw an exception on error. In each case, *ENDP, if non-NULL,