diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2021-08-10 10:11:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-10 10:11:35 -0400 |
| commit | bde0fd77d9bc3bfbbd64222b210d1353f377a024 (patch) | |
| tree | 3c9694ebb21635e3702f0f0c64e73cc6365aea9f /doc/developer/scripting.rst | |
| parent | 227ffdfe61e4ee9901d03b426916fde920246c89 (diff) | |
| parent | 5141fd7f8e034081f3e1a2f391dd43d664c0412c (diff) | |
Merge pull request #9348 from dlqs/consecutive
lib: lua: consecutive script calls
Diffstat (limited to 'doc/developer/scripting.rst')
| -rw-r--r-- | doc/developer/scripting.rst | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/doc/developer/scripting.rst b/doc/developer/scripting.rst index d543ed3560..202f0036f8 100644 --- a/doc/developer/scripting.rst +++ b/doc/developer/scripting.rst @@ -117,6 +117,7 @@ Load The function to be called must first be loaded. Use ``frrscript_load()`` which takes a ``frrscript`` object, the name of the Lua function and a callback function. +The script file will be read to load and compile the function. For example, to load the Lua function ``on_foo`` in ``/etc/frr/scripts/bingus.lua``: @@ -138,7 +139,7 @@ should not be able to write the scripts directory anyway. Call ^^^^ -After loading, Lua functions may be called. +After loading, a Lua function can be called any number of times. Input """"" @@ -231,6 +232,18 @@ In the example, ``d`` is a "new" value in C space, so memory allocation might take place. Hence the caller is responsible for memory deallocation. +``frrscript_call()`` may be called multiple times without re-loading with +``frrscript_load()``. Results are not preserved between consecutive calls. + +.. code-block:: c + + frrscript_load(fs, "on_foo"); + + frrscript_call(fs, "on_foo"); + frrscript_get_result(fs, "on_foo", ...); + frrscript_call(fs, "on_foo"); + frrscript_get_result(fs, "on_foo", ...); + Delete ^^^^^^ @@ -385,7 +398,7 @@ Again, for ``struct prefix *``: { lua_getfield(L, idx, "network"); (void)str2prefix(lua_tostring(L, -1), prefix); - /* pop the netork string */ + /* pop the network string */ lua_pop(L, 1); /* pop the prefix table */ lua_pop(L, 1); |
