From 6d1bc9b2f82e7b6c49e3a7fd38ed66aab1ac86d6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 29 Mar 2024 16:06:49 -0400 Subject: [PATCH] =?UTF-8?q?[msh]=20add=20comment=20for=20secondary-command?= =?UTF-8?q?s=20=E6=96=B0=E5=A2=9E=E5=8A=A0=E7=9A=84=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=B8=85=E6=99=B0=E7=9A=84=E6=8F=8F=E8=BF=B0=20-=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0PR=EF=BC=9Ahttps://github.c?= =?UTF-8?q?om/RT-Thread/rt-thread/pull/8086=20-=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96PR=EF=BC=9Ahttps://github.com/RT-Thread/rt-th?= =?UTF-8?q?read/pull/8251=20-=20=E4=BD=BF=E7=94=A8=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=9A=84=E4=BE=8B=E5=AD=90=EF=BC=9Ahttps://g?= =?UTF-8?q?ithub.com/RT-Thread/rt-thread/pull/8398=20-=20=E7=9B=B8?= =?UTF-8?q?=E5=85=B3issue=EF=BC=9Ahttps://github.com/RT-Thread/rt-thread/i?= =?UTF-8?q?ssues/8691?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/finsh/finsh.h | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index f8e4ba5060..4e9727df5b 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -35,6 +35,13 @@ typedef long (*syscall_func)(void); #define __TI_FINSH_EXPORT_FUNCTION(f) PRAGMA(DATA_SECTION(f,"FSymTab")) #endif /* __TI_COMPILER_VERSION__ */ +/** + * Macro to export a command along with its name, description, and options to the symbol table in MSVC. + * @param name The function name associated with the command. + * @param cmd The command name. + * @param desc The description of the command. + * @param opt The options associated with the command, used for option completion. + */ #ifdef _MSC_VER #define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc, opt) \ const char __fsym_##cmd##_name[] = #cmd; \ @@ -80,9 +87,11 @@ typedef long (*syscall_func)(void); }; #endif /* _MSC_VER */ -#endif /* end of FINSH_USING_SYMTAB */ - +#endif /* FINSH_USING_SYMTAB */ +/** + * Macro definitions to simplify the declaration of exported functions or commands. + */ #define __MSH_GET_MACRO(_1, _2, _3, _FUN, ...) _FUN #define __MSH_GET_EXPORT_MACRO(_1, _2, _3, _4, _FUN, ...) _FUN @@ -143,9 +152,10 @@ typedef long (*syscall_func)(void); * @param alias is the alias of the command. * @param desc is the description of the command, which will show in help list. * @param opt This is an option, enter any content to enable option completion + * @note + * #define MSH_CMD_EXPORT_ALIAS(command, alias, desc) or + * #define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt) */ -/* #define MSH_CMD_EXPORT_ALIAS(command, alias, desc) or - #define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt) */ #define MSH_CMD_EXPORT_ALIAS(...) \ __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD3_OPT, \ _MSH_FUNCTION_EXPORT_CMD3)(__VA_ARGS__) @@ -179,9 +189,31 @@ typedef struct msh_cmd_opt const char *des; } msh_cmd_opt_t; +/* Command options declaration and definition macros */ + +/** + * Declares a static array of command options for a specific command. + * @param command The command associated with these options. + */ #define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[]; + +/** + * Starts the definition of command options for a specific command. + * @param command The command these options are associated with. + */ #define CMD_OPTIONS_NODE_START(command) static struct msh_cmd_opt command##_msh_options[] = { + +/** + * Defines a single command option. + * @param _id Unique identifier for the option. + * @param _name The name of the option. + * @param _des Description of the option. + */ #define CMD_OPTIONS_NODE(_id, _name, _des) {.id = _id, .name = #_name, .des = #_des}, + +/** + * Marks the end of command options definition. + */ #define CMD_OPTIONS_NODE_END {0},}; void msh_opt_list_dump(void *options);