diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-09-20 14:01:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-09-20 14:01:24 -0300 |
commit | ce09af1e25c1bd033f020f644095ded24216ee30 (patch) | |
tree | 4cb1b5a07f4e785b7aad0b41d5bea123798089e0 /lapi.c | |
parent | 98d0b79613fadec653baf18eab360e365b364481 (diff) | |
download | lua-ce09af1e25c1bd033f020f644095ded24216ee30.tar.gz lua-ce09af1e25c1bd033f020f644095ded24216ee30.tar.bz2 lua-ce09af1e25c1bd033f020f644095ded24216ee30.zip |
easier to define `api_check' using `assert'
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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) \ | 64 | static 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 | ||
69 | static TObject *luaA_indexAcceptable (lua_State *L, int index) { | 74 | static TObject *luaA_indexAcceptable (lua_State *L, int index) { |