gdb: remove cmd_list_element::function::sfunc
I don't understand what the sfunc function type in cmd_list_element::function is for. Compared to cmd_simple_func_ftype, it has an extra cmd_list_element parameter, giving the callback access to the cmd_list_element for the command being invoked. This allows registering the same callback with many commands, and alter the behavior using the cmd_list_element's context. From the comment in cmd_list_element, it sounds like at some point it was the callback function type for set and show functions, hence the "s". But nowadays, it's used for many more commands that need to access the cmd_list_element object (see add_catch_command for example). I don't really see the point of having sfunc at all, since do_sfunc is just a trivial shim that changes the order of the arguments. All commands using sfunc could just as well set cmd_list_element::func to their callback directly. Therefore, remove the sfunc field in cmd_list_element and everything that goes with it. Rename cmd_const_sfunc_ftype to cmd_func_ftype and use it for cmd_list_element::func, as well as for the add_setshow commands. Change-Id: I1eb96326c9b511c293c76996cea0ebc51c70fac0
This commit is contained in:
parent
3a553c80da
commit
5538b03c98
12 changed files with 52 additions and 82 deletions
|
@ -168,8 +168,8 @@ struct cmd_list_element
|
|||
cagney/2002-02-02: This function signature is evolving. For
|
||||
the moment suggest sticking with either set_cmd_cfunc() or
|
||||
set_cmd_sfunc(). */
|
||||
void (*func) (struct cmd_list_element *c, const char *args, int from_tty)
|
||||
= nullptr;
|
||||
cmd_func_ftype *func;
|
||||
|
||||
/* The command's real callback. At present func() bounces through
|
||||
to one of the below. */
|
||||
union
|
||||
|
@ -179,10 +179,6 @@ struct cmd_list_element
|
|||
cmd_list_element parameter. do_simple_func is installed as FUNC, and
|
||||
acts as a shim between the two. */
|
||||
cmd_simple_func_ftype *simple_func;
|
||||
|
||||
/* If type is set_cmd or show_cmd, first set the variables,
|
||||
and then call this: */
|
||||
cmd_const_sfunc_ftype *sfunc;
|
||||
}
|
||||
function;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue