commit ce09af1e25c1bd033f020f644095ded24216ee30
parent 98d0b79613fadec653baf18eab360e365b364481
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 20 Sep 2002 14:01:02 -0300
easier to define `api_check' using `assert'
Diffstat:
M | lapi.c | | | 19 | ++++++++++++------- |
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,10 +1,11 @@
/*
-** $Id: lapi.c,v 1.211 2002/08/08 20:08:41 roberto Exp roberto $
+** $Id: lapi.c,v 1.212 2002/08/30 19:09:21 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
+#include <assert.h>
#include <string.h>
#include "lua.h"
@@ -32,12 +33,12 @@ const char lua_ident[] =
#ifndef api_check
-#define api_check(L, o) ((void)1)
+#define api_check(L, o) /*{ assert(o); }*/
#endif
#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base))
-#define api_incr_top(L) (api_check(L, L->top<L->ci->top), L->top++)
+#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
@@ -60,10 +61,14 @@ static TObject *negindex (lua_State *L, int index) {
}
-#define luaA_index(L, index) \
- ( (index > 0) ? \
- (api_check(L, index <= L->top - L->ci->base), L->ci->base+index-1) : \
- negindex(L, index))
+static TObject *luaA_index (lua_State *L, int index) {
+ if (index > 0) {
+ api_check(L, index <= L->top - L->ci->base);
+ return L->ci->base + index - 1;
+ }
+ else
+ return negindex(L, index);
+}
static TObject *luaA_indexAcceptable (lua_State *L, int index) {