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
This commit is contained in:
parent
5c2bcadd21
commit
521751e8d7
2 changed files with 14 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue