[riot-notifications] [RIOT-OS/RIOT] pkg/lua: Make the module searchers conform to the API. (#9726)

Leandro Lanzieri notifications at github.com
Fri May 31 09:17:47 CEST 2019


leandrolanzieri requested changes on this pull request.

Changes make sense. I noticed a change of behaviour compared to master, when trying to require a module that is not defined:

**On current master**
```
main(): This is RIOT! (Version: 2019.07-devel-527-gd1f06)
Using memory range for Lua heap: 0x56614090 - 0x5661dcd0, 4 bytes
This is Lua: starting interactive session

Welcome to the interactive interpreter
L> require "something"
Runtime error   Module 'something' not found in Lua-builtins
L> 
L> 
```

**With this PR**
```
main(): This is RIOT! (Version: 2019.07-devel-519-g18a38-lua-loader-fix)
Using memory range for Lua heap: 0x5668e090 - 0x56697cd0, 4 bytes
This is Lua: starting interactive session

Welcome to the interactive interpreter
L> require "something"
/home/leandro/Work/RIOT/examples/lua_REPL/../../Makefile.include:557: recipe for target 'term' failed
make: *** [term] Segmentation fault (core dumped)
```
Also, some minor comments.

> +#define LUA_MEM_SIZE (11000)
+static char lua_mem[LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__)));
+
+#define LINEBUF_SZ (32)
+static char linebuf[LINEBUF_SZ];
+
+int main(void)
+{
+    int status;
+    status = lua_riot_do_module("test", lua_mem, LUA_MEM_SIZE,
+                                        LUAR_LOAD_BASE, NULL);
+
+    assert(status == LUAR_EXIT);
+
+    while (fgets(linebuf, LINEBUF_SZ, stdin) != NULL) {
+        int status;//, value;

Please remove the comment

> @@ -0,0 +1,17 @@
+include ../Makefile.tests_common
+
+USEPKG += lua
+# USEMODULE +=

There is an extra comment here.

> +const size_t lua_riot_builtin_lua_table_len =
+    sizeof(_lua_riot_builtin_lua_table)/sizeof(*_lua_riot_builtin_lua_table);
+const size_t lua_riot_builtin_c_table_len =
+     sizeof(_lua_riot_builtin_c_table)/sizeof(*_lua_riot_builtin_c_table);
+
+#define LUA_MEM_SIZE (11000)
+static char lua_mem[LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__)));
+
+#define LINEBUF_SZ (32)
+static char linebuf[LINEBUF_SZ];
+
+int main(void)
+{
+    int status;
+    status = lua_riot_do_module("test", lua_mem, LUA_MEM_SIZE,
+                                        LUAR_LOAD_BASE, NULL);

Please align properly.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/9726#pullrequestreview-243470311
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190531/2e0fefc3/attachment-0001.html>


More information about the notifications mailing list