FINSH: 优化MSH宏定义 (#8251)
This commit is contained in:
parent
0b1a49ed66
commit
b80a455b34
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue