diff --git a/docs/libraries/adding-libraries.md b/docs/libraries/adding-libraries.md index 551c70e..675e58f 100644 --- a/docs/libraries/adding-libraries.md +++ b/docs/libraries/adding-libraries.md @@ -27,7 +27,7 @@ wildcard character with the library name you are looking for and check to see if that file exists. So, a package.cpath that is set as ``` - "./?.so;/usr/local/?/init.so" +"./?.so;/usr/local/?/init.so" ``` would try to search for the files ./foo.so and /usr/local/foo/init.so @@ -43,31 +43,31 @@ You just provide it with a list of pairs of function names and function pointers like so: ```c++ - static int l_bar( lua_State *L ) - { - lua_pushstring(L, "Hello, World"); - return 1; - } - - int luaopen_foo( lua_State *L ) - { - static const luaL_Reg foo[] = { - { "bar", l_bar }, - { NULL, NULL } /* Sentinel item */ - }; - - luaL_newlib( L, foo ); - return 1; - } +static int l_bar( lua_State *L ) +{ + lua_pushstring(L, "Hello, World"); + return 1; +} + +int luaopen_foo( lua_State *L ) +{ + static const luaL_Reg foo[] = { + { "bar", l_bar }, + { NULL, NULL } /* Sentinel item */ + }; + + luaL_newlib( L, foo ); + return 1; +} ``` Then you can use the above library like so: ```lua - foo = require("foo") +foo = require("foo") - print(foo.bar()) +print(foo.bar()) ``` Note that luaopen_foo just returns a table with all the functions @@ -93,21 +93,21 @@ the shell is to use the dbd’s registrar function. **foo.cpp** ```c++ - static void fooRegister(void) - { - luaRegisterLibrary("foo", luaopen_foo); - } - - extern "C" - { - epicsExportRegistrar(fooRegister); - } +static void fooRegister(void) +{ + luaRegisterLibrary("foo", luaopen_foo); +} + +extern "C" +{ + epicsExportRegistrar(fooRegister); +} ``` **foo.dbd** ``` - registrar(fooRegister) +registrar(fooRegister) ``` Then when you load the dbd file into your IOC, lua is given the link @@ -137,16 +137,16 @@ directly. **Example:** ```c++ - static int l_bar( lua_State *L ) - { - lua_pushstring(L, "Hello, World"); - return 1; - } - - static void testRegister(void) - { - luaRegisterFunction("bar", l_bar); - } +static int l_bar( lua_State *L ) +{ + lua_pushstring(L, "Hello, World"); + return 1; +} + +static void testRegister(void) +{ + luaRegisterFunction("bar", l_bar); +} ``` Then, you can call the function bar in the lua shell. Since these diff --git a/docs/luaPortDriver.md b/docs/luaPortDriver.md index be0006c..e9effd0 100644 --- a/docs/luaPortDriver.md +++ b/docs/luaPortDriver.md @@ -12,7 +12,7 @@ This function takes in the name of an asyn port, a lua script, and a string of macro definitions. An example of a luaPortDriver function call is shown below: ``` - luaPortDriver("EXAMPLE", "exampleDriver.lua", "VAL=10") +luaPortDriver("EXAMPLE", "exampleDriver.lua", "VAL=10") ``` An asynPortDriver is created with the given asyn port name and the lua script @@ -21,7 +21,7 @@ implemented using the following convention: ``` - param. "" +param. "" ``` The parameter type can be any of Int32, Float64, or Octet, each corresponding @@ -36,9 +36,9 @@ used to bind lua code to reading and writing callbacks. ``` - param.. "NAME" [[ - CODE - ]] +param.. "NAME" [[ + CODE +]] ``` The same parameter type and name conventions remain, but the definition now @@ -60,12 +60,12 @@ calculation of the length of a hypotenuse: ``` - param.int32 "BASE" - param.int32 "SIDE" +param.int32 "BASE" +param.int32 "SIDE" - param.float64.read "HYPOTENUSE" [[ - return math.sqrt(self["BASE"]^2 + self["SIDE"]^2) - ]] +param.float64.read "HYPOTENUSE" [[ + return math.sqrt(self["BASE"]^2 + self["SIDE"]^2) +]] ``` diff --git a/docs/luascriptRecord.md b/docs/luascriptRecord.md index 747126b..2df47dd 100644 --- a/docs/luascriptRecord.md +++ b/docs/luascriptRecord.md @@ -227,7 +227,7 @@ specification ``` - field(DTYP,"Soft Channel") +field(DTYP,"Soft Channel") ``` Operator Display Parameters diff --git a/docs/using-lua-shell.md b/docs/using-lua-shell.md index 8f822e8..7030e97 100644 --- a/docs/using-lua-shell.md +++ b/docs/using-lua-shell.md @@ -21,14 +21,14 @@ be treated as if they were defined lua functions. ``` - luash> EPICS_VERSION_MAJOR - 7 - luash> - luash> epicsEnvShow - func_meta: 0x673150 - luash> - luash> epicsEnvShow("EPICS_VERSION_MAJOR") - EPICS_VERSION_MAJOR=7 +luash> EPICS_VERSION_MAJOR +7 +luash> +luash> epicsEnvShow +func_meta: 0x673150 +luash> +luash> epicsEnvShow("EPICS_VERSION_MAJOR") +EPICS_VERSION_MAJOR=7 ``` As well, the special directive '#ENABLE_HASH_COMMENTS' is provided. While lua normally @@ -40,12 +40,12 @@ operations. ``` - luash> #ENABLE_HASH_COMMENTS - Accepting iocsh-style comments - luash> - luash> #print("This won't print") - luash> print(#"Check len") - 9 +luash> #ENABLE_HASH_COMMENTS +Accepting iocsh-style comments +luash> +luash> #print("This won't print") +luash> print(#"Check len") +9 ``` Calling the Lua Shell From Inside The IOC Shell @@ -75,7 +75,7 @@ include other scripts by using the ‘<’ character. Putting ``` - < script.lua +< script.lua ``` Will attempt to find script.lua by the same process as detailed above @@ -90,9 +90,9 @@ above, and the file had the following code within it ```lua - if (true) then - exit - end +if (true) then + exit +end ``` That exit will end the reading of just the script.lua file and flow would @@ -111,18 +111,18 @@ same parameters apply as when calling the command inside the IOC shell. So your main.cpp file might look like: ```c++ - #include "luaShell.h" - - int main(int argc,char *argv[]) - { - if(argc>=2) { - luash(argv[1]); - epicsThreadSleep(.2); - } - luash(NULL); - epicsExit(0); - return(0); - } +#include "luaShell.h" + +int main(int argc,char *argv[]) +{ + if(argc>=2) { + luash(argv[1]); + epicsThreadSleep(.2); + } + luash(NULL); + epicsExit(0); + return(0); +} ``` Common Lua Environments @@ -146,18 +146,18 @@ above code changed to allow the interactive shell to reference code from the interpreted script would look like: ```c++ - #include "luaShell.h" - - int main(int argc,char *argv[]) - { - luashSetCommonState("default"); - - if(argc>=2) { - luash(argv[1]); - epicsThreadSleep(.2); - } - luash(NULL); - epicsExit(0); - return(0); - } +#include "luaShell.h" + +int main(int argc,char *argv[]) +{ + luashSetCommonState("default"); + + if(argc>=2) { + luash(argv[1]); + epicsThreadSleep(.2); + } + luash(NULL); + epicsExit(0); + return(0); +} ```