lib, python: DEFPY_ATTR, DEFPY_HIDDEN

Add support for element attributes in DEFPY macros.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2018-03-29 13:01:06 -04:00
parent e1a8a773a2
commit e31f4dbec6
No known key found for this signature in database
GPG Key ID: DAF48E0F57E0834F
3 changed files with 13 additions and 1 deletions

View File

@ -221,6 +221,13 @@ struct cmd_node {
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
funcdecl_##funcname
#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
funcdecl_##funcname
#define DEFPY_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_FUNC_DECL(funcname) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
@ -298,6 +305,9 @@ struct cmd_node {
#else /* VTYSH_EXTRACT_PL */
#define DEFPY(funcname, cmdname, cmdstr, helpstr) \
DEFUN(funcname, cmdname, cmdstr, helpstr)
#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr)
#endif /* VTYSH_EXTRACT_PL */
/* Some macroes */

View File

@ -132,6 +132,8 @@ SPECIAL [(),]
"DEFUN_NOSH" value = strdup(yytext); return DEFUNNY;
"DEFUN_HIDDEN" value = strdup(yytext); return DEFUNNY;
"DEFPY" value = strdup(yytext); return DEFUNNY;
"DEFPY_ATTR" value = strdup(yytext); return DEFUNNY;
"DEFPY_HIDDEN" value = strdup(yytext); return DEFUNNY;
"ALIAS" value = strdup(yytext); return DEFUNNY;
"ALIAS_HIDDEN" value = strdup(yytext); return DEFUNNY;
"install_element" value = strdup(yytext); return INSTALL;

View File

@ -186,7 +186,7 @@ def process_file(fn, ofd, dumpfd, all_defun):
filedata = clippy.parse(fn)
for entry in filedata['data']:
if entry['type'] == 'DEFPY' or (all_defun and entry['type'].startswith('DEFUN')):
if entry['type'].startswith('DEFPY') or (all_defun and entry['type'].startswith('DEFUN')):
cmddef = entry['args'][2]
cmddef = ''.join([i[1:-1] for i in cmddef])