aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-09-20 14:01:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-09-20 14:01:24 -0300
commitce09af1e25c1bd033f020f644095ded24216ee30 (patch)
tree4cb1b5a07f4e785b7aad0b41d5bea123798089e0
parent98d0b79613fadec653baf18eab360e365b364481 (diff)
downloadlua-ce09af1e25c1bd033f020f644095ded24216ee30.tar.gz
lua-ce09af1e25c1bd033f020f644095ded24216ee30.tar.bz2
lua-ce09af1e25c1bd033f020f644095ded24216ee30.zip
easier to define `api_check' using `assert'
-rw-r--r--lapi.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/lapi.c b/lapi.c
index 012db0aa..a74c84fd 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,10 +1,11 @@
1/* 1/*
2** $Id: lapi.c,v 1.211 2002/08/08 20:08:41 roberto Exp roberto $ 2** $Id: lapi.c,v 1.212 2002/08/30 19:09:21 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7 7
8#include <assert.h>
8#include <string.h> 9#include <string.h>
9 10
10#include "lua.h" 11#include "lua.h"
@@ -32,12 +33,12 @@ const char lua_ident[] =
32 33
33 34
34#ifndef api_check 35#ifndef api_check
35#define api_check(L, o) ((void)1) 36#define api_check(L, o) /*{ assert(o); }*/
36#endif 37#endif
37 38
38#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) 39#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base))
39 40
40#define api_incr_top(L) (api_check(L, L->top<L->ci->top), L->top++) 41#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
41 42
42 43
43 44
@@ -60,10 +61,14 @@ static TObject *negindex (lua_State *L, int index) {
60} 61}
61 62
62 63
63#define luaA_index(L, index) \ 64static TObject *luaA_index (lua_State *L, int index) {
64 ( (index > 0) ? \ 65 if (index > 0) {
65 (api_check(L, index <= L->top - L->ci->base), L->ci->base+index-1) : \ 66 api_check(L, index <= L->top - L->ci->base);
66 negindex(L, index)) 67 return L->ci->base + index - 1;
68 }
69 else
70 return negindex(L, index);
71}
67 72
68 73
69static TObject *luaA_indexAcceptable (lua_State *L, int index) { 74static TObject *luaA_indexAcceptable (lua_State *L, int index) {