From 2006e564a1287ff31c2c6acedecf90034e784fd2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 1 Aug 2010 09:31:36 +0000 Subject: SWORD25: Moved the Lua library into it's own namespace Previously with some of the files I was leaving the #include references to the library inside the global namespace. However, since the engine itself is now inside a namespace, I had to do a lot of changes, such as lua_State to ::lua_State. This way is cleaner, and I just need to add a 'using namespace Lua' where needed. svn-id: r53198 --- engines/sword25/script/luascript.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/sword25/script/luascript.cpp') diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index 8af0128c72..129dd03c8a 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -38,28 +38,28 @@ // Includes // ----------------------------------------------------------------------------- -//namespace { +#include "sword25/package/packagemanager.h" +#include "sword25/script/luascript.h" +#include "sword25/script/luabindhelper.h" + +#include "sword25/kernel/outputpersistenceblock.h" +#include "sword25/kernel/inputpersistenceblock.h" -extern "C" -{ +namespace Lua { + +extern "C" { #include "sword25/util/lua/lua.h" #include "sword25/util/lua/lualib.h" #include "sword25/util/lua/lauxlib.h" #include "sword25/util/pluto/pluto.h" } -//} - -#include "sword25/package/packagemanager.h" -#include "sword25/script/luascript.h" -#include "sword25/script/luabindhelper.h" - -#include "sword25/kernel/outputpersistenceblock.h" -#include "sword25/kernel/inputpersistenceblock.h" +} namespace Sword25 { using namespace std; +using namespace Lua; // ----------------------------------------------------------------------------- // Constructor / Destructor @@ -85,7 +85,7 @@ BS_Service *BS_LuaScriptEngine_CreateObject(BS_Kernel * KernelPtr) { return new // ----------------------------------------------------------------------------- namespace { - int PanicCB(::lua_State *L) { + int PanicCB(lua_State *L) { BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1)); return 0; } @@ -193,7 +193,7 @@ bool BS_LuaScriptEngine::ExecuteString(const Common::String &Code) { namespace { - void RemoveForbiddenFunctions(::lua_State *L) { + void RemoveForbiddenFunctions(lua_State *L) { static const char *FORBIDDEN_FUNCTIONS[] = { "dofile", 0 @@ -326,7 +326,7 @@ namespace { // ------------------------------------------------------------------------- - bool PushPermanentsTable(::lua_State *L, PERMANENT_TABLE_TYPE TableType) { + bool PushPermanentsTable(lua_State *L, PERMANENT_TABLE_TYPE TableType) { // Permanents-Table lua_newtable(L); @@ -409,7 +409,7 @@ namespace { // ----------------------------------------------------------------------------- namespace { - int Chunkwriter(::lua_State *L, const void *p, size_t sz, void *ud) { + int Chunkwriter(lua_State *L, const void *p, size_t sz, void *ud) { vector & chunkData = *reinterpret_cast * >(ud); const unsigned char *buffer = reinterpret_cast(p); @@ -457,7 +457,7 @@ namespace { // ------------------------------------------------------------------------ - const char *Chunkreader(::lua_State *L, void *ud, size_t *sz) { + const char *Chunkreader(lua_State *L, void *ud, size_t *sz) { ChunkreaderData & cd = *reinterpret_cast(ud); if (!cd.BufferReturned) { @@ -471,7 +471,7 @@ namespace { // ------------------------------------------------------------------------- - void ClearGlobalTable(::lua_State *L, const char **Exceptions) { + void ClearGlobalTable(lua_State *L, const char **Exceptions) { // Iterate over all elements of the global table lua_pushvalue(L, LUA_GLOBALSINDEX); lua_pushnil(L); -- cgit v1.2.3