2014-12-22 12:35:05 +01:00
|
|
|
/*
|
|
|
|
** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
|
|
|
|
** Initialization of libraries for lua.c
|
|
|
|
** See Copyright Notice in lua.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#define linit_c
|
|
|
|
#define LUA_LIB
|
2015-09-01 07:11:36 +02:00
|
|
|
#define LUAC_CROSS_FILE
|
2014-12-22 12:35:05 +01:00
|
|
|
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
#include "lualib.h"
|
|
|
|
#include "lauxlib.h"
|
|
|
|
#include "luaconf.h"
|
2015-12-16 06:04:58 +01:00
|
|
|
#include "module.h"
|
2014-12-22 12:35:05 +01:00
|
|
|
|
2015-03-06 04:59:04 +01:00
|
|
|
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB_INIT( BASE, "", luaopen_base);
|
|
|
|
BUILTIN_LIB_INIT( LOADLIB, LUA_LOADLIBNAME, luaopen_package);
|
2014-12-22 12:35:05 +01:00
|
|
|
|
2015-03-06 08:55:24 +01:00
|
|
|
#if defined(LUA_USE_BUILTIN_IO)
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB_INIT( IO, LUA_IOLIBNAME, luaopen_io);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
2015-12-16 06:04:58 +01:00
|
|
|
#if defined (LUA_USE_BUILTIN_STRING)
|
2014-12-22 12:35:05 +01:00
|
|
|
extern const luaR_entry strlib[];
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB_INIT( STRING, LUA_STRLIBNAME, luaopen_string);
|
|
|
|
BUILTIN_LIB( STRING, LUA_STRLIBNAME, strlib);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(LUA_USE_BUILTIN_TABLE)
|
2014-12-22 12:35:05 +01:00
|
|
|
extern const luaR_entry tab_funcs[];
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB_INIT( TABLE, LUA_TABLIBNAME, luaopen_table);
|
|
|
|
BUILTIN_LIB( TABLE, LUA_TABLIBNAME, tab_funcs);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
2015-08-31 13:18:57 +02:00
|
|
|
#if defined(LUA_USE_BUILTIN_DEBUG) || defined(LUA_USE_BUILTIN_DEBUG_MINIMAL)
|
2015-03-06 08:55:24 +01:00
|
|
|
extern const luaR_entry dblib[];
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB_INIT( DBG, LUA_DBLIBNAME, luaopen_debug);
|
|
|
|
BUILTIN_LIB( DBG, LUA_DBLIBNAME, dblib);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(LUA_USE_BUILTIN_OS)
|
|
|
|
extern const luaR_entry syslib[];
|
|
|
|
BUILTIN_LIB( OS, LUA_OSLIBNAME, syslib);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(LUA_USE_BUILTIN_COROUTINE)
|
2014-12-22 12:35:05 +01:00
|
|
|
extern const luaR_entry co_funcs[];
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB( CO, LUA_COLIBNAME, co_funcs);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(LUA_USE_BUILTIN_MATH)
|
|
|
|
extern const luaR_entry math_map[];
|
2015-12-16 06:04:58 +01:00
|
|
|
BUILTIN_LIB( MATH, LUA_MATHLIBNAME, math_map);
|
2015-03-06 08:55:24 +01:00
|
|
|
#endif
|
|
|
|
|
2015-12-16 06:04:58 +01:00
|
|
|
extern const luaL_Reg lua_libs[];
|
|
|
|
|
|
|
|
void luaL_openlibs (lua_State *L) {
|
|
|
|
const luaL_Reg *lib = lua_libs;
|
|
|
|
for (; lib->name; lib++) {
|
|
|
|
if (lib->func)
|
|
|
|
{
|
|
|
|
lua_pushcfunction(L, lib->func);
|
|
|
|
lua_pushstring(L, lib->name);
|
|
|
|
lua_call(L, 1, 0);
|
|
|
|
}
|
2014-12-22 12:35:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|