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
|
@ -117,6 +117,7 @@ var_types;
|
|||
struct cmd_list_element;
|
||||
|
||||
typedef void cmd_cfunc_ftype (char *args, int from_tty);
|
||||
typedef void cmd_const_cfunc_ftype (const char *args, int from_tty);
|
||||
|
||||
/* This structure specifies notifications to be suppressed by a cli
|
||||
command interpreter. */
|
||||
|
@ -140,6 +141,19 @@ extern struct cmd_list_element *add_cmd (const char *, enum command_class,
|
|||
const char *,
|
||||
struct cmd_list_element **);
|
||||
|
||||
/* Const-correct variant of the above. */
|
||||
|
||||
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
|
||||
cmd_const_cfunc_ftype *fun,
|
||||
const char *,
|
||||
struct cmd_list_element **);
|
||||
|
||||
/* Like add_cmd, but no command function is specified. */
|
||||
|
||||
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
|
||||
const char *,
|
||||
struct cmd_list_element **);
|
||||
|
||||
extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
|
||||
enum command_class, int,
|
||||
struct cmd_list_element **);
|
||||
|
@ -171,6 +185,11 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
|
|||
extern void set_cmd_cfunc (struct cmd_list_element *cmd,
|
||||
cmd_cfunc_ftype *cfunc);
|
||||
|
||||
/* Const-correct variant of the above. */
|
||||
|
||||
extern void set_cmd_cfunc (struct cmd_list_element *cmd,
|
||||
cmd_const_cfunc_ftype *cfunc);
|
||||
|
||||
typedef void cmd_sfunc_ftype (char *args, int from_tty,
|
||||
struct cmd_list_element *c);
|
||||
extern void set_cmd_sfunc (struct cmd_list_element *cmd,
|
||||
|
@ -205,6 +224,8 @@ extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
|
|||
around in cmd objects to test the value of the commands sfunc(). */
|
||||
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
|
||||
cmd_cfunc_ftype *cfun);
|
||||
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
|
||||
cmd_const_cfunc_ftype *cfun);
|
||||
|
||||
/* Each command object has a local context attached to it. */
|
||||
extern void set_cmd_context (struct cmd_list_element *cmd,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue