mirror of
https://github.com/lua/lua
synced 2024-11-22 12:51:30 +03:00
removed unused parameter Ä'L' in macro 'api_check' and company
This commit is contained in:
parent
d4fb848be7
commit
5bbb4a06a6
78
lapi.c
78
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.223 2014/06/30 19:48:08 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.224 2014/07/15 21:14:49 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -47,29 +47,29 @@ const char lua_ident[] =
|
||||
/* test for valid but not pseudo index */
|
||||
#define isstackindex(i, o) (isvalid(o) && !ispseudo(i))
|
||||
|
||||
#define api_checkvalidindex(L, o) api_check(L, isvalid(o), "invalid index")
|
||||
#define api_checkvalidindex(o) api_check(isvalid(o), "invalid index")
|
||||
|
||||
#define api_checkstackindex(L, i, o) \
|
||||
api_check(L, isstackindex(i, o), "index not in the stack")
|
||||
#define api_checkstackindex(i, o) \
|
||||
api_check(isstackindex(i, o), "index not in the stack")
|
||||
|
||||
|
||||
static TValue *index2addr (lua_State *L, int idx) {
|
||||
CallInfo *ci = L->ci;
|
||||
if (idx > 0) {
|
||||
TValue *o = ci->func + idx;
|
||||
api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index");
|
||||
api_check(idx <= ci->top - (ci->func + 1), "unacceptable index");
|
||||
if (o >= L->top) return NONVALIDVALUE;
|
||||
else return o;
|
||||
}
|
||||
else if (!ispseudo(idx)) { /* negative index */
|
||||
api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index");
|
||||
api_check(idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index");
|
||||
return L->top + idx;
|
||||
}
|
||||
else if (idx == LUA_REGISTRYINDEX)
|
||||
return &G(L)->l_registry;
|
||||
else { /* upvalues */
|
||||
idx = LUA_REGISTRYINDEX - idx;
|
||||
api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large");
|
||||
api_check(idx <= MAXUPVAL + 1, "upvalue index too large");
|
||||
if (ttislcf(ci->func)) /* light C function? */
|
||||
return NONVALIDVALUE; /* it has no upvalues */
|
||||
else {
|
||||
@ -94,7 +94,7 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
|
||||
int res;
|
||||
CallInfo *ci = L->ci;
|
||||
lua_lock(L);
|
||||
api_check(L, size >= 0, "negative 'size'");
|
||||
api_check(size >= 0, "negative 'size'");
|
||||
if (L->stack_last - L->top > size) /* stack large enough? */
|
||||
res = 1; /* yes; check is OK */
|
||||
else { /* no; need to grow stack */
|
||||
@ -116,8 +116,8 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
|
||||
if (from == to) return;
|
||||
lua_lock(to);
|
||||
api_checknelems(from, n);
|
||||
api_check(from, G(from) == G(to), "moving among independent states");
|
||||
api_check(from, to->ci->top - to->top >= n, "not enough elements to move");
|
||||
api_check(G(from) == G(to), "moving among independent states");
|
||||
api_check(to->ci->top - to->top >= n, "not enough elements to move");
|
||||
from->top -= n;
|
||||
for (i = 0; i < n; i++) {
|
||||
setobj2s(to, to->top++, from->top + i);
|
||||
@ -168,13 +168,13 @@ LUA_API void lua_settop (lua_State *L, int idx) {
|
||||
StkId func = L->ci->func;
|
||||
lua_lock(L);
|
||||
if (idx >= 0) {
|
||||
api_check(L, idx <= L->stack_last - (func + 1), "new top too large");
|
||||
api_check(idx <= L->stack_last - (func + 1), "new top too large");
|
||||
while (L->top < (func + 1) + idx)
|
||||
setnilvalue(L->top++);
|
||||
L->top = (func + 1) + idx;
|
||||
}
|
||||
else {
|
||||
api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
|
||||
api_check(-(idx+1) <= (L->top - (func + 1)), "invalid new top");
|
||||
L->top += idx+1; /* `subtract' index (index is negative) */
|
||||
}
|
||||
lua_unlock(L);
|
||||
@ -204,8 +204,8 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) {
|
||||
lua_lock(L);
|
||||
t = L->top - 1; /* end of stack segment being rotated */
|
||||
p = index2addr(L, idx); /* start of segment */
|
||||
api_checkstackindex(L, idx, p);
|
||||
api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
|
||||
api_checkstackindex(idx, p);
|
||||
api_check((n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
|
||||
m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
|
||||
reverse(L, p, m); /* reverse the prefix with length 'n' */
|
||||
reverse(L, m + 1, t); /* reverse the suffix */
|
||||
@ -216,7 +216,7 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) {
|
||||
|
||||
static void moveto (lua_State *L, TValue *fr, int idx) {
|
||||
TValue *to = index2addr(L, idx);
|
||||
api_checkvalidindex(L, to);
|
||||
api_checkvalidindex(to);
|
||||
setobj(L, to, fr);
|
||||
if (idx < LUA_REGISTRYINDEX) /* function upvalue? */
|
||||
luaC_barrier(L, clCvalue(L->ci->func), fr);
|
||||
@ -264,8 +264,8 @@ LUA_API int lua_type (lua_State *L, int idx) {
|
||||
|
||||
|
||||
LUA_API const char *lua_typename (lua_State *L, int t) {
|
||||
(void)L;
|
||||
api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag");
|
||||
UNUSED(L);
|
||||
api_check(LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag");
|
||||
return ttypename(t);
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
|
||||
case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
|
||||
case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
|
||||
case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
|
||||
default: api_check(L, 0, "invalid option");
|
||||
default: api_check(0, "invalid option");
|
||||
}
|
||||
}
|
||||
lua_unlock(L);
|
||||
@ -541,7 +541,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
|
||||
else {
|
||||
CClosure *cl;
|
||||
api_checknelems(L, n);
|
||||
api_check(L, n <= MAXUPVAL, "upvalue index too large");
|
||||
api_check(n <= MAXUPVAL, "upvalue index too large");
|
||||
luaC_checkGC(L);
|
||||
cl = luaF_newCclosure(L, n);
|
||||
cl->f = fn;
|
||||
@ -626,7 +626,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) {
|
||||
StkId t;
|
||||
lua_lock(L);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
|
||||
lua_unlock(L);
|
||||
return ttnov(L->top - 1);
|
||||
@ -637,7 +637,7 @@ LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
|
||||
StkId t;
|
||||
lua_lock(L);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
setobj2s(L, L->top, luaH_getint(hvalue(t), n));
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
@ -650,7 +650,7 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
|
||||
TValue k;
|
||||
lua_lock(L);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
setpvalue(&k, cast(void *, p));
|
||||
setobj2s(L, L->top, luaH_get(hvalue(t), &k));
|
||||
api_incr_top(L);
|
||||
@ -705,7 +705,7 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) {
|
||||
StkId o;
|
||||
lua_lock(L);
|
||||
o = index2addr(L, idx);
|
||||
api_check(L, ttisfulluserdata(o), "full userdata expected");
|
||||
api_check(ttisfulluserdata(o), "full userdata expected");
|
||||
getuservalue(L, rawuvalue(o), L->top);
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
@ -759,7 +759,7 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 2);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
|
||||
invalidateTMcache(hvalue(t));
|
||||
luaC_barrierback(L, gcvalue(t), L->top-1);
|
||||
@ -773,7 +773,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) {
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
luaH_setint(L, hvalue(t), n, L->top - 1);
|
||||
luaC_barrierback(L, gcvalue(t), L->top-1);
|
||||
L->top--;
|
||||
@ -787,7 +787,7 @@ LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) {
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
setpvalue(&k, cast(void *, p));
|
||||
setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1);
|
||||
luaC_barrierback(L, gcvalue(t), L->top - 1);
|
||||
@ -805,7 +805,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
|
||||
if (ttisnil(L->top - 1))
|
||||
mt = NULL;
|
||||
else {
|
||||
api_check(L, ttistable(L->top - 1), "table expected");
|
||||
api_check(ttistable(L->top - 1), "table expected");
|
||||
mt = hvalue(L->top - 1);
|
||||
}
|
||||
switch (ttnov(obj)) {
|
||||
@ -841,7 +841,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
o = index2addr(L, idx);
|
||||
api_check(L, ttisfulluserdata(o), "full userdata expected");
|
||||
api_check(ttisfulluserdata(o), "full userdata expected");
|
||||
setuservalue(L, rawuvalue(o), L->top - 1);
|
||||
luaC_barrier(L, gcvalue(o), L->top - 1);
|
||||
L->top--;
|
||||
@ -855,7 +855,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
|
||||
|
||||
|
||||
#define checkresults(L,na,nr) \
|
||||
api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \
|
||||
api_check((nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \
|
||||
"results from function overflow current stack size")
|
||||
|
||||
|
||||
@ -863,10 +863,10 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx,
|
||||
lua_KFunction k) {
|
||||
StkId func;
|
||||
lua_lock(L);
|
||||
api_check(L, k == NULL || !isLua(L->ci),
|
||||
api_check(k == NULL || !isLua(L->ci),
|
||||
"cannot use continuations inside hooks");
|
||||
api_checknelems(L, nargs+1);
|
||||
api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
|
||||
api_check(L->status == LUA_OK, "cannot do calls on non-normal thread");
|
||||
checkresults(L, nargs, nresults);
|
||||
func = L->top - (nargs+1);
|
||||
if (k != NULL && L->nny == 0) { /* need to prepare continuation? */
|
||||
@ -904,16 +904,16 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
|
||||
int status;
|
||||
ptrdiff_t func;
|
||||
lua_lock(L);
|
||||
api_check(L, k == NULL || !isLua(L->ci),
|
||||
api_check(k == NULL || !isLua(L->ci),
|
||||
"cannot use continuations inside hooks");
|
||||
api_checknelems(L, nargs+1);
|
||||
api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
|
||||
api_check(L->status == LUA_OK, "cannot do calls on non-normal thread");
|
||||
checkresults(L, nargs, nresults);
|
||||
if (errfunc == 0)
|
||||
func = 0;
|
||||
else {
|
||||
StkId o = index2addr(L, errfunc);
|
||||
api_checkstackindex(L, errfunc, o);
|
||||
api_checkstackindex(errfunc, o);
|
||||
func = savestack(L, o);
|
||||
}
|
||||
c.func = L->top - (nargs+1); /* function to be called */
|
||||
@ -1078,7 +1078,7 @@ LUA_API int lua_next (lua_State *L, int idx) {
|
||||
int more;
|
||||
lua_lock(L);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
api_check(ttistable(t), "table expected");
|
||||
more = luaH_next(L, hvalue(t), L->top - 1);
|
||||
if (more) {
|
||||
api_incr_top(L);
|
||||
@ -1210,9 +1210,9 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
|
||||
static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
|
||||
LClosure *f;
|
||||
StkId fi = index2addr(L, fidx);
|
||||
api_check(L, ttisLclosure(fi), "Lua function expected");
|
||||
api_check(ttisLclosure(fi), "Lua function expected");
|
||||
f = clLvalue(fi);
|
||||
api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
|
||||
api_check((1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
|
||||
if (pf) *pf = f;
|
||||
return &f->upvals[n - 1]; /* get its upvalue pointer */
|
||||
}
|
||||
@ -1226,11 +1226,11 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
|
||||
}
|
||||
case LUA_TCCL: { /* C closure */
|
||||
CClosure *f = clCvalue(fi);
|
||||
api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index");
|
||||
api_check(1 <= n && n <= f->nupvalues, "invalid upvalue index");
|
||||
return &f->upvalue[n - 1];
|
||||
}
|
||||
default: {
|
||||
api_check(L, 0, "closure expected");
|
||||
api_check(0, "closure expected");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
6
lapi.h
6
lapi.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.h,v 2.6 2009/08/31 14:26:28 roberto Exp roberto $
|
||||
** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp roberto $
|
||||
** Auxiliary functions from Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -11,13 +11,13 @@
|
||||
#include "llimits.h"
|
||||
#include "lstate.h"
|
||||
|
||||
#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
|
||||
#define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \
|
||||
"stack overflow");}
|
||||
|
||||
#define adjustresults(L,nres) \
|
||||
{ if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
|
||||
|
||||
#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
|
||||
#define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \
|
||||
"not enough elements in the stack")
|
||||
|
||||
|
||||
|
4
ldebug.c
4
ldebug.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldebug.c,v 2.96 2013/07/10 20:32:36 roberto Exp roberto $
|
||||
** $Id: ldebug.c,v 2.97 2013/12/09 14:21:10 roberto Exp roberto $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -271,7 +271,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
||||
if (*what == '>') {
|
||||
ci = NULL;
|
||||
func = L->top - 1;
|
||||
api_check(L, ttisfunction(func), "function expected");
|
||||
api_check(ttisfunction(func), "function expected");
|
||||
what++; /* skip the '>' */
|
||||
L->top--; /* pop function */
|
||||
}
|
||||
|
4
ldo.c
4
ldo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldo.c,v 2.123 2014/06/19 18:27:20 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 2.124 2014/06/30 19:48:08 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -607,7 +607,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_KFunction k) {
|
||||
L->status = LUA_YIELD;
|
||||
ci->extra = savestack(L, ci->func); /* save current 'func' */
|
||||
if (isLua(ci)) { /* inside a hook? */
|
||||
api_check(L, k == NULL, "hooks cannot continue after yielding");
|
||||
api_check(k == NULL, "hooks cannot continue after yielding");
|
||||
}
|
||||
else {
|
||||
if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
|
||||
|
11
llimits.h
11
llimits.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llimits.h,v 1.116 2014/04/15 16:32:49 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.117 2014/06/26 16:17:35 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -79,18 +79,15 @@ typedef LUAI_UACINT l_uacInt;
|
||||
/*
|
||||
** assertion for checking API calls
|
||||
*/
|
||||
#if !defined(luai_apicheck)
|
||||
|
||||
#if defined(LUA_USE_APICHECK)
|
||||
#include <assert.h>
|
||||
#define luai_apicheck(L,e) assert(e)
|
||||
#define luai_apicheck(e) assert(e)
|
||||
#else
|
||||
#define luai_apicheck(L,e) lua_assert(e)
|
||||
#define luai_apicheck(e) lua_assert(e)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define api_check(l,e,msg) luai_apicheck(l,(e) && msg)
|
||||
#define api_check(e,msg) luai_apicheck((e) && msg)
|
||||
|
||||
|
||||
#if !defined(UNUSED)
|
||||
|
4
lmem.c
4
lmem.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmem.c,v 1.84 2012/05/23 15:41:53 roberto Exp roberto $
|
||||
** $Id: lmem.c,v 1.85 2014/06/26 18:29:05 roberto Exp roberto $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -83,7 +83,7 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
|
||||
#endif
|
||||
newblock = (*g->frealloc)(g->ud, block, osize, nsize);
|
||||
if (newblock == NULL && nsize > 0) {
|
||||
api_check(L, nsize > realosize,
|
||||
api_check( nsize > realosize,
|
||||
"realloc cannot fail when shrinking a block");
|
||||
luaC_fullgc(L, 1); /* try to free some memory... */
|
||||
newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
|
||||
|
Loading…
Reference in New Issue
Block a user