]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
command: drop Jim Command handler, at last
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 16 Dec 2023 16:39:12 +0000 (17:39 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 25 May 2025 12:42:19 +0000 (12:42 +0000)
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
doc/manual/helper.txt
src/helper/command.c
src/helper/command.h
src/server/telnet_server.c

index 6cf3c977bf9522f711140657d684150bf18decd3..29e84e6f0b8e8b009c01b295c8923fe3a4c3b047 100644 (file)
@@ -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
index 218f0581efcc690e0eb1cc9df2a985a145f5baef..b70081a4dd9d09986c0c529ef589fe35842c1491 100644 (file)
@@ -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;
        }
index 18fe561782a4cdc6ba1e37df7bebca8391279a0e..8bd2430e0b0973656c254827e8b08254dd6bd912 100644 (file)
@@ -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 */
index 2c3f769801aa2682d4a1ede2aab0ddbecb034acf..3634a2a59209ae1b8a2d5af642f1e86c135d6ae8 100644 (file)
@@ -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) {