Skip to content

Commit

Permalink
Merge pull request FRRouting#16501 from donaldsharp/preprocess_vtysh
Browse files Browse the repository at this point in the history
Preprocess vtysh
  • Loading branch information
mjstapp authored Aug 2, 2024
2 parents e38dfe0 + 4bc4119 commit 975e1a3
Show file tree
Hide file tree
Showing 15 changed files with 544 additions and 203 deletions.
15 changes: 10 additions & 5 deletions lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,11 @@ struct cmd_node {
/* Argc max counts. */
#define CMD_ARGC_MAX 256

/* clang-format off */

/* helper defines for end-user DEFUN* macros */
#define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
static const struct cmd_element cmdname = { \
const struct cmd_element cmdname = { \
.string = cmdstr, \
.func = funcname, \
.doc = helpstr, \
Expand All @@ -281,7 +283,7 @@ struct cmd_node {
/* DEFPY variants */

#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
static DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
funcdecl_##funcname

#define DEFPY(funcname, cmdname, cmdstr, helpstr) \
Expand All @@ -308,7 +310,7 @@ struct cmd_node {

#define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_FUNC_DECL(funcname) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
static DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
DEFUN_CMD_FUNC_TEXT(funcname)

#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
Expand Down Expand Up @@ -345,7 +347,8 @@ struct cmd_node {
/* DEFUN + DEFSH */
#define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_FUNC_DECL(funcname) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \
static DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, \
daemon) \
DEFUN_CMD_FUNC_TEXT(funcname)

#define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \
Expand All @@ -357,7 +360,7 @@ struct cmd_node {

/* ALIAS macro which define existing command's alias. */
#define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)
static DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)

#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, 0)
Expand All @@ -376,6 +379,8 @@ struct cmd_node {
#define ALIAS_YANG(funcname, cmdname, cmdstr, helpstr) \
ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG)

/* clang-format on */

/* Some macroes */

/*
Expand Down
3 changes: 3 additions & 0 deletions lib/command_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ static bool cmd_nodes_equal(struct graph_node *ga, struct graph_node *gb)
case NEG_ONLY_TKN:
case WORD_TKN:
case ASNUM_TKN:
#ifdef BUILDING_CLIPPY
case CMD_ELEMENT_TKN:
#endif
return true;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/command_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ enum cmd_token_type {
END_TKN, // last token in line
NEG_ONLY_TKN, // filter token, match if "no ..." command

#ifdef BUILDING_CLIPPY
CMD_ELEMENT_TKN, // python bindings only
#endif
SPECIAL_TKN = FORK_TKN,
};
/* clang-format on */
Expand Down
Loading

0 comments on commit 975e1a3

Please sign in to comment.