Skip to content

Commit

Permalink
remove excessive indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanlang committed Jan 16, 2024
1 parent 631771e commit 3627f69
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 94 deletions.
78 changes: 39 additions & 39 deletions docs/libraries/adding-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions docs/luaPortDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +21,7 @@ implemented using the following convention:


```
param.<param_type> "<NAME>"
param.<param_type> "<NAME>"
```

The parameter type can be any of Int32, Float64, or Octet, each corresponding
Expand All @@ -36,9 +36,9 @@ used to bind lua code to reading and writing callbacks.


```
param.<param_type>.<read/write> "NAME" [[
CODE
]]
param.<param_type>.<read/write> "NAME" [[
CODE
]]
```

The same parameter type and name conventions remain, but the definition now
Expand All @@ -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)
]]
```


Expand Down
2 changes: 1 addition & 1 deletion docs/luascriptRecord.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ specification


```
field(DTYP,"Soft Channel")
field(DTYP,"Soft Channel")
```

Operator Display Parameters
Expand Down
88 changes: 44 additions & 44 deletions docs/using-lua-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
}
```

0 comments on commit 3627f69

Please sign in to comment.