Explorar o código

easier to define `api_check' using `assert'

Roberto Ierusalimschy %!s(int64=23) %!d(string=hai) anos
pai
achega
ce09af1e25
Modificáronse 1 ficheiros con 12 adicións e 7 borrados
  1. 12 7
      lapi.c

+ 12 - 7
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) {