From 2b67227e6e69a0d5ce1831185f95182f8874ee37 Mon Sep 17 00:00:00 2001 From: Donald Lee Date: Sat, 17 Jul 2021 20:46:10 +0800 Subject: [PATCH] lib: Add int encoder/decoder Signed-off-by: Donald Lee --- lib/frrlua.c | 8 ++++++++ lib/frrlua.h | 4 +++- lib/frrscript.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/frrlua.c b/lib/frrlua.c index e97e48121c..710d9ece00 100644 --- a/lib/frrlua.c +++ b/lib/frrlua.c @@ -309,6 +309,14 @@ void lua_decode_noop(lua_State *L, int idx, const void *ptr) { } + +/* + * Noop decoder for int. + */ +void lua_decode_int_noop(lua_State *L, int idx, int i) +{ +} + /* * Logging. * diff --git a/lib/frrlua.h b/lib/frrlua.h index c4de82740c..2c86d87cbd 100644 --- a/lib/frrlua.h +++ b/lib/frrlua.h @@ -162,10 +162,12 @@ void lua_decode_stringp(lua_State *L, int idx, char *str); void *lua_tostringp(lua_State *L, int idx); /* - * No-op decocder + * No-op decocders */ void lua_decode_noop(lua_State *L, int idx, const void *ptr); +void lua_decode_int_noop(lua_State *L, int idx, int i); + /* * Retrieve an integer from table on the top of the stack. * diff --git a/lib/frrscript.h b/lib/frrscript.h index 905cda1a95..be6820bed5 100644 --- a/lib/frrscript.h +++ b/lib/frrscript.h @@ -142,6 +142,7 @@ void frrscript_init(const char *scriptdir); */ #define ENCODE_ARGS_WITH_STATE(L, value) \ _Generic((value), \ +int: lua_pushinteger, \ long long * : lua_pushintegerp, \ struct prefix * : lua_pushprefix, \ struct interface * : lua_pushinterface, \ @@ -157,6 +158,7 @@ const struct prefix * : lua_pushprefix \ #define DECODE_ARGS_WITH_STATE(L, value) \ _Generic((value), \ +int : lua_decode_int_noop, \ long long * : lua_decode_integerp, \ struct prefix * : lua_decode_prefix, \ struct interface * : lua_decode_interface, \ -- 2.39.5