summaryrefslogtreecommitdiff
path: root/src/lib_init.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib_init.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib_init.c b/src/lib_init.c
new file mode 100644
index 00000000..04ca60d9
--- /dev/null
+++ b/src/lib_init.c
@@ -0,0 +1,37 @@
1/*
2** Library initialization.
3** Major parts taken verbatim from the Lua interpreter.
4** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
5*/
6
7#define lib_init_c
8#define LUA_LIB
9
10#include "lua.h"
11#include "lauxlib.h"
12#include "lualib.h"
13
14static const luaL_Reg lualibs[] = {
15 { "", luaopen_base },
16 { LUA_LOADLIBNAME, luaopen_package },
17 { LUA_TABLIBNAME, luaopen_table },
18 { LUA_IOLIBNAME, luaopen_io },
19 { LUA_OSLIBNAME, luaopen_os },
20 { LUA_STRLIBNAME, luaopen_string },
21 { LUA_MATHLIBNAME, luaopen_math },
22 { LUA_DBLIBNAME, luaopen_debug },
23 { LUA_BITLIBNAME, luaopen_bit },
24 { LUA_JITLIBNAME, luaopen_jit },
25 { NULL, NULL }
26};
27
28LUALIB_API void luaL_openlibs(lua_State *L)
29{
30 const luaL_Reg *lib = lualibs;
31 for (; lib->func; lib++) {
32 lua_pushcfunction(L, lib->func);
33 lua_pushstring(L, lib->name);
34 lua_call(L, 1, 0);
35 }
36}
37