[Scummvm-cvs-logs] SF.net SVN: scummvm:[53592] scummvm/trunk/engines/sword25/util/lua
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Tue Oct 19 00:17:18 CEST 2010
Revision: 53592
http://scummvm.svn.sourceforge.net/scummvm/?rev=53592&view=rev
Author: lordhoto
Date: 2010-10-18 22:17:18 +0000 (Mon, 18 Oct 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/sword25/util/lua/lapi.cpp
scummvm/trunk/engines/sword25/util/lua/ltable.cpp
Modified: scummvm/trunk/engines/sword25/util/lua/lapi.cpp
===================================================================
--- scummvm/trunk/engines/sword25/util/lua/lapi.cpp 2010-10-18 21:37:07 UTC (rev 53591)
+++ scummvm/trunk/engines/sword25/util/lua/lapi.cpp 2010-10-18 22:17:18 UTC (rev 53592)
@@ -50,7 +50,8 @@
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 @@
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);
}
}
}
Modified: scummvm/trunk/engines/sword25/util/lua/ltable.cpp
===================================================================
--- scummvm/trunk/engines/sword25/util/lua/ltable.cpp 2010-10-18 21:37:07 UTC (rev 53591)
+++ scummvm/trunk/engines/sword25/util/lua/ltable.cpp 2010-10-18 22:17:18 UTC (rev 53592)
@@ -272,7 +272,8 @@
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 @@
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 @@
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_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_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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list