Lua: Disabled debug library.

This commit is contained in:
Birunthan Mohanathas 2012-03-09 13:19:49 +00:00
parent ad2a986e88
commit e196ac08db
5 changed files with 26 additions and 8 deletions

View File

@ -29,9 +29,27 @@ void LuaManager::Initialize()
{ {
// Initialize Lua // Initialize Lua
c_State = lua_open(); c_State = lua_open();
// Load Lua base libraries // Initialize standard libraries except debug, modified from linit.c
luaL_openlibs(c_State); const luaL_Reg lualibs[] =
{
{ "", luaopen_base },
{ LUA_LOADLIBNAME, luaopen_package },
{ LUA_TABLIBNAME, luaopen_table },
{ LUA_IOLIBNAME, luaopen_io },
{ LUA_OSLIBNAME, luaopen_os },
{ LUA_STRLIBNAME, luaopen_string },
{ LUA_MATHLIBNAME, luaopen_math },
{ NULL, NULL }
};
const luaL_Reg* lib = lualibs;
for (; lib->func; lib++)
{
lua_pushcfunction(c_State, lib->func);
lua_pushstring(c_State, lib->name);
lua_call(c_State, 1, 0);
}
// Register custom types and functions // Register custom types and functions
RegisterGlobal(c_State); RegisterGlobal(c_State);

View File

@ -20,7 +20,7 @@
#include "../LuaManager.h" #include "../LuaManager.h"
#include "../../Litestep.h" #include "../../Litestep.h"
static int Global_Print(lua_State* L) static int Print(lua_State* L)
{ {
// Modified version of luaB_print() // Modified version of luaB_print()
std::string message; std::string message;
@ -59,5 +59,5 @@ static int Global_Print(lua_State* L)
void LuaManager::RegisterGlobal(lua_State* L) void LuaManager::RegisterGlobal(lua_State* L)
{ {
lua_register(L, "print", Global_Print); lua_register(L, "print", Print);
} }

View File

@ -147,7 +147,7 @@ static int GetStringValue(lua_State* L)
void LuaManager::RegisterMeasure(lua_State* L) void LuaManager::RegisterMeasure(lua_State* L)
{ {
const luaL_reg functions[] = const luaL_Reg functions[] =
{ {
{ "GetName", GetName }, { "GetName", GetName },
{ "GetOption", GetOption }, { "GetOption", GetOption },

View File

@ -148,7 +148,7 @@ static int SetText(lua_State* L)
void LuaManager::RegisterMeter(lua_State* L) void LuaManager::RegisterMeter(lua_State* L)
{ {
const luaL_reg functions[] = const luaL_Reg functions[] =
{ {
{ "GetName", GetName }, { "GetName", GetName },
{ "GetOption", GetOption }, { "GetOption", GetOption },

View File

@ -179,7 +179,7 @@ static int MakePathAbsolute(lua_State* L)
void LuaManager::RegisterMeterWindow(lua_State* L) void LuaManager::RegisterMeterWindow(lua_State* L)
{ {
const luaL_reg functions[] = const luaL_Reg functions[] =
{ {
{ "Bang", Bang }, { "Bang", Bang },
{ "GetMeter", GetMeter }, { "GetMeter", GetMeter },