shell: Deprecate macros for subcommands creation

Macros are replaced by C++ friendly versions:
- SHELL_CREATE_STATIC_SUBCMD_SET by SHELL_STATIC_SUBCMD_SET_CREATE
- SHELL_CREATE_DYNAMIC_CMD by SHELL_DYNAMIC_CMD_CREATE

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2019-02-13 14:58:26 +01:00 committed by Anas Nashif
commit a64b0fe1e3
5 changed files with 13 additions and 11 deletions

View file

@ -177,12 +177,14 @@ struct shell_static_entry {
} }
/** /**
* @brief Macro for creating a subcommand set. It must be used outside of any * @brief Deprecated macro for creating a subcommand set.
* function body. *
* It must be used outside of any function body.
* *
* @param[in] name Name of the subcommand set. * @param[in] name Name of the subcommand set.
*/ */
#define SHELL_CREATE_STATIC_SUBCMD_SET(name) \ #define SHELL_CREATE_STATIC_SUBCMD_SET(name) \
__DEPRECATED_MACRO \
static const struct shell_static_entry shell_##name[]; \ static const struct shell_static_entry shell_##name[]; \
static const struct shell_cmd_entry name = { \ static const struct shell_cmd_entry name = { \
.is_dynamic = false, \ .is_dynamic = false, \
@ -210,13 +212,13 @@ struct shell_static_entry {
} }
/** /**
* @brief Macro for creating a dynamic entry. * @brief Deprecated macro for creating a dynamic entry.
* *
* @param[in] name Name of the dynamic entry. * @param[in] name Name of the dynamic entry.
* @param[in] get Pointer to the function returning dynamic commands array * @param[in] get Pointer to the function returning dynamic commands array
*/ */
#define SHELL_CREATE_DYNAMIC_CMD(name, get) \ #define SHELL_CREATE_DYNAMIC_CMD(name, get) \
SHELL_DYNAMIC_CMD_CREATE(name, get) __DEPRECATED_MACRO SHELL_DYNAMIC_CMD_CREATE(name, get)
/** /**
* @brief Initializes a shell command with arguments. * @brief Initializes a shell command with arguments.

View file

@ -155,7 +155,7 @@ static void dynamic_cmd_get(size_t idx, struct shell_static_entry *entry)
} }
} }
SHELL_CREATE_DYNAMIC_CMD(m_sub_dynamic_set, dynamic_cmd_get); SHELL_DYNAMIC_CMD_CREATE(m_sub_dynamic_set, dynamic_cmd_get);
SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_dynamic, SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_dynamic,
SHELL_CMD_ARG(add, NULL, SHELL_CMD_ARG(add, NULL,
"Add a new dynamic command.\nExample usage: [ dynamic add test " "Add a new dynamic command.\nExample usage: [ dynamic add test "

View file

@ -266,7 +266,7 @@ static int cmd_log_backend_disable(const struct shell *shell,
static void module_name_get(size_t idx, struct shell_static_entry *entry); static void module_name_get(size_t idx, struct shell_static_entry *entry);
SHELL_CREATE_DYNAMIC_CMD(dsub_module_name, module_name_get); SHELL_DYNAMIC_CMD_CREATE(dsub_module_name, module_name_get);
static void module_name_get(size_t idx, struct shell_static_entry *entry) static void module_name_get(size_t idx, struct shell_static_entry *entry)
{ {
@ -286,7 +286,7 @@ static void severity_lvl_get(size_t idx, struct shell_static_entry *entry)
severity_lvls_sorted[idx] : NULL; severity_lvls_sorted[idx] : NULL;
} }
SHELL_CREATE_DYNAMIC_CMD(dsub_severity_lvl, severity_lvl_get); SHELL_DYNAMIC_CMD_CREATE(dsub_severity_lvl, severity_lvl_get);
static int log_halt(const struct shell *shell, static int log_halt(const struct shell *shell,
const struct log_backend *backend, const struct log_backend *backend,
@ -394,7 +394,7 @@ static void backend_name_get(size_t idx, struct shell_static_entry *entry)
} }
} }
SHELL_CREATE_DYNAMIC_CMD(dsub_backend_name_dynamic, backend_name_get); SHELL_DYNAMIC_CMD_CREATE(dsub_backend_name_dynamic, backend_name_get);
SHELL_STATIC_SUBCMD_SET_CREATE(sub_log_stat, SHELL_STATIC_SUBCMD_SET_CREATE(sub_log_stat,

View file

@ -3637,7 +3637,7 @@ static char *set_iface_index_help(size_t idx)
static void iface_index_get(size_t idx, struct shell_static_entry *entry); static void iface_index_get(size_t idx, struct shell_static_entry *entry);
SHELL_CREATE_DYNAMIC_CMD(iface_index, iface_index_get); SHELL_DYNAMIC_CMD_CREATE(iface_index, iface_index_get);
static void iface_index_get(size_t idx, struct shell_static_entry *entry) static void iface_index_get(size_t idx, struct shell_static_entry *entry)
{ {
@ -3712,7 +3712,7 @@ static char *set_nbr_address(size_t idx)
static void nbr_address_get(size_t idx, struct shell_static_entry *entry); static void nbr_address_get(size_t idx, struct shell_static_entry *entry);
SHELL_CREATE_DYNAMIC_CMD(nbr_address, nbr_address_get); SHELL_DYNAMIC_CMD_CREATE(nbr_address, nbr_address_get);
#define NBR_ADDRESS_CMD &nbr_address #define NBR_ADDRESS_CMD &nbr_address

View file

@ -268,7 +268,7 @@ static void dynamic_cmd_get(size_t idx, struct shell_static_entry *entry)
} }
} }
SHELL_CREATE_DYNAMIC_CMD(m_sub_test_dynamic, dynamic_cmd_get); SHELL_DYNAMIC_CMD_CREATE(m_sub_test_dynamic, dynamic_cmd_get);
SHELL_CMD_REGISTER(test_dynamic, &m_sub_test_dynamic, NULL, cmd_dynamic); SHELL_CMD_REGISTER(test_dynamic, &m_sub_test_dynamic, NULL, cmd_dynamic);