Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define linit_c
00017 #define LUA_LIB
00018
00019 #include "lua.h"
00020
00021 #include "lualib.h"
00022 #include "lauxlib.h"
00023
00024
00025
00026
00027
00028
00029 static const luaL_Reg loadedlibs[] = {
00030 {"_G", luaopen_base},
00031 {LUA_LOADLIBNAME, luaopen_package},
00032 {LUA_COLIBNAME, luaopen_coroutine},
00033 {LUA_TABLIBNAME, luaopen_table},
00034 {LUA_IOLIBNAME, luaopen_io},
00035 {LUA_OSLIBNAME, luaopen_os},
00036 {LUA_STRLIBNAME, luaopen_string},
00037 {LUA_BITLIBNAME, luaopen_bit32},
00038 {LUA_MATHLIBNAME, luaopen_math},
00039 {LUA_DBLIBNAME, luaopen_debug},
00040 {NULL, NULL}
00041 };
00042
00043
00044
00045
00046
00047 static const luaL_Reg preloadedlibs[] = {
00048 {NULL, NULL}
00049 };
00050
00051
00052 LUALIB_API void luaL_openlibs (lua_State *L) {
00053 const luaL_Reg *lib;
00054
00055 for (lib = loadedlibs; lib->func; lib++) {
00056 luaL_requiref(L, lib->name, lib->func, 1);
00057 lua_pop(L, 1);
00058 }
00059
00060 luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
00061 for (lib = preloadedlibs; lib->func; lib++) {
00062 lua_pushcfunction(L, lib->func);
00063 lua_setfield(L, -2, lib->name);
00064 }
00065 lua_pop(L, 1);
00066 }
00067