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
This commit is contained in:
Paul Gilbert 2010-08-01 09:31:36 +00:00 committed by Eugene Sandulenko
parent 53a9d2d0a1
commit 2006e564a1
11 changed files with 111 additions and 104 deletions

View File

@ -36,23 +36,20 @@
#define SWORD25_STDWININPUT_H
/// Includes
#include "sword25/kernel/memlog_off.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <list>
#include "sword25/kernel/memlog_on.h"
#include "common/scummsys.h"
#include "common/list.h"
#include "sword25/kernel/common.h"
#include "sword25/input/inputengine.h"
/// Klassendefinitionen
namespace Sword25 {
/// Forward class definitions
class BS_Kernel;
/// Klassendefinition
class BS_StdWinInput : public BS_InputEngine
{
/// Class definitions
class BS_StdWinInput : public BS_InputEngine {
public:
BS_StdWinInput(BS_Kernel* pKernel);
BS_StdWinInput(BS_Kernel *pKernel);
virtual ~BS_StdWinInput();
virtual bool Init();
@ -75,13 +72,13 @@ public:
virtual void ReportCharacter(unsigned char Character);
virtual void ReportCommand(KEY_COMMANDS Command);
bool Persist(BS_OutputPersistenceBlock & Writer);
bool Unpersist(BS_InputPersistenceBlock & Reader);
bool Persist(BS_OutputPersistenceBlock &Writer);
bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
void TestForLeftDoubleClick();
BYTE m_KeyboardState[2][256];
byte m_KeyboardState[2][256];
bool m_LeftMouseState[2];
bool m_RightMouseState[2];
unsigned int m_CurrentState;
@ -96,8 +93,10 @@ private:
unsigned int m_LastLeftClickTime;
int m_LastLeftClickMouseX;
int m_LastLeftClickMouseY;
std::list<CommandCallback> m_CommandCallbacks;
std::list<CharacterCallback> m_CharacterCallbacks;
Common::List<CommandCallback> m_CommandCallbacks;
Common::List<CharacterCallback> m_CharacterCallbacks;
};
} // End of namespace Sword25
#endif

View File

@ -64,7 +64,7 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
// How luaL_checkudata, only without that no error is generated.
static void *my_checkudata(::lua_State *L, int ud, const char *tname) {
static void *my_checkudata(lua_State *L, int ud, const char *tname) {
int top = lua_gettop(L);
void * p = lua_touserdata(L, ud);
@ -88,14 +88,14 @@ static void *my_checkudata(::lua_State *L, int ud, const char *tname) {
// -----------------------------------------------------------------------------
static void NewUintUserData(::lua_State *L, unsigned int Value) {
static void NewUintUserData(lua_State *L, unsigned int Value) {
void * UserData = lua_newuserdata(L, sizeof(Value));
memcpy(UserData, &Value, sizeof(Value));
}
// -----------------------------------------------------------------------------
static bool IsValidPolygonDefinition(::lua_State *L) {
static bool IsValidPolygonDefinition(lua_State *L) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -140,7 +140,7 @@ static bool IsValidPolygonDefinition(::lua_State *L) {
// -----------------------------------------------------------------------------
static void TablePolygonToPolygon(::lua_State *L, BS_Polygon &Polygon) {
static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -184,7 +184,7 @@ static void TablePolygonToPolygon(::lua_State *L, BS_Polygon &Polygon) {
// -----------------------------------------------------------------------------
static unsigned int TableRegionToRegion(::lua_State *L, const char *ClassName) {
static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -268,7 +268,7 @@ static unsigned int TableRegionToRegion(::lua_State *L, const char *ClassName) {
// -----------------------------------------------------------------------------
static void NewUserdataRegion(::lua_State *L, const char *ClassName)
static void NewUserdataRegion(lua_State *L, const char *ClassName)
{
// Region due to the Lua code to create
// Any errors that occur will be intercepted to the luaL_error
@ -284,14 +284,14 @@ static void NewUserdataRegion(::lua_State *L, const char *ClassName)
// -----------------------------------------------------------------------------
static int NewRegion(::lua_State *L) {
static int NewRegion(lua_State *L) {
NewUserdataRegion(L, REGION_CLASS_NAME);
return 1;
}
// -----------------------------------------------------------------------------
static int NewWalkRegion(::lua_State *L) {
static int NewWalkRegion(lua_State *L) {
NewUserdataRegion(L, WALKREGION_CLASS_NAME);
return 1;
}
@ -308,7 +308,7 @@ static const luaL_reg GEO_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
static BS_Region * CheckRegion(::lua_State *L) {
static BS_Region * CheckRegion(lua_State *L) {
// The first parameter must be of type 'userdata', and the Metatable class Geo.Region or Geo.WalkRegion
unsigned int *RegionHandlePtr;
if ((RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, REGION_CLASS_NAME))) != 0 ||
@ -324,7 +324,7 @@ static BS_Region * CheckRegion(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_IsValid(::lua_State *L) {
static int R_IsValid(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -334,7 +334,7 @@ static int R_IsValid(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetX(::lua_State *L) {
static int R_GetX(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -344,7 +344,7 @@ static int R_GetX(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetY(::lua_State *L) {
static int R_GetY(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -354,7 +354,7 @@ static int R_GetY(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetPos(::lua_State *L) {
static int R_GetPos(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -364,7 +364,7 @@ static int R_GetPos(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_IsPointInRegion(::lua_State *L) {
static int R_IsPointInRegion(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -376,7 +376,7 @@ static int R_IsPointInRegion(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetPos(::lua_State *L) {
static int R_SetPos(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -389,7 +389,7 @@ static int R_SetPos(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetX(::lua_State *L) {
static int R_SetX(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -400,7 +400,7 @@ static int R_SetX(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetY(::lua_State *L) {
static int R_SetY(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -431,7 +431,7 @@ static void DrawRegion(const BS_Region &Region, unsigned int Color, const BS_Ver
// -----------------------------------------------------------------------------
static int R_Draw(::lua_State *L) {
static int R_Draw(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
@ -456,7 +456,7 @@ static int R_Draw(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetCentroid(::lua_State *L) {
static int R_GetCentroid(lua_State *L) {
BS_Region * RPtr = CheckRegion(L);
BS_ASSERT(RPtr);
@ -467,7 +467,7 @@ static int R_GetCentroid(::lua_State *L) {
// -----------------------------------------------------------------------------
static int R_Delete(::lua_State *L) {
static int R_Delete(lua_State *L) {
BS_Region * pR = CheckRegion(L);
BS_ASSERT(pR);
delete pR;
@ -492,7 +492,7 @@ static const luaL_reg REGION_METHODS[] = {
// -----------------------------------------------------------------------------
static BS_WalkRegion *CheckWalkRegion(::lua_State *L) {
static BS_WalkRegion *CheckWalkRegion(lua_State *L) {
// The first parameter must be of type 'userdate', and the Metatable class Geo.WalkRegion
unsigned int RegionHandle;
if ((RegionHandle = *reinterpret_cast<unsigned int *>(my_checkudata(L, 1, WALKREGION_CLASS_NAME))) != 0) {
@ -507,7 +507,7 @@ static BS_WalkRegion *CheckWalkRegion(::lua_State *L) {
// -----------------------------------------------------------------------------
static int WR_GetPath(::lua_State *L) {
static int WR_GetPath(lua_State *L) {
BS_WalkRegion *pWR = CheckWalkRegion(L);
BS_ASSERT(pWR);
@ -544,7 +544,7 @@ bool BS_Geometry::_RegisterScriptBindings() {
BS_ASSERT(pKernel);
BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
::lua_State *L = static_cast< ::lua_State *>(pScript->GetScriptObject());
lua_State *L = static_cast< lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
if (!BS_LuaBindhelper::AddMethodsToClass(L, REGION_CLASS_NAME, REGION_METHODS)) return false;

View File

@ -34,7 +34,7 @@
#include "sword25/math/vertex.h"
namespace {
namespace Lua {
extern "C"
{

View File

@ -46,13 +46,15 @@
#include <math.h>
#include "sword25/kernel/common.h"
namespace {
namespace Lua {
// Forward declarations
struct lua_State;
}
using namespace Lua;
namespace Sword25 {
/**
@ -151,8 +153,8 @@ public:
return sqrtf(static_cast<float>(X * X + Y * Y));
}
static BS_Vertex & LuaVertexToVertex(lua_State * L, int StackIndex, BS_Vertex & Vertex);
static void VertexToLuaVertex(lua_State * L, const BS_Vertex & Vertex);
static BS_Vertex &LuaVertexToVertex(lua_State *L, int StackIndex, BS_Vertex &Vertex);
static void VertexToLuaVertex(lua_State *L, const BS_Vertex &Vertex);
};
} // End of namespace Sword25

View File

@ -43,7 +43,7 @@
namespace Sword25 {
static int Warning(::lua_State *L) {
static int Warning(lua_State *L) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -73,7 +73,7 @@ static const luaL_reg GLOBAL_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
bool BS_LuaScriptEngine::RegisterStandardLibExtensions() {
::lua_State *L = m_State;
lua_State *L = m_State;
BS_ASSERT(m_State);
if (!BS_LuaBindhelper::AddFunctionsToLib(L, "", GLOBAL_FUNCTIONS)) return false;

View File

@ -48,7 +48,7 @@ namespace {
const char * METATABLES_TABLE_NAME = "__METATABLES";
const char * PERMANENTS_TABLE_NAME = "Permanents";
bool RegisterPermanent(::lua_State *L, const Common::String &Name) {
bool RegisterPermanent(lua_State *L, const Common::String &Name) {
// A C function has to be on the stack
if (!lua_iscfunction(L, -1)) return false;
@ -93,7 +93,7 @@ namespace Sword25 {
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddFunctionsToLib(::lua_State *L, const Common::String &LibName, const luaL_reg *Functions) {
bool BS_LuaBindhelper::AddFunctionsToLib(lua_State *L, const Common::String &LibName, const luaL_reg *Functions) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -151,7 +151,7 @@ bool BS_LuaBindhelper::AddFunctionsToLib(::lua_State *L, const Common::String &L
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddConstantsToLib(::lua_State *L, const Common::String &LibName, const lua_constant_reg *Constants) {
bool BS_LuaBindhelper::AddConstantsToLib(lua_State *L, const Common::String &LibName, const lua_constant_reg *Constants) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -198,7 +198,7 @@ bool BS_LuaBindhelper::AddConstantsToLib(::lua_State *L, const Common::String &L
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddMethodsToClass(::lua_State *L, const Common::String &ClassName, const luaL_reg *Methods) {
bool BS_LuaBindhelper::AddMethodsToClass(lua_State *L, const Common::String &ClassName, const luaL_reg *Methods) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -238,7 +238,7 @@ bool BS_LuaBindhelper::AddMethodsToClass(::lua_State *L, const Common::String &C
* @param GCHandler A function pointer
* @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::SetClassGCHandler(::lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler) {
bool BS_LuaBindhelper::SetClassGCHandler(lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@ -271,7 +271,7 @@ bool BS_LuaBindhelper::SetClassGCHandler(::lua_State *L, const Common::String &C
// -----------------------------------------------------------------------------
namespace {
void PushMetatableTable(::lua_State *L) {
void PushMetatableTable(lua_State *L) {
// Push the Metatable table onto the stack
lua_getglobal(L, METATABLES_TABLE_NAME);
@ -290,7 +290,7 @@ namespace {
namespace Sword25 {
bool BS_LuaBindhelper::GetMetatable(::lua_State *L, const Common::String &TableName) {
bool BS_LuaBindhelper::GetMetatable(lua_State *L, const Common::String &TableName) {
// Push the Metatable table onto the stack
PushMetatableTable(L);
@ -324,7 +324,7 @@ bool BS_LuaBindhelper::GetMetatable(::lua_State *L, const Common::String &TableN
// -----------------------------------------------------------------------------
bool BS_LuaBindhelper::_CreateTable(::lua_State *L, const Common::String &TableName) {
bool BS_LuaBindhelper::_CreateTable(lua_State *L, const Common::String &TableName) {
const char *PartBegin = TableName.c_str();
while (PartBegin) {
@ -373,7 +373,7 @@ bool BS_LuaBindhelper::_CreateTable(::lua_State *L, const Common::String &TableN
} // End of namespace Sword25
namespace {
Common::String GetLuaValueInfo(::lua_State *L, int StackIndex) {
Common::String GetLuaValueInfo(lua_State *L, int StackIndex) {
switch (lua_type(L, StackIndex)) {
case LUA_TNUMBER:
lua_pushstring(L, lua_tostring(L, StackIndex));
@ -405,7 +405,7 @@ namespace {
namespace Sword25 {
Common::String BS_LuaBindhelper::StackDump(::lua_State *L) {
Common::String BS_LuaBindhelper::StackDump(lua_State *L) {
Common::String oss;
int i = lua_gettop(L);
@ -421,7 +421,7 @@ Common::String BS_LuaBindhelper::StackDump(::lua_State *L) {
return oss;
}
Common::String BS_LuaBindhelper::TableDump(::lua_State *L) {
Common::String BS_LuaBindhelper::TableDump(lua_State *L) {
Common::String oss;
oss += "------------------- Table Dump -------------------\n";

View File

@ -37,7 +37,7 @@
#include "sword25/kernel/common.h"
namespace {
namespace Lua {
extern "C"
{
@ -47,6 +47,8 @@ extern "C"
}
using namespace Lua;
namespace Sword25 {
#define lua_pushbooleancpp(L, b) (lua_pushboolean(L, b ? 1 : 0))
@ -68,7 +70,7 @@ public:
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
static bool AddFunctionsToLib(::lua_State *L, const Common::String &LibName, const luaL_reg *Functions);
static bool AddFunctionsToLib(lua_State *L, const Common::String &LibName, const luaL_reg *Functions);
/**
* Adds a set of constants to the Lua library
@ -79,7 +81,7 @@ public:
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
static bool AddConstantsToLib(::lua_State * L, const Common::String & LibName, const lua_constant_reg * Constants);
static bool AddConstantsToLib(lua_State * L, const Common::String & LibName, const lua_constant_reg * Constants);
/**
* Adds a set of methods to a Lua class
@ -90,7 +92,7 @@ public:
* The array must be terminated with the enry (0, 0)
* @return Returns true if successful, otherwise false.
*/
static bool AddMethodsToClass(::lua_State *L, const Common::String &ClassName, const luaL_reg *Methods);
static bool AddMethodsToClass(lua_State *L, const Common::String &ClassName, const luaL_reg *Methods);
/**
* Sets the garbage collector callback method when items of a particular class are deleted
@ -100,25 +102,25 @@ public:
* @param GCHandler A function pointer
* @return Returns true if successful, otherwise false.
*/
static bool SetClassGCHandler(::lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler);
static bool SetClassGCHandler(lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler);
/**
* Returns a string containing a stack dump of the Lua stack
* @param L A pointer to the Lua VM
*/
static Common::String StackDump(::lua_State *L);
static Common::String StackDump(lua_State *L);
/**
* Returns a string that describes the contents of a table
* @param L A pointer to the Lua VM
* @remark The table must be on the Lua stack to be read out.
*/
static Common::String TableDump(::lua_State *L);
static Common::String TableDump(lua_State *L);
static bool GetMetatable(::lua_State *L, const Common::String &TableName);
static bool GetMetatable(lua_State *L, const Common::String &TableName);
private:
static bool _CreateTable(::lua_State *L, const Common::String &TableName);
static bool _CreateTable(lua_State *L, const Common::String &TableName);
};
} // End of namespace Sword25

View File

@ -39,7 +39,7 @@
#include "sword25/script/luacallback.h"
#include "sword25/script/luabindhelper.h"
namespace {
namespace Lua {
extern "C"
{
@ -59,7 +59,7 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
BS_LuaCallback::BS_LuaCallback(::lua_State *L) {
BS_LuaCallback::BS_LuaCallback(lua_State *L) {
// Create callback table
lua_newtable(L);
lua_setglobal(L, CALLBACKTABLE_NAME);
@ -72,7 +72,7 @@ BS_LuaCallback::~BS_LuaCallback() {
// -----------------------------------------------------------------------------
void BS_LuaCallback::RegisterCallbackFunction(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::RegisterCallbackFunction(lua_State *L, unsigned int ObjectHandle) {
BS_ASSERT(lua_isfunction(L, -1));
EnsureObjectCallbackTableExists(L, ObjectHandle);
@ -86,7 +86,7 @@ void BS_LuaCallback::RegisterCallbackFunction(::lua_State *L, unsigned int Objec
// -----------------------------------------------------------------------------
void BS_LuaCallback::UnregisterCallbackFunction(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::UnregisterCallbackFunction(lua_State *L, unsigned int ObjectHandle) {
BS_ASSERT(lua_isfunction(L, -1));
EnsureObjectCallbackTableExists(L,ObjectHandle);
@ -116,7 +116,7 @@ void BS_LuaCallback::UnregisterCallbackFunction(::lua_State *L, unsigned int Obj
// -----------------------------------------------------------------------------
void BS_LuaCallback::RemoveAllObjectCallbacks(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::RemoveAllObjectCallbacks(lua_State *L, unsigned int ObjectHandle) {
PushCallbackTable(L);
// Remove the object callback from the callback table
@ -129,7 +129,7 @@ void BS_LuaCallback::RemoveAllObjectCallbacks(::lua_State *L, unsigned int Objec
// -----------------------------------------------------------------------------
void BS_LuaCallback::InvokeCallbackFunctions(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHandle) {
EnsureObjectCallbackTableExists(L, ObjectHandle);
// Iterate through the table and perform all the callbacks
@ -164,7 +164,7 @@ void BS_LuaCallback::InvokeCallbackFunctions(::lua_State *L, unsigned int Object
// -----------------------------------------------------------------------------
void BS_LuaCallback::EnsureObjectCallbackTableExists(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::EnsureObjectCallbackTableExists(lua_State *L, unsigned int ObjectHandle) {
PushObjectCallbackTable(L, ObjectHandle);
// If the table is nil, it must first be created
@ -187,13 +187,13 @@ void BS_LuaCallback::EnsureObjectCallbackTableExists(::lua_State *L, unsigned in
// -----------------------------------------------------------------------------
void BS_LuaCallback::PushCallbackTable(::lua_State *L) {
void BS_LuaCallback::PushCallbackTable(lua_State *L) {
lua_getglobal(L, CALLBACKTABLE_NAME);
}
// -----------------------------------------------------------------------------
void BS_LuaCallback::PushObjectCallbackTable(::lua_State *L, unsigned int ObjectHandle) {
void BS_LuaCallback::PushObjectCallbackTable(lua_State *L, unsigned int ObjectHandle) {
PushCallbackTable(L);
// Push Object Callback table onto the stack

View File

@ -45,12 +45,14 @@
// Forward Declarations
// -----------------------------------------------------------------------------
namespace {
namespace Lua {
struct lua_State;
}
using namespace Lua;
namespace Sword25 {
// -----------------------------------------------------------------------------
@ -59,26 +61,26 @@ namespace Sword25 {
class BS_LuaCallback {
public:
BS_LuaCallback(::lua_State * L);
BS_LuaCallback(lua_State * L);
virtual ~BS_LuaCallback();
// Funktion muss auf dem Lua-Stack liegen.
void RegisterCallbackFunction(::lua_State *L, unsigned int ObjectHandle);
void RegisterCallbackFunction(lua_State *L, unsigned int ObjectHandle);
// Funktion muss auf dem Lua-Stack liegen.
void UnregisterCallbackFunction(::lua_State *L, unsigned int ObjectHandle);
void UnregisterCallbackFunction(lua_State *L, unsigned int ObjectHandle);
void RemoveAllObjectCallbacks(::lua_State *L, unsigned int ObjectHandle);
void RemoveAllObjectCallbacks(lua_State *L, unsigned int ObjectHandle);
void InvokeCallbackFunctions(::lua_State *L, unsigned int ObjectHandle);
void InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHandle);
protected:
virtual int PreFunctionInvokation(::lua_State *L) { return 0; }
virtual int PreFunctionInvokation(lua_State *L) { return 0; }
private:
void EnsureObjectCallbackTableExists(::lua_State *L,unsigned int ObjectHandle);
void PushCallbackTable(::lua_State *L);
void PushObjectCallbackTable(::lua_State *L, unsigned int ObjectHandle);
void EnsureObjectCallbackTableExists(lua_State *L,unsigned int ObjectHandle);
void PushCallbackTable(lua_State *L);
void PushObjectCallbackTable(lua_State *L, unsigned int ObjectHandle);
};
} // End of namespace Sword25

View File

@ -38,18 +38,6 @@
// Includes
// -----------------------------------------------------------------------------
//namespace {
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"
@ -57,9 +45,21 @@ extern "C"
#include "sword25/kernel/outputpersistenceblock.h"
#include "sword25/kernel/inputpersistenceblock.h"
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"
}
}
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<unsigned char> & chunkData = *reinterpret_cast<vector<unsigned char> * >(ud);
const unsigned char *buffer = reinterpret_cast<const unsigned char *>(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<ChunkreaderData *>(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);

View File

@ -48,12 +48,14 @@
// Forward declarations
// -----------------------------------------------------------------------------
namespace {
namespace Lua {
struct lua_State;
}
using namespace Lua;
namespace Sword25 {
class BS_Kernel;
@ -115,7 +117,7 @@ public:
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
::lua_State *m_State;
lua_State *m_State;
int m_PcallErrorhandlerRegistryIndex;
bool RegisterStandardLibs();