]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add comments for functions
authorDonald Lee <dlqs@gmx.com>
Thu, 24 Jun 2021 16:05:37 +0000 (00:05 +0800)
committerDonald Lee <dlqs@gmx.com>
Fri, 25 Jun 2021 09:29:15 +0000 (17:29 +0800)
Signed-off-by: Donald Lee <dlqs@gmx.com>
lib/compiler.h
lib/frrlua.c
lib/frrscript.h

index 155ffc60036461af0dc9fda74872322de0f6f90d..a6fd858518b36ebc651e006d9a087fe2cc35a747 100644 (file)
@@ -174,11 +174,10 @@ extern "C" {
        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__
@@ -196,6 +195,7 @@ extern "C" {
        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")
index 36f1797473445449b0b44371203619bc4ed9791f..e97e48121c8aba1be0e7f944da18425b4b1e69d5 100644 (file)
@@ -52,10 +52,9 @@ int frrlua_table_get_integer(lua_State *L, const char *key)
 }
 
 /*
- * 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)
@@ -303,6 +302,9 @@ void *lua_tostringp(lua_State *L, int idx)
        return string;
 }
 
+/*
+ * Decoder for const values, since we cannot modify them.
+ */
 void lua_decode_noop(lua_State *L, int idx, const void *ptr)
 {
 }
index 502921539af1f25cd98bf3bc93493540c4cfb2de..8612c602f3ca317a2115186b54720f48bfec487d 100644 (file)
@@ -109,6 +109,15 @@ void frrscript_init(const char *scriptdir);
                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,                                 \
@@ -145,14 +154,21 @@ const struct prefix * : lua_decode_noop                         \
  * 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;                                          \