aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/math
diff options
context:
space:
mode:
authorPaul Gilbert2010-08-01 09:31:36 +0000
committerEugene Sandulenko2010-10-12 22:18:35 +0000
commit2006e564a1287ff31c2c6acedecf90034e784fd2 (patch)
tree4e1ebb10fedbd39f053691c3cd59b6157c545d37 /engines/sword25/math
parent53a9d2d0a1dab1119dc1cc12886321fa72743061 (diff)
downloadscummvm-rg350-2006e564a1287ff31c2c6acedecf90034e784fd2.tar.gz
scummvm-rg350-2006e564a1287ff31c2c6acedecf90034e784fd2.tar.bz2
scummvm-rg350-2006e564a1287ff31c2c6acedecf90034e784fd2.zip
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
Diffstat (limited to 'engines/sword25/math')
-rw-r--r--engines/sword25/math/geometry_script.cpp46
-rw-r--r--engines/sword25/math/vertex.cpp2
-rw-r--r--engines/sword25/math/vertex.h8
3 files changed, 29 insertions, 27 deletions
diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp
index e656e5f548..08e6d3b159 100644
--- a/engines/sword25/math/geometry_script.cpp
+++ b/engines/sword25/math/geometry_script.cpp
@@ -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;
diff --git a/engines/sword25/math/vertex.cpp b/engines/sword25/math/vertex.cpp
index 61d21b58d8..ef49fd8139 100644
--- a/engines/sword25/math/vertex.cpp
+++ b/engines/sword25/math/vertex.cpp
@@ -34,7 +34,7 @@
#include "sword25/math/vertex.h"
-namespace {
+namespace Lua {
extern "C"
{
diff --git a/engines/sword25/math/vertex.h b/engines/sword25/math/vertex.h
index 5b4e6da0f8..65c179d654 100644
--- a/engines/sword25/math/vertex.h
+++ b/engines/sword25/math/vertex.h
@@ -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