summaryrefslogtreecommitdiff
path: root/lib/frrscript.h
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-07-23 17:03:42 +0800
committerDonald Lee <dlqs@gmx.com>2021-07-23 20:43:24 +0800
commit70d995abd4e6938dcdaccc61a6f9cd66946d99d1 (patch)
tree9e5498605aa654ba18a7b1722bfae0e9f400f85a /lib/frrscript.h
parent59a35b667d4f592f284e7c13db9123b7eb6379b6 (diff)
lib: Comment on how macro works
Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrscript.h')
-rw-r--r--lib/frrscript.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/frrscript.h b/lib/frrscript.h
index e76d14c1f4..8f5b9f9cf8 100644
--- a/lib/frrscript.h
+++ b/lib/frrscript.h
@@ -122,8 +122,22 @@ void frrscript_register_type_codecs(struct frrscript_codec *codecs);
*/
void frrscript_init(const char *scriptdir);
+/*
+ * This macro is mapped to every (name, value) in frrscript_call,
+ * so this in turn maps them onto their encoders
+ */
#define ENCODE_ARGS(name, value) ENCODE_ARGS_WITH_STATE(lfs->L, value)
+/*
+ * This macro is also mapped to every (name, value) in frrscript_call, but
+ * not every value can be mapped to its decoder - only those that appear
+ * in the returned table will. To find out if they appear in the returned
+ * table, first pop the value and check if its nil. Only call the decoder
+ * if non-nil.
+ *
+ * At the end, the only thing left on the stack should be the
+ * returned table.
+ */
#define DECODE_ARGS(name, value) \
do { \
lua_getfield(lfs->L, 1, name); \