lib: Add polymorphic noop macro

Co-authored-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Donald Lee <dlqs@gmx.com>
This commit is contained in:
Donald Lee 2021-08-10 04:36:30 +08:00 committed by Quentin Young
parent 83cbdcc267
commit 2faab06ed3
2 changed files with 8 additions and 7 deletions

View File

@ -25,6 +25,8 @@ DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting");
struct frrscript_names_head frrscript_names_hash;
void _lua_decode_noop(lua_State *L, ...) {}
/*
* Wrapper for frrscript_names_add
* Use this to register hook calls when a daemon starts up

View File

@ -180,6 +180,11 @@ void frrscript_fini(void);
assert(lua_gettop(lfs->L) == 1); \
} while (0)
/*
* Noop function. Used below where we need a noop decoder for any type.
*/
void _lua_decode_noop(lua_State *, ...);
/*
* Maps the type of value to its encoder/decoder.
* Add new mappings here.
@ -220,13 +225,7 @@ struct in6_addr * : lua_decode_in6addr, \
union sockunion * : lua_decode_sockunion, \
char * : lua_decode_stringp, \
struct attr * : lua_decode_attr, \
struct peer * : lua_decode_noop, \
const struct prefix * : lua_decode_noop, \
const struct ipaddr * : lua_decode_noop, \
const struct ethaddr * : lua_decode_noop, \
const struct nexthop_group * : lua_decode_noop, \
const struct nexthop * : lua_decode_noop, \
struct zebra_dplane_ctx * : lua_decode_noop \
default : _lua_decode_noop \
)((L), -1, (value))
/*