MACRO_VARIANT(_MACRO_REPEAT, ##__VA_ARGS__)(NAME, ##__VA_ARGS__)
/* per-arglist repeat macro, use like this:
- * #define SEP_SEMICOLON ;
- * #define foo(...) MAP_LISTS(F, SEP_SEMICOLON, ##__VA_ARGS__)
+ * #define foo(...) MAP_LISTS(F, ##__VA_ARGS__)
* where F is a n-ary function where n is the number of args in each arglist.
- * e.g.: MAP_LISTS(f, SEP_SEMICOLON, (a, b), (c, d, e))
- * expands to: f(a, b); f(c, d, e)
+ * e.g.: MAP_LISTS(f, (a, b), (c, d))
+ * expands to: f(a, b); f(c, d)
*/
#define ESC(...) __VA_ARGS__
ESC(M _1; M _2; M _3; M _4; M _5; M _6; M _7)
#define _MAP_LISTS_8(M, _1, _2, _3, _4, _5, _6, _7, _8) \
ESC(M _1; M _2; M _3; M _4; M _5; M _6; M _7; M _8)
+
/*
* for warnings on macros, put in the macro content like this:
* #define MACRO BLA CPP_WARN("MACRO has been deprecated")
}
/*
- * Encoders.
- *
* This section has functions that convert internal FRR datatypes into Lua
- * datatypes.
+ * datatypes: one encoder function and two decoder functions for each type.
+ *
*/
void lua_pushprefix(lua_State *L, const struct prefix *prefix)
return string;
}
+/*
+ * Decoder for const values, since we cannot modify them.
+ */
void lua_decode_noop(lua_State *L, int idx, const void *ptr)
{
}
DECODE_ARGS_WITH_STATE(L, value); \
} while (0)
+/*
+ * Maps the type of value to its encoder/decoder.
+ * Add new mappings here.
+ *
+ * L
+ * Lua state
+ * scriptdir
+ * Directory in which to look for scripts
+ */
#define ENCODE_ARGS_WITH_STATE(L, value) \
_Generic((value), \
long long * : lua_pushintegerp, \
* fs
* The script to call; this is obtained from frrscript_load().
*
- * env
- * The script's environment. Specify this as an array of frrscript_env.
- *
* Returns:
* 0 if the script ran successfully, nonzero otherwise.
*/
int _frrscript_call(struct frrscript *fs);
+/*
+ * Wrapper for call script. Maps values passed in to their encoder
+ * and decoder types.
+ *
+ * fs
+ * The script to call; this is obtained from frrscript_load().
+ *
+ * Returns:
+ * 0 if the script ran successfully, nonzero otherwise.
+ */
#define frrscript_call(fs, ...) \
({ \
lua_State *L = fs->L; \