1 /* $NetBSD: linit.c,v 1.2 2013/12/02 04:57:41 lneto Exp $ */ 2 3 /* 4 ** $Id: linit.c,v 1.2 2013/12/02 04:57:41 lneto Exp $ 5 ** Initialization of libraries for lua.c 6 ** See Copyright Notice in lua.h 7 */ 8 9 10 #define linit_c 11 #define LUA_LIB 12 13 #include "lua.h" 14 15 #include "lualib.h" 16 #include "lauxlib.h" 17 18 19 static const luaL_Reg lualibs[] = { 20 {"", luaopen_base}, 21 #ifndef _KERNEL 22 {LUA_LOADLIBNAME, luaopen_package}, 23 #endif 24 {LUA_TABLIBNAME, luaopen_table}, 25 #ifndef _KERNEL 26 {LUA_IOLIBNAME, luaopen_io}, 27 {LUA_OSLIBNAME, luaopen_os}, 28 #endif 29 {LUA_STRLIBNAME, luaopen_string}, 30 #ifndef _KERNEL 31 {LUA_MATHLIBNAME, luaopen_math}, 32 {LUA_DBLIBNAME, luaopen_debug}, 33 #endif 34 {NULL, NULL} 35 }; 36 37 38 LUALIB_API void luaL_openlibs (lua_State *L) { 39 const luaL_Reg *lib = lualibs; 40 for (; lib->func; lib++) { 41 lua_pushcfunction(L, lib->func); 42 lua_pushstring(L, lib->name); 43 lua_call(L, 1, 0); 44 } 45 } 46 47