interp_lua: Register io/loader with regular Lua module system
Reviewed by: kevans Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14421
This commit is contained in:
parent
faf2ee299c
commit
6771d4a815
@ -85,6 +85,8 @@ static const luaL_Reg loadedlibs[] = {
|
||||
// {LUA_MATHLIBNAME, luaopen_math},
|
||||
// {LUA_UTF8LIBNAME, luaopen_utf8},
|
||||
// {LUA_DBLIBNAME, luaopen_debug},
|
||||
{"io", luaopen_io},
|
||||
{"loader", luaopen_loader},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@ -105,7 +107,6 @@ interp_init(void)
|
||||
abort();
|
||||
}
|
||||
softc->luap = luap;
|
||||
register_utils(luap);
|
||||
|
||||
/* "require" functions from 'loadedlibs' and set results to global table */
|
||||
for (lib = loadedlibs; lib->func; lib++) {
|
||||
|
@ -233,11 +233,15 @@ static const struct luaL_Reg iolib[] = {
|
||||
};
|
||||
#undef REG_SIMPLE
|
||||
|
||||
void
|
||||
register_utils(lua_State *L)
|
||||
int
|
||||
luaopen_loader(lua_State *L)
|
||||
{
|
||||
luaL_newlib(L, loaderlib);
|
||||
lua_setglobal(L, "loader");
|
||||
luaL_newlib(L, iolib);
|
||||
lua_setglobal(L, "io");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
luaopen_io(lua_State *L)
|
||||
{
|
||||
luaL_newlib(L, iolib);
|
||||
return 1;
|
||||
|
@ -28,4 +28,5 @@
|
||||
|
||||
#include <lua.h>
|
||||
|
||||
void register_utils(lua_State *);
|
||||
int luaopen_loader(lua_State *);
|
||||
int luaopen_io(lua_State *);
|
||||
|
Loading…
Reference in New Issue
Block a user