Add add_cmd function overloads
This adds two add_cmd overloads: one whose callback takes a const char *, and one that doesn't accept a function at all. The no-function overload was introduced to avoid ambiguity when NULL was passed as the function. Long term the goal is for all commands to take const arguments, and for the non-const variants to be removed entirely. gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * cli/cli-decode.c (add_cmd, set_cmd_cfunc): New function overloads. (do_add_cmd): Rename from add_cmd. Don't call set_cmd_cfunc. (do_const_cfunc): New function. (cmd_cfunc_eq): New overload. (cli_user_command_p): Check do_const_cfunc. * cli/cli-decode.h (struct cmd_list_element) <function>: New field const_cfunc. * command.h (add_cmd): Add const overload and no-function overload. (set_cmd_cfunc): Add const overload. (cmd_const_cfunc_ftype): Declare. (cmd_cfunc_eq): Add const overload. * breakpoint.c, cli-cmds.c, cli-dump.c, guile/scm-cmd.c, python/py-cmd.c, target.c, tracepoint.c: Use no-function add_cmd overload.
This commit is contained in:
parent
a9bbfbd85f
commit
0450cc4ce8
11 changed files with 124 additions and 31 deletions
|
@ -360,7 +360,7 @@ add_dump_command (const char *name,
|
|||
struct cmd_list_element *c;
|
||||
struct dump_context *d;
|
||||
|
||||
c = add_cmd (name, all_commands, NULL, descr, &dump_cmdlist);
|
||||
c = add_cmd (name, all_commands, descr, &dump_cmdlist);
|
||||
c->completer = filename_completer;
|
||||
d = XNEW (struct dump_context);
|
||||
d->func = func;
|
||||
|
@ -368,7 +368,7 @@ add_dump_command (const char *name,
|
|||
set_cmd_context (c, d);
|
||||
c->func = call_dump_func;
|
||||
|
||||
c = add_cmd (name, all_commands, NULL, descr, &append_cmdlist);
|
||||
c = add_cmd (name, all_commands, descr, &append_cmdlist);
|
||||
c->completer = filename_completer;
|
||||
d = XNEW (struct dump_context);
|
||||
d->func = func;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue