1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/lua_loader/cmodules.c
Juan Carrano 913f74b90b tests/lua_loader: test the RIOT-customized lua loader.
For the RIOT port of Lua, the module loader has been more or less
rewritten to allow for easily integrating source modules defined in static
arrays and C modules embedded in the application.

So  far the loader had not been tested (and a bug was found). This test
should give a bit more certainty that the RIOT integration works as it
should.
2019-05-31 17:16:06 +02:00

56 lines
1.0 KiB
C

/*
* Copyright (C) 2019 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
* @brief Define a couple of dummy lua extension modules
*
* @author Juan Carrano <j.carrano@fu-berlin.de>
*
* Normally one would not define more than one module in a single file, but
* these modules are exacly the same: a single table with an integer value.
*
* @}
*/
#define LUA_LIB
#include "lprefix.h"
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
static const luaL_Reg funcs[] = {
/* placeholder */
{ "X", NULL },
{ NULL, NULL }
};
static int _luaopen_X(lua_State *L, const char *xstring)
{
luaL_newlib(L, funcs);
lua_pushstring(L, xstring);
lua_setfield(L, -2, "X");
return 1;
}
int _luaopen_hello(lua_State *L)
{
return _luaopen_X(L, "E se deixa no céu,");
}
int _luaopen_world(lua_State *L)
{
return _luaopen_X(L, "como esquecida");
}