diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-21 13:59:51 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 21:37:30 -0800 |
commit | 60ba4641d61ba65943ac7a8c800e82d6665ee11f (patch) | |
tree | 8670f3bfebaefd2c62c948292da9f0991dc39bc5 /src/helper/command.h | |
parent | 607634f967cf25630860794847dea770eb17a8f4 (diff) | |
download | riscv-openocd-60ba4641d61ba65943ac7a8c800e82d6665ee11f.zip riscv-openocd-60ba4641d61ba65943ac7a8c800e82d6665ee11f.tar.gz riscv-openocd-60ba4641d61ba65943ac7a8c800e82d6665ee11f.tar.bz2 |
add command registration chaining
Adds the ability to chain registration structures. Modules can define a
command with the 'chain' and 'num_chain' fields defined in their
registration table, and the register_commands() function will initialize
these commands. If the registration record creates a new command, then
the chained commands are created under it; otherwise, they are created
in the same context as the other commands (i.e. the parent argument).
Diffstat (limited to 'src/helper/command.h')
-rw-r--r-- | src/helper/command.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/helper/command.h b/src/helper/command.h index 7baa92d..6e3e93a 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -202,10 +202,18 @@ struct command_registration { const char *help; /// a string listing the options and arguments, required or optional const char *usage; + + /** + * If non-NULL, the commands in @c chain will be registered in + * the same context and scope of this registration record. + * This allows modules to inherit lists commands from other + * modules. + */ + const struct command_registration *chain; }; /// Use this as the last entry in an array of command_registration records. -#define COMMAND_REGISTRATION_DONE { .name = NULL } +#define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL } /** * Register a command @c handler that can be called from scripts during @@ -238,7 +246,10 @@ struct command* register_command(struct command_context *cmd_ctx, /** * Register one or more commands in the specified context, as children - * of @c parent (or top-level commends, if NULL). + * of @c parent (or top-level commends, if NULL). In a registration's + * record contains a non-NULL @c chain member and name is NULL, the + * commands on the chain will be registered in the same context. + * Otherwise, the chained commands are added as children of the command. * * @param cmd_ctx The command_context in which to register the command. * @param parent Register this command as a child of this, or NULL to |