summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangqinglin <[email protected]>2023-11-15 13:54:22 +0800
committerGitHub <[email protected]>2023-11-15 13:54:22 +0800
commitb80a455b3459f5b104906159d37c90b25c1e3cf2 (patch)
tree7e413202550e76149f683be3957533d5df626d2e
parent0b1a49ed6615f5e47b1848a26b2f8733bfeb8334 (diff)
FINSH: 优化MSH宏定义 (#8251)
-rw-r--r--components/finsh/finsh.h33
1 files 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_FUNCTION_EXPORT_CMD3)(__VA_ARGS__)
-#else
#define MSH_CMD_EXPORT_ALIAS(...) \
- __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD4_NO_OPT, \
+ __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD3_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;