command: drop Jim Command handler, at last
With all OpenOCD commands converted to COMMAND_HANDLER, we can drop the management of jim_handler commands. Drop also from documentation the subsection on Jim Command Registration. Change-Id: I4d13abc7e384e64ecb155cb40bbbd52bb79ec672 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8901 Tested-by: jenkins
This commit is contained in:
@@ -97,18 +97,6 @@ registration, while the @c unregister_command() and
|
||||
These may be called at any time, allowing the command set to change in
|
||||
response to system actions.
|
||||
|
||||
@subsection helpercmdjim Jim Command Registration
|
||||
|
||||
The command_registration structure provides support for registering
|
||||
native Jim command handlers (@c jim_handler) too. For these handlers,
|
||||
the module can provide help and usage support; however, this mechanism
|
||||
allows Jim handlers to be called as sub-commands of other commands.
|
||||
These commands may be registered with a private data value (@c
|
||||
jim_handler_data) that will be available when called, as with low-level
|
||||
Jim command registration.
|
||||
|
||||
A command may have a normal @c handler or a @c jim_handler, but not both.
|
||||
|
||||
@subsection helpercmdregisterchains Command Chaining
|
||||
|
||||
When using register_commands(), the array of commands may reference
|
||||
|
||||
@@ -130,13 +130,13 @@ static struct command *command_new(struct command_context *cmd_ctx,
|
||||
assert(cr->name);
|
||||
|
||||
/*
|
||||
* If it is a non-jim command with no .usage specified,
|
||||
* If it is a command with no .usage specified,
|
||||
* log an error.
|
||||
*
|
||||
* strlen(.usage) == 0 means that the command takes no
|
||||
* arguments.
|
||||
*/
|
||||
if (!cr->jim_handler && !cr->usage)
|
||||
if (!cr->usage)
|
||||
LOG_ERROR("BUG: command '%s' does not have the "
|
||||
"'.usage' field filled out",
|
||||
full_name);
|
||||
@@ -152,7 +152,6 @@ static struct command *command_new(struct command_context *cmd_ctx,
|
||||
}
|
||||
|
||||
c->handler = cr->handler;
|
||||
c->jim_handler = cr->jim_handler;
|
||||
c->mode = cr->mode;
|
||||
|
||||
if (cr->help || cr->usage)
|
||||
@@ -425,9 +424,6 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c,
|
||||
static int exec_command(Jim_Interp *interp, struct command_context *context,
|
||||
struct command *c, int argc, Jim_Obj * const *argv)
|
||||
{
|
||||
if (c->jim_handler)
|
||||
return c->jim_handler(interp, argc, argv);
|
||||
|
||||
/* use c->handler */
|
||||
const char **words = malloc(argc * sizeof(char *));
|
||||
if (!words) {
|
||||
@@ -841,7 +837,7 @@ static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *a
|
||||
script_debug(interp, argc, argv);
|
||||
|
||||
struct command *c = jim_to_command(interp);
|
||||
if (!c->jim_handler && !c->handler) {
|
||||
if (!c->handler) {
|
||||
Jim_EvalObjPrefix(interp, Jim_NewStringObj(interp, "usage", -1), 1, argv);
|
||||
return JIM_ERR;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,6 @@ typedef __COMMAND_HANDLER((*command_handler_t));
|
||||
struct command {
|
||||
char *name;
|
||||
command_handler_t handler;
|
||||
Jim_CmdProc *jim_handler;
|
||||
void *jim_handler_data;
|
||||
/* Command handlers can use it for any handler specific data */
|
||||
struct target *jim_override_target;
|
||||
@@ -234,7 +233,6 @@ static inline struct command *jim_to_command(Jim_Interp *interp)
|
||||
struct command_registration {
|
||||
const char *name;
|
||||
command_handler_t handler;
|
||||
Jim_CmdProc *jim_handler;
|
||||
enum command_mode mode;
|
||||
const char *help;
|
||||
/** a string listing the options and arguments, required or optional */
|
||||
|
||||
@@ -671,7 +671,7 @@ static void telnet_auto_complete(struct connection *connection)
|
||||
} else if (jimcmd_is_oocd_command(jim_cmd)) {
|
||||
struct command *cmd = jimcmd_privdata(jim_cmd);
|
||||
|
||||
if (cmd && !cmd->handler && !cmd->jim_handler) {
|
||||
if (cmd && !cmd->handler) {
|
||||
/* Initial part of a multi-word command. Ignore it! */
|
||||
ignore_cmd = true;
|
||||
} else if (cmd && cmd->mode == COMMAND_CONFIG) {
|
||||
|
||||
Reference in New Issue
Block a user