From b80a455b3459f5b104906159d37c90b25c1e3cf2 Mon Sep 17 00:00:00 2001 From: wangqinglin <53550140+HelloByeAll@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:54:22 +0800 Subject: [PATCH] =?UTF-8?q?FINSH:=20=E4=BC=98=E5=8C=96MSH=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20(#8251)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/finsh/finsh.h | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index d6bf53abcb..f8e4ba5060 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -89,20 +89,15 @@ typedef long (*syscall_func)(void); #define _MSH_FUNCTION_CMD2(a0, a1) \ MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, 0) -#define _MSH_FUNCTION_CMD3_OPT(a0, a1, a2) \ +#define _MSH_FUNCTION_CMD2_OPT(a0, a1, a2) \ MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, a0##_msh_options) -#define _MSH_FUNCTION_CMD3_NO_OPT(a0, a1, a2) \ - MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, 0) - #define _MSH_FUNCTION_EXPORT_CMD3(a0, a1, a2) \ MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, 0) -#define _MSH_FUNCTION_EXPORT_CMD4_OPT(a0, a1, a2, a3) \ +#define _MSH_FUNCTION_EXPORT_CMD3_OPT(a0, a1, a2, a3) \ MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, a0##_msh_options) -#define _MSH_FUNCTION_EXPORT_CMD4_NO_OPT(a0, a1, a2, a3) \ - MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, 0) /** * @ingroup finsh @@ -135,15 +130,9 @@ typedef long (*syscall_func)(void); * @param opt This is an option, enter any content to enable option completion */ /* MSH_CMD_EXPORT(command, desc) or MSH_CMD_EXPORT(command, desc, opt) */ -#ifdef FINSH_USING_OPTION_COMPLETION #define MSH_CMD_EXPORT(...) \ - __MSH_GET_MACRO(__VA_ARGS__, _MSH_FUNCTION_CMD3_OPT, \ + __MSH_GET_MACRO(__VA_ARGS__, _MSH_FUNCTION_CMD2_OPT, \ _MSH_FUNCTION_CMD2)(__VA_ARGS__) -#else -#define MSH_CMD_EXPORT(...) \ - __MSH_GET_MACRO(__VA_ARGS__, _MSH_FUNCTION_CMD3_NO_OPT, \ - _MSH_FUNCTION_CMD2)(__VA_ARGS__) -#endif /* FINSH_USING_OPTION_COMPLETION */ /** * @ingroup msh @@ -157,15 +146,9 @@ typedef long (*syscall_func)(void); */ /* #define MSH_CMD_EXPORT_ALIAS(command, alias, desc) or #define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt) */ -#ifdef FINSH_USING_OPTION_COMPLETION #define MSH_CMD_EXPORT_ALIAS(...) \ - __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD4_OPT, \ + __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD3_OPT, \ _MSH_FUNCTION_EXPORT_CMD3)(__VA_ARGS__) -#else -#define MSH_CMD_EXPORT_ALIAS(...) \ - __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD4_NO_OPT, \ - _MSH_FUNCTION_EXPORT_CMD3)(__VA_ARGS__) -#endif /* FINSH_USING_OPTION_COMPLETION */ /* system call table */ struct finsh_syscall @@ -191,9 +174,9 @@ struct finsh_syscall_item #ifdef FINSH_USING_OPTION_COMPLETION typedef struct msh_cmd_opt { - rt_uint32_t id; - const char *name; - const char *des; + rt_uint32_t id; + const char *name; + const char *des; } msh_cmd_opt_t; #define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[]; @@ -211,6 +194,8 @@ int msh_cmd_opt_id_get(int argc, char *argv[], void *options); #define CMD_OPTIONS_NODE_START(command) #define CMD_OPTIONS_NODE(_id, _name, _des) #define CMD_OPTIONS_NODE_END +#define MSH_OPT_ID_GET(fun) ((int)(-1UL)) +#define MSH_OPT_DUMP(fun) do{}while(0) #endif extern struct finsh_syscall_item *global_syscall_list;