mirror of https://github.com/rusefi/lua.git
Details
Some cast operations rewritten to use respective macros.
This commit is contained in:
parent
7f12bf40c4
commit
14d2803e55
4
ltable.c
4
ltable.c
|
@ -107,7 +107,7 @@ static const TValue absentkey = {ABSTKEYCONSTANT};
|
||||||
*/
|
*/
|
||||||
static Node *hashint (const Table *t, lua_Integer i) {
|
static Node *hashint (const Table *t, lua_Integer i) {
|
||||||
lua_Unsigned ui = l_castS2U(i);
|
lua_Unsigned ui = l_castS2U(i);
|
||||||
if (ui <= (unsigned int)INT_MAX)
|
if (ui <= cast_uint(INT_MAX))
|
||||||
return hashmod(t, cast_int(ui));
|
return hashmod(t, cast_int(ui));
|
||||||
else
|
else
|
||||||
return hashmod(t, ui);
|
return hashmod(t, ui);
|
||||||
|
@ -488,7 +488,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) {
|
||||||
luaG_runerror(L, "table overflow");
|
luaG_runerror(L, "table overflow");
|
||||||
size = twoto(lsize);
|
size = twoto(lsize);
|
||||||
t->node = luaM_newvector(L, size, Node);
|
t->node = luaM_newvector(L, size, Node);
|
||||||
for (i = 0; i < (int)size; i++) {
|
for (i = 0; i < cast_int(size); i++) {
|
||||||
Node *n = gnode(t, i);
|
Node *n = gnode(t, i);
|
||||||
gnext(n) = 0;
|
gnext(n) = 0;
|
||||||
setnilkey(n);
|
setnilkey(n);
|
||||||
|
|
10
ltests.c
10
ltests.c
|
@ -533,7 +533,7 @@ static void checkobject (global_State *g, GCObject *o, int maybedead,
|
||||||
|
|
||||||
static lu_mem checkgraylist (global_State *g, GCObject *o) {
|
static lu_mem checkgraylist (global_State *g, GCObject *o) {
|
||||||
int total = 0; /* count number of elements in the list */
|
int total = 0; /* count number of elements in the list */
|
||||||
((void)g); /* better to keep it available if we need to print an object */
|
cast_void(g); /* better to keep it if we need to print an object */
|
||||||
while (o) {
|
while (o) {
|
||||||
assert(!!isgray(o) ^ (getage(o) == G_TOUCHED2));
|
assert(!!isgray(o) ^ (getage(o) == G_TOUCHED2));
|
||||||
assert(!testbit(o->marked, TESTBIT));
|
assert(!testbit(o->marked, TESTBIT));
|
||||||
|
@ -1055,7 +1055,7 @@ static int tref (lua_State *L) {
|
||||||
luaL_checkany(L, 1);
|
luaL_checkany(L, 1);
|
||||||
lua_pushvalue(L, 1);
|
lua_pushvalue(L, 1);
|
||||||
lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX));
|
lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX));
|
||||||
(void)level; /* to avoid warnings */
|
cast_void(level); /* to avoid warnings */
|
||||||
lua_assert(lua_gettop(L) == level+1); /* +1 for result */
|
lua_assert(lua_gettop(L) == level+1); /* +1 for result */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1063,7 @@ static int tref (lua_State *L) {
|
||||||
static int getref (lua_State *L) {
|
static int getref (lua_State *L) {
|
||||||
int level = lua_gettop(L);
|
int level = lua_gettop(L);
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1));
|
lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1));
|
||||||
(void)level; /* to avoid warnings */
|
cast_void(level); /* to avoid warnings */
|
||||||
lua_assert(lua_gettop(L) == level+1);
|
lua_assert(lua_gettop(L) == level+1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1071,7 +1071,7 @@ static int getref (lua_State *L) {
|
||||||
static int unref (lua_State *L) {
|
static int unref (lua_State *L) {
|
||||||
int level = lua_gettop(L);
|
int level = lua_gettop(L);
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, cast_int(luaL_checkinteger(L, 1)));
|
luaL_unref(L, LUA_REGISTRYINDEX, cast_int(luaL_checkinteger(L, 1)));
|
||||||
(void)level; /* to avoid warnings */
|
cast_void(level); /* to avoid warnings */
|
||||||
lua_assert(lua_gettop(L) == level);
|
lua_assert(lua_gettop(L) == level);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1740,7 +1740,7 @@ static struct X { int x; } x;
|
||||||
else if EQ("tostring") {
|
else if EQ("tostring") {
|
||||||
const char *s = lua_tostring(L1, getindex);
|
const char *s = lua_tostring(L1, getindex);
|
||||||
const char *s1 = lua_pushstring(L1, s);
|
const char *s1 = lua_pushstring(L1, s);
|
||||||
(void)s1; /* to avoid warnings */
|
cast_void(s1); /* to avoid warnings */
|
||||||
lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0);
|
lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0);
|
||||||
}
|
}
|
||||||
else if EQ("Ltolstring") {
|
else if EQ("Ltolstring") {
|
||||||
|
|
Loading…
Reference in New Issue