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) \
|
#define _MSH_FUNCTION_CMD2(a0, a1) \
|
||||||
MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, 0)
|
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)
|
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) \
|
#define _MSH_FUNCTION_EXPORT_CMD3(a0, a1, a2) \
|
||||||
MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, 0)
|
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)
|
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
|
* @ingroup finsh
|
||||||
@ -135,15 +130,9 @@ typedef long (*syscall_func)(void);
|
|||||||
* @param opt This is an option, enter any content to enable option completion
|
* @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) */
|
/* MSH_CMD_EXPORT(command, desc) or MSH_CMD_EXPORT(command, desc, opt) */
|
||||||
#ifdef FINSH_USING_OPTION_COMPLETION
|
|
||||||
#define MSH_CMD_EXPORT(...) \
|
#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__)
|
_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
|
* @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) or
|
||||||
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt) */
|
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt) */
|
||||||
#ifdef FINSH_USING_OPTION_COMPLETION
|
|
||||||
#define MSH_CMD_EXPORT_ALIAS(...) \
|
#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__)
|
_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 */
|
/* system call table */
|
||||||
struct finsh_syscall
|
struct finsh_syscall
|
||||||
@ -191,9 +174,9 @@ struct finsh_syscall_item
|
|||||||
#ifdef FINSH_USING_OPTION_COMPLETION
|
#ifdef FINSH_USING_OPTION_COMPLETION
|
||||||
typedef struct msh_cmd_opt
|
typedef struct msh_cmd_opt
|
||||||
{
|
{
|
||||||
rt_uint32_t id;
|
rt_uint32_t id;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *des;
|
const char *des;
|
||||||
} msh_cmd_opt_t;
|
} msh_cmd_opt_t;
|
||||||
|
|
||||||
#define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[];
|
#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_START(command)
|
||||||
#define CMD_OPTIONS_NODE(_id, _name, _des)
|
#define CMD_OPTIONS_NODE(_id, _name, _des)
|
||||||
#define CMD_OPTIONS_NODE_END
|
#define CMD_OPTIONS_NODE_END
|
||||||
|
#define MSH_OPT_ID_GET(fun) ((int)(-1UL))
|
||||||
|
#define MSH_OPT_DUMP(fun) do{}while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern struct finsh_syscall_item *global_syscall_list;
|
extern struct finsh_syscall_item *global_syscall_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user