mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
deprecated "cast macros" ('luaL_checkint', 'luaL_optint', etc.)
This commit is contained in:
parent
34b6664dcb
commit
798660c9cd
18
lauxlib.h
18
lauxlib.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.124 2014/04/15 18:25:49 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.125 2014/06/26 17:25:11 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -115,10 +115,6 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
|
|||||||
((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
|
((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
|
||||||
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
|
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
|
||||||
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
|
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
|
||||||
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
|
|
||||||
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
|
|
||||||
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
|
|
||||||
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
|
|
||||||
|
|
||||||
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
|
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
|
||||||
|
|
||||||
@ -210,15 +206,21 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** {============================================================
|
** {============================================================
|
||||||
** Compatibility with deprecated unsigned conversions
|
** Compatibility with deprecated conversions
|
||||||
** =============================================================
|
** =============================================================
|
||||||
*/
|
*/
|
||||||
#if defined(LUA_COMPAT_APIUNSIGNED)
|
#if defined(LUA_COMPAT_APIINTCASTS)
|
||||||
|
|
||||||
#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
|
#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
|
||||||
#define luaL_optunsigned(L,a,d) \
|
#define luaL_optunsigned(L,a,d) \
|
||||||
((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
|
((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
|
||||||
|
|
||||||
|
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
|
||||||
|
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
|
||||||
|
|
||||||
|
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
|
||||||
|
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* }============================================================ */
|
/* }============================================================ */
|
||||||
|
|
||||||
|
18
lbaselib.c
18
lbaselib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.297 2014/09/22 06:42:15 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.298 2014/09/30 13:53:26 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -87,11 +87,11 @@ static int luaB_tonumber (lua_State *L) {
|
|||||||
size_t l;
|
size_t l;
|
||||||
const char *s;
|
const char *s;
|
||||||
lua_Integer n = 0; /* to avoid warnings */
|
lua_Integer n = 0; /* to avoid warnings */
|
||||||
int base = luaL_checkint(L, 2);
|
lua_Integer base = luaL_checkinteger(L, 2);
|
||||||
luaL_checktype(L, 1, LUA_TSTRING); /* before 'luaL_checklstring'! */
|
luaL_checktype(L, 1, LUA_TSTRING); /* before 'luaL_checklstring'! */
|
||||||
s = luaL_checklstring(L, 1, &l);
|
s = luaL_checklstring(L, 1, &l);
|
||||||
luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
|
luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
|
||||||
if (b_str2int(s, base, &n) == s + l) {
|
if (b_str2int(s, (int)base, &n) == s + l) {
|
||||||
lua_pushinteger(L, n);
|
lua_pushinteger(L, n);
|
||||||
return 1;
|
return 1;
|
||||||
} /* else not a number */
|
} /* else not a number */
|
||||||
@ -102,7 +102,7 @@ static int luaB_tonumber (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static int luaB_error (lua_State *L) {
|
static int luaB_error (lua_State *L) {
|
||||||
int level = luaL_optint(L, 2, 1);
|
int level = (int)luaL_optinteger(L, 2, 1);
|
||||||
lua_settop(L, 1);
|
lua_settop(L, 1);
|
||||||
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
|
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
|
||||||
luaL_where(L, level);
|
luaL_where(L, level);
|
||||||
@ -180,7 +180,7 @@ static int luaB_collectgarbage (lua_State *L) {
|
|||||||
LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
|
LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
|
||||||
LUA_GCISRUNNING};
|
LUA_GCISRUNNING};
|
||||||
int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
|
int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
|
||||||
int ex = luaL_optint(L, 2, 0);
|
int ex = (int)luaL_optinteger(L, 2, 0);
|
||||||
int res = lua_gc(L, o, ex);
|
int res = lua_gc(L, o, ex);
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case LUA_GCCOUNT: {
|
case LUA_GCCOUNT: {
|
||||||
@ -248,7 +248,7 @@ static int luaB_pairs (lua_State *L) {
|
|||||||
** Traversal function for 'ipairs' for raw tables
|
** Traversal function for 'ipairs' for raw tables
|
||||||
*/
|
*/
|
||||||
static int ipairsaux_raw (lua_State *L) {
|
static int ipairsaux_raw (lua_State *L) {
|
||||||
int i = luaL_checkint(L, 2) + 1;
|
lua_Integer i = luaL_checkinteger(L, 2) + 1;
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
lua_pushinteger(L, i);
|
lua_pushinteger(L, i);
|
||||||
return (lua_rawgeti(L, 1, i) == LUA_TNIL) ? 1 : 2;
|
return (lua_rawgeti(L, 1, i) == LUA_TNIL) ? 1 : 2;
|
||||||
@ -259,7 +259,7 @@ static int ipairsaux_raw (lua_State *L) {
|
|||||||
** Traversal function for 'ipairs' for tables with metamethods
|
** Traversal function for 'ipairs' for tables with metamethods
|
||||||
*/
|
*/
|
||||||
static int ipairsaux (lua_State *L) {
|
static int ipairsaux (lua_State *L) {
|
||||||
int i = luaL_checkint(L, 2) + 1;
|
lua_Integer i = luaL_checkinteger(L, 2) + 1;
|
||||||
lua_pushinteger(L, i);
|
lua_pushinteger(L, i);
|
||||||
return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;
|
return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;
|
||||||
}
|
}
|
||||||
@ -405,11 +405,11 @@ static int luaB_select (lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i = luaL_checkint(L, 1);
|
lua_Integer i = luaL_checkinteger(L, 1);
|
||||||
if (i < 0) i = n + i;
|
if (i < 0) i = n + i;
|
||||||
else if (i > n) i = n;
|
else if (i > n) i = n;
|
||||||
luaL_argcheck(L, 1 <= i, 1, "index out of range");
|
luaL_argcheck(L, 1 <= i, 1, "index out of range");
|
||||||
return n - i;
|
return n - (int)i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
lbitlib.c
26
lbitlib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbitlib.c,v 1.25 2014/03/20 19:22:16 roberto Exp roberto $
|
** $Id: lbitlib.c,v 1.26 2014/05/15 19:28:34 roberto Exp roberto $
|
||||||
** Standard library for bitwise operations
|
** Standard library for bitwise operations
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -89,7 +89,7 @@ static int b_not (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b_shift (lua_State *L, lua_Unsigned r, int i) {
|
static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) {
|
||||||
if (i < 0) { /* shift right? */
|
if (i < 0) { /* shift right? */
|
||||||
i = -i;
|
i = -i;
|
||||||
r = trim(r);
|
r = trim(r);
|
||||||
@ -107,18 +107,18 @@ static int b_shift (lua_State *L, lua_Unsigned r, int i) {
|
|||||||
|
|
||||||
|
|
||||||
static int b_lshift (lua_State *L) {
|
static int b_lshift (lua_State *L) {
|
||||||
return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2));
|
return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkinteger(L, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b_rshift (lua_State *L) {
|
static int b_rshift (lua_State *L) {
|
||||||
return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2));
|
return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkinteger(L, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b_arshift (lua_State *L) {
|
static int b_arshift (lua_State *L) {
|
||||||
lua_Unsigned r = luaL_checkunsigned(L, 1);
|
lua_Unsigned r = luaL_checkunsigned(L, 1);
|
||||||
int i = luaL_checkint(L, 2);
|
lua_Integer i = luaL_checkinteger(L, 2);
|
||||||
if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1))))
|
if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1))))
|
||||||
return b_shift(L, r, -i);
|
return b_shift(L, r, -i);
|
||||||
else { /* arithmetic shift for 'negative' number */
|
else { /* arithmetic shift for 'negative' number */
|
||||||
@ -131,9 +131,9 @@ static int b_arshift (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b_rot (lua_State *L, int i) {
|
static int b_rot (lua_State *L, lua_Integer d) {
|
||||||
lua_Unsigned r = luaL_checkunsigned(L, 1);
|
lua_Unsigned r = luaL_checkunsigned(L, 1);
|
||||||
i &= (LUA_NBITS - 1); /* i = i % NBITS */
|
int i = d & (LUA_NBITS - 1); /* i = d % NBITS */
|
||||||
r = trim(r);
|
r = trim(r);
|
||||||
if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */
|
if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */
|
||||||
r = (r << i) | (r >> (LUA_NBITS - i));
|
r = (r << i) | (r >> (LUA_NBITS - i));
|
||||||
@ -143,12 +143,12 @@ static int b_rot (lua_State *L, int i) {
|
|||||||
|
|
||||||
|
|
||||||
static int b_lrot (lua_State *L) {
|
static int b_lrot (lua_State *L) {
|
||||||
return b_rot(L, luaL_checkint(L, 2));
|
return b_rot(L, luaL_checkinteger(L, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b_rrot (lua_State *L) {
|
static int b_rrot (lua_State *L) {
|
||||||
return b_rot(L, -luaL_checkint(L, 2));
|
return b_rot(L, -luaL_checkinteger(L, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,14 +159,14 @@ static int b_rrot (lua_State *L) {
|
|||||||
** 'width' being used uninitialized.)
|
** 'width' being used uninitialized.)
|
||||||
*/
|
*/
|
||||||
static int fieldargs (lua_State *L, int farg, int *width) {
|
static int fieldargs (lua_State *L, int farg, int *width) {
|
||||||
int f = luaL_checkint(L, farg);
|
lua_Integer f = luaL_checkinteger(L, farg);
|
||||||
int w = luaL_optint(L, farg + 1, 1);
|
lua_Integer w = luaL_optinteger(L, farg + 1, 1);
|
||||||
luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
|
luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
|
||||||
luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
|
luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
|
||||||
if (f + w > LUA_NBITS)
|
if (f + w > LUA_NBITS)
|
||||||
luaL_error(L, "trying to access non-existent bits");
|
luaL_error(L, "trying to access non-existent bits");
|
||||||
*width = w;
|
*width = (int)w;
|
||||||
return f;
|
return (int)f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
22
ldblib.c
22
ldblib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.140 2014/08/21 19:12:40 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.141 2014/08/22 16:22:42 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -160,7 +160,7 @@ static int db_getinfo (lua_State *L) {
|
|||||||
lua_xmove(L, L1, 1);
|
lua_xmove(L, L1, 1);
|
||||||
}
|
}
|
||||||
else { /* stack level */
|
else { /* stack level */
|
||||||
if (!lua_getstack(L1, luaL_checkint(L, arg + 1), &ar)) {
|
if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) {
|
||||||
lua_pushnil(L); /* level out of range */
|
lua_pushnil(L); /* level out of range */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -201,14 +201,15 @@ static int db_getlocal (lua_State *L) {
|
|||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
const char *name;
|
const char *name;
|
||||||
int nvar = luaL_checkint(L, arg+2); /* local-variable index */
|
int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
|
||||||
if (lua_isfunction(L, arg + 1)) { /* function argument? */
|
if (lua_isfunction(L, arg + 1)) { /* function argument? */
|
||||||
lua_pushvalue(L, arg + 1); /* push function */
|
lua_pushvalue(L, arg + 1); /* push function */
|
||||||
lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
|
lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
|
||||||
return 1; /* return only name (there is no value) */
|
return 1; /* return only name (there is no value) */
|
||||||
}
|
}
|
||||||
else { /* stack-level argument */
|
else { /* stack-level argument */
|
||||||
if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
|
int level = (int)luaL_checkinteger(L, arg + 1);
|
||||||
|
if (!lua_getstack(L1, level, &ar)) /* out of range? */
|
||||||
return luaL_argerror(L, arg+1, "level out of range");
|
return luaL_argerror(L, arg+1, "level out of range");
|
||||||
name = lua_getlocal(L1, &ar, nvar);
|
name = lua_getlocal(L1, &ar, nvar);
|
||||||
if (name) {
|
if (name) {
|
||||||
@ -229,12 +230,13 @@ static int db_setlocal (lua_State *L) {
|
|||||||
int arg;
|
int arg;
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
|
int level = (int)luaL_checkinteger(L, arg + 1);
|
||||||
|
if (!lua_getstack(L1, level, &ar)) /* out of range? */
|
||||||
return luaL_argerror(L, arg+1, "level out of range");
|
return luaL_argerror(L, arg+1, "level out of range");
|
||||||
luaL_checkany(L, arg+3);
|
luaL_checkany(L, arg+3);
|
||||||
lua_settop(L, arg+3);
|
lua_settop(L, arg+3);
|
||||||
lua_xmove(L, L1, 1);
|
lua_xmove(L, L1, 1);
|
||||||
lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
|
lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ static int db_setlocal (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
static int auxupvalue (lua_State *L, int get) {
|
static int auxupvalue (lua_State *L, int get) {
|
||||||
const char *name;
|
const char *name;
|
||||||
int n = luaL_checkint(L, 2); /* upvalue index */
|
int n = (int)luaL_checkinteger(L, 2); /* upvalue index */
|
||||||
luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */
|
luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */
|
||||||
name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
|
name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
|
||||||
if (name == NULL) return 0;
|
if (name == NULL) return 0;
|
||||||
@ -270,7 +272,7 @@ static int db_setupvalue (lua_State *L) {
|
|||||||
** returns its index
|
** returns its index
|
||||||
*/
|
*/
|
||||||
static int checkupval (lua_State *L, int argf, int argnup) {
|
static int checkupval (lua_State *L, int argf, int argnup) {
|
||||||
int nup = luaL_checkint(L, argnup); /* upvalue index */
|
int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */
|
||||||
luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */
|
luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */
|
||||||
luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup,
|
luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup,
|
||||||
"invalid upvalue index");
|
"invalid upvalue index");
|
||||||
@ -359,7 +361,7 @@ static int db_sethook (lua_State *L) {
|
|||||||
else {
|
else {
|
||||||
const char *smask = luaL_checkstring(L, arg+2);
|
const char *smask = luaL_checkstring(L, arg+2);
|
||||||
luaL_checktype(L, arg+1, LUA_TFUNCTION);
|
luaL_checktype(L, arg+1, LUA_TFUNCTION);
|
||||||
count = luaL_optint(L, arg+3, 0);
|
count = (int)luaL_optinteger(L, arg + 3, 0);
|
||||||
func = hookf; mask = makemask(smask, count);
|
func = hookf; mask = makemask(smask, count);
|
||||||
}
|
}
|
||||||
if (gethooktable(L) == 0) { /* creating hook table? */
|
if (gethooktable(L) == 0) { /* creating hook table? */
|
||||||
@ -418,7 +420,7 @@ static int db_traceback (lua_State *L) {
|
|||||||
if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
|
if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
|
||||||
lua_pushvalue(L, arg + 1); /* return it untouched */
|
lua_pushvalue(L, arg + 1); /* return it untouched */
|
||||||
else {
|
else {
|
||||||
int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0);
|
int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0);
|
||||||
luaL_traceback(L, L1, msg, level);
|
luaL_traceback(L, L1, msg, level);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.107 2014/07/17 12:30:53 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.108 2014/07/28 17:35:47 roberto Exp roberto $
|
||||||
** Standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -324,7 +324,7 @@ static int math_frexp (lua_State *L) {
|
|||||||
|
|
||||||
static int math_ldexp (lua_State *L) {
|
static int math_ldexp (lua_State *L) {
|
||||||
lua_Number x = luaL_checknumber(L, 1);
|
lua_Number x = luaL_checknumber(L, 1);
|
||||||
int ep = luaL_checkint(L, 2);
|
int ep = (int)luaL_checkinteger(L, 2);
|
||||||
lua_pushnumber(L, l_mathop(ldexp)(x, ep));
|
lua_pushnumber(L, l_mathop(ldexp)(x, ep));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
4
loslib.c
4
loslib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loslib.c,v 1.45 2014/03/20 19:18:54 roberto Exp roberto $
|
** $Id: loslib.c,v 1.46 2014/04/29 17:05:13 roberto Exp roberto $
|
||||||
** Standard Operating System library
|
** Standard Operating System library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -319,7 +319,7 @@ static int os_exit (lua_State *L) {
|
|||||||
if (lua_isboolean(L, 1))
|
if (lua_isboolean(L, 1))
|
||||||
status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
|
status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
else
|
else
|
||||||
status = luaL_optint(L, 1, EXIT_SUCCESS);
|
status = (int)luaL_optinteger(L, 1, EXIT_SUCCESS);
|
||||||
if (lua_toboolean(L, 2))
|
if (lua_toboolean(L, 2))
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */
|
if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.200 2014/07/30 13:59:24 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.201 2014/08/20 22:06:41 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -890,7 +890,7 @@ static int str_format (lua_State *L) {
|
|||||||
strfrmt = scanformat(L, strfrmt, form);
|
strfrmt = scanformat(L, strfrmt, form);
|
||||||
switch (*strfrmt++) {
|
switch (*strfrmt++) {
|
||||||
case 'c': {
|
case 'c': {
|
||||||
nb = sprintf(buff, form, luaL_checkint(L, arg));
|
nb = sprintf(buff, form, (int)luaL_checkinteger(L, arg));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd': case 'i':
|
case 'd': case 'i':
|
||||||
@ -984,11 +984,11 @@ static int getendian (lua_State *L, int arg) {
|
|||||||
|
|
||||||
|
|
||||||
static int getintsize (lua_State *L, int arg) {
|
static int getintsize (lua_State *L, int arg) {
|
||||||
int size = luaL_optint(L, arg, 0);
|
lua_Integer size = luaL_optinteger(L, arg, 0);
|
||||||
if (size == 0) size = SZINT;
|
if (size == 0) size = SZINT;
|
||||||
luaL_argcheck(L, 1 <= size && size <= MAXINTSIZE, arg,
|
luaL_argcheck(L, 1 <= size && size <= MAXINTSIZE, arg,
|
||||||
"integer size out of valid range");
|
"integer size out of valid range");
|
||||||
return size;
|
return (int)size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
18
ltests.c
18
ltests.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.184 2014/09/01 17:58:55 roberto Exp roberto $
|
** $Id: ltests.c,v 2.185 2014/09/04 18:15:29 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -530,7 +530,7 @@ static int listk (lua_State *L) {
|
|||||||
|
|
||||||
static int listlocals (lua_State *L) {
|
static int listlocals (lua_State *L) {
|
||||||
Proto *p;
|
Proto *p;
|
||||||
int pc = luaL_checkint(L, 2) - 1;
|
int pc = (int)luaL_checkinteger(L, 2) - 1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const char *name;
|
const char *name;
|
||||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
||||||
@ -659,7 +659,7 @@ static int stacklevel (lua_State *L) {
|
|||||||
|
|
||||||
static int table_query (lua_State *L) {
|
static int table_query (lua_State *L) {
|
||||||
const Table *t;
|
const Table *t;
|
||||||
int i = luaL_optint(L, 2, -1);
|
int i = (int)luaL_optinteger(L, 2, -1);
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
t = hvalue(obj_at(L, 1));
|
t = hvalue(obj_at(L, 1));
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
@ -692,7 +692,7 @@ static int table_query (lua_State *L) {
|
|||||||
|
|
||||||
static int string_query (lua_State *L) {
|
static int string_query (lua_State *L) {
|
||||||
stringtable *tb = &G(L)->strt;
|
stringtable *tb = &G(L)->strt;
|
||||||
int s = luaL_optint(L, 1, 0) - 1;
|
int s = (int)luaL_optinteger(L, 1, 0) - 1;
|
||||||
if (s == -1) {
|
if (s == -1) {
|
||||||
lua_pushinteger(L ,tb->size);
|
lua_pushinteger(L ,tb->size);
|
||||||
lua_pushinteger(L ,tb->nuse);
|
lua_pushinteger(L ,tb->nuse);
|
||||||
@ -723,21 +723,21 @@ 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_checkint(L, 1));
|
lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1));
|
||||||
lua_assert(lua_gettop(L) == level+1);
|
lua_assert(lua_gettop(L) == level+1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, luaL_checkint(L, 1));
|
luaL_unref(L, LUA_REGISTRYINDEX, (int)luaL_checkinteger(L, 1));
|
||||||
lua_assert(lua_gettop(L) == level);
|
lua_assert(lua_gettop(L) == level);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int upvalue (lua_State *L) {
|
static int upvalue (lua_State *L) {
|
||||||
int n = luaL_checkint(L, 2);
|
int n = (int)luaL_checkinteger(L, 2);
|
||||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||||
if (lua_isnone(L, 3)) {
|
if (lua_isnone(L, 3)) {
|
||||||
const char *name = lua_getupvalue(L, 1, n);
|
const char *name = lua_getupvalue(L, 1, n);
|
||||||
@ -886,7 +886,7 @@ static int doremote (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static int int2fb_aux (lua_State *L) {
|
static int int2fb_aux (lua_State *L) {
|
||||||
int b = luaO_int2fb(luaL_checkint(L, 1));
|
int b = luaO_int2fb((unsigned int)luaL_checkinteger(L, 1));
|
||||||
lua_pushinteger(L, b);
|
lua_pushinteger(L, b);
|
||||||
lua_pushinteger(L, luaO_fb2int(b));
|
lua_pushinteger(L, luaO_fb2int(b));
|
||||||
return 2;
|
return 2;
|
||||||
@ -1389,7 +1389,7 @@ static int sethook (lua_State *L) {
|
|||||||
else {
|
else {
|
||||||
const char *scpt = luaL_checkstring(L, 1);
|
const char *scpt = luaL_checkstring(L, 1);
|
||||||
const char *smask = luaL_checkstring(L, 2);
|
const char *smask = luaL_checkstring(L, 2);
|
||||||
int count = luaL_optint(L, 3, 0);
|
int count = (int)luaL_optinteger(L, 3, 0);
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
||||||
if (strchr(smask, 'r')) mask |= LUA_MASKRET;
|
if (strchr(smask, 'r')) mask |= LUA_MASKRET;
|
||||||
|
4
ltests.h
4
ltests.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.h,v 2.38 2014/07/24 14:00:16 roberto Exp roberto $
|
** $Id: ltests.h,v 2.39 2014/07/24 19:33:29 roberto Exp roberto $
|
||||||
** Internal Header for Debugging of the Lua Implementation
|
** Internal Header for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#undef LUA_COMPAT_MATHLIB
|
#undef LUA_COMPAT_MATHLIB
|
||||||
#undef LUA_COMPAT_IPAIRS
|
#undef LUA_COMPAT_IPAIRS
|
||||||
#undef LUA_COMPAT_BITLIB
|
#undef LUA_COMPAT_BITLIB
|
||||||
#undef LUA_COMPAT_APIUNSIGNED
|
#undef LUA_COMPAT_APIINTCASTS
|
||||||
#undef LUA_COMPAT_FLOATSTRING
|
#undef LUA_COMPAT_FLOATSTRING
|
||||||
#undef LUA_COMPAT_UNPACK
|
#undef LUA_COMPAT_UNPACK
|
||||||
#undef LUA_COMPAT_LOADERS
|
#undef LUA_COMPAT_LOADERS
|
||||||
|
4
lua.h
4
lua.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.313 2014/08/01 17:33:08 roberto Exp roberto $
|
** $Id: lua.h,v 1.314 2014/08/21 20:07:56 roberto Exp roberto $
|
||||||
** Lua - A Scripting Language
|
** Lua - A Scripting Language
|
||||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||||
** See Copyright Notice at the end of this file
|
** See Copyright Notice at the end of this file
|
||||||
@ -379,7 +379,7 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
|
|||||||
** compatibility macros for unsigned conversions
|
** compatibility macros for unsigned conversions
|
||||||
** ===============================================================
|
** ===============================================================
|
||||||
*/
|
*/
|
||||||
#if defined(LUA_COMPAT_APIUNSIGNED)
|
#if defined(LUA_COMPAT_APIINTCASTS)
|
||||||
|
|
||||||
#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
|
#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
|
||||||
#define lua_tounsignedx(L,i,is) ((lua_Integer)lua_tointegerx(L,i,is))
|
#define lua_tounsignedx(L,i,is) ((lua_Integer)lua_tointegerx(L,i,is))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.212 2014/07/24 19:33:29 roberto Exp roberto $
|
** $Id: luaconf.h,v 1.213 2014/08/01 17:33:08 roberto Exp roberto $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -311,10 +311,11 @@
|
|||||||
#define LUA_COMPAT_IPAIRS
|
#define LUA_COMPAT_IPAIRS
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUA_COMPAT_APIUNSIGNED controls the presence of macros for
|
@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
|
||||||
** manipulating unsigned integers (lua_pushunsigned, lua_tounsigned, etc.)
|
** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
|
||||||
|
** luaL_checkint, luaL_checklong, etc.)
|
||||||
*/
|
*/
|
||||||
#define LUA_COMPAT_APIUNSIGNED
|
#define LUA_COMPAT_APIINTCASTS
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user