aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/util
diff options
context:
space:
mode:
authorJohannes Schickel2010-10-18 22:17:18 +0000
committerJohannes Schickel2010-10-18 22:17:18 +0000
commit521751e8d7810ee603669fd2e4c2b35dd1da4bf0 (patch)
tree414fe623a7a8cb3b53beeba01d8567fe1edc2bdc /engines/sword25/util
parent5c2bcadd214b0af8f10e2915b986735739c42b36 (diff)
downloadscummvm-rg350-521751e8d7810ee603669fd2e4c2b35dd1da4bf0.tar.gz
scummvm-rg350-521751e8d7810ee603669fd2e4c2b35dd1da4bf0.tar.bz2
scummvm-rg350-521751e8d7810ee603669fd2e4c2b35dd1da4bf0.zip
SWORD25: Use const_cast to cast away constness.
This fixes a few warnings/errors in the LUA code. I added some FIXMEs at the places where the casts happen, since usually this casting indicates bad design. svn-id: r53592
Diffstat (limited to 'engines/sword25/util')
-rw-r--r--engines/sword25/util/lua/lapi.cpp6
-rw-r--r--engines/sword25/util/lua/ltable.cpp15
2 files changed, 14 insertions, 7 deletions
diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp
index e4a3d86dc3..a38733e1f7 100644
--- a/engines/sword25/util/lua/lapi.cpp
+++ b/engines/sword25/util/lua/lapi.cpp
@@ -50,7 +50,8 @@ static TValue *index2adr (lua_State *L, int idx) {
if (idx > 0) {
TValue *o = L->base + (idx - 1);
api_check(L, idx <= L->ci->top - L->base);
- if (o >= L->top) return cast(TValue *, luaO_nilobject);
+ // FIXME: Get rid of const_cast
+ if (o >= L->top) return const_cast<TValue *>(luaO_nilobject);
else return o;
}
else if (idx > LUA_REGISTRYINDEX) {
@@ -70,7 +71,8 @@ static TValue *index2adr (lua_State *L, int idx) {
idx = LUA_GLOBALSINDEX - idx;
return (idx <= func->c.nupvalues)
? &func->c.upvalue[idx-1]
- : cast(TValue *, luaO_nilobject);
+ // FIXME: Get rid of const_cast
+ : const_cast<TValue *>(luaO_nilobject);
}
}
}
diff --git a/engines/sword25/util/lua/ltable.cpp b/engines/sword25/util/lua/ltable.cpp
index 35d763eac3..b2ec0e912a 100644
--- a/engines/sword25/util/lua/ltable.cpp
+++ b/engines/sword25/util/lua/ltable.cpp
@@ -272,7 +272,8 @@ static void setarrayvector (lua_State *L, Table *t, int size) {
static void setnodevector (lua_State *L, Table *t, int size) {
int lsize;
if (size == 0) { /* no elements to hash part? */
- t->node = cast(Node *, dummynode); /* use common `dummynode' */
+ // FIXME: Get rid of const_cast
+ t->node = const_cast<Node *>(dummynode); /* use common `dummynode' */
lsize = 0;
}
else {
@@ -364,7 +365,8 @@ Table *luaH_new (lua_State *L, int narray, int nhash) {
t->array = NULL;
t->sizearray = 0;
t->lsizenode = 0;
- t->node = cast(Node *, dummynode);
+ // FIXME: Get rid of const_cast
+ t->node = const_cast<Node *>(dummynode);
setarrayvector(L, t, narray);
setnodevector(L, t, nhash);
return t;
@@ -495,7 +497,8 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
const TValue *p = luaH_get(t, key);
t->flags = 0;
if (p != luaO_nilobject)
- return cast(TValue *, p);
+ // FIXME: Get rid of const_cast
+ return const_cast<TValue *>(p);
else {
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
@@ -508,7 +511,8 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
TValue *luaH_setnum (lua_State *L, Table *t, int key) {
const TValue *p = luaH_getnum(t, key);
if (p != luaO_nilobject)
- return cast(TValue *, p);
+ // FIXME: Get rid of const_cast
+ return const_cast<TValue *>(p);
else {
TValue k;
setnvalue(&k, cast_num(key));
@@ -520,7 +524,8 @@ TValue *luaH_setnum (lua_State *L, Table *t, int key) {
TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
const TValue *p = luaH_getstr(t, key);
if (p != luaO_nilobject)
- return cast(TValue *, p);
+ // FIXME: Get rid of const_cast
+ return const_cast<TValue *>(p);
else {
TValue k;
setsvalue(L, &k, key);