diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-01-10 10:50:00 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-01-10 10:50:00 -0200 |
commit | dd1221582bc7c0c2ec508b5bad4086f8801b61a8 (patch) | |
tree | 36c896b2dc704cc28edc59c92b83f00319e4e9ea /lapi.c | |
parent | bfdcbbcd76c7187022fe2d35675de0b1c92eeadf (diff) | |
download | lua-dd1221582bc7c0c2ec508b5bad4086f8801b61a8.tar.gz lua-dd1221582bc7c0c2ec508b5bad4086f8801b61a8.tar.bz2 lua-dd1221582bc7c0c2ec508b5bad4086f8801b61a8.zip |
details
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.51 2005/10/20 11:35:50 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.52 2005/12/22 16:19:56 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 | */ |
@@ -40,7 +40,7 @@ const char lua_ident[] = | |||
40 | 40 | ||
41 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) | 41 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) |
42 | 42 | ||
43 | #define api_checkvalidindex(L, i) api_check(L, (i) != &luaO_nilobject) | 43 | #define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) |
44 | 44 | ||
45 | #define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} | 45 | #define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} |
46 | 46 | ||
@@ -50,7 +50,7 @@ static TValue *index2adr (lua_State *L, int idx) { | |||
50 | if (idx > 0) { | 50 | if (idx > 0) { |
51 | TValue *o = L->base + (idx - 1); | 51 | TValue *o = L->base + (idx - 1); |
52 | api_check(L, idx <= L->ci->top - L->base); | 52 | api_check(L, idx <= L->ci->top - L->base); |
53 | if (o >= L->top) return cast(TValue *, &luaO_nilobject); | 53 | if (o >= L->top) return cast(TValue *, luaO_nilobject); |
54 | else return o; | 54 | else return o; |
55 | } | 55 | } |
56 | else if (idx > LUA_REGISTRYINDEX) { | 56 | else if (idx > LUA_REGISTRYINDEX) { |
@@ -70,7 +70,7 @@ static TValue *index2adr (lua_State *L, int idx) { | |||
70 | idx = LUA_GLOBALSINDEX - idx; | 70 | idx = LUA_GLOBALSINDEX - idx; |
71 | return (idx <= func->c.nupvalues) | 71 | return (idx <= func->c.nupvalues) |
72 | ? &func->c.upvalue[idx-1] | 72 | ? &func->c.upvalue[idx-1] |
73 | : cast(TValue *, &luaO_nilobject); | 73 | : cast(TValue *, luaO_nilobject); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | } | 76 | } |
@@ -234,7 +234,7 @@ LUA_API void lua_pushvalue (lua_State *L, int idx) { | |||
234 | 234 | ||
235 | LUA_API int lua_type (lua_State *L, int idx) { | 235 | LUA_API int lua_type (lua_State *L, int idx) { |
236 | StkId o = index2adr(L, idx); | 236 | StkId o = index2adr(L, idx); |
237 | return (o == &luaO_nilobject) ? LUA_TNONE : ttype(o); | 237 | return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
@@ -272,7 +272,7 @@ LUA_API int lua_isuserdata (lua_State *L, int idx) { | |||
272 | LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { | 272 | LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { |
273 | StkId o1 = index2adr(L, index1); | 273 | StkId o1 = index2adr(L, index1); |
274 | StkId o2 = index2adr(L, index2); | 274 | StkId o2 = index2adr(L, index2); |
275 | return (o1 == &luaO_nilobject || o2 == &luaO_nilobject) ? 0 | 275 | return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 |
276 | : luaO_rawequalObj(o1, o2); | 276 | : luaO_rawequalObj(o1, o2); |
277 | } | 277 | } |
278 | 278 | ||
@@ -283,8 +283,7 @@ LUA_API int lua_equal (lua_State *L, int index1, int index2) { | |||
283 | lua_lock(L); /* may call tag method */ | 283 | lua_lock(L); /* may call tag method */ |
284 | o1 = index2adr(L, index1); | 284 | o1 = index2adr(L, index1); |
285 | o2 = index2adr(L, index2); | 285 | o2 = index2adr(L, index2); |
286 | i = (o1 == &luaO_nilobject || o2 == &luaO_nilobject) ? 0 | 286 | i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); |
287 | : equalobj(L, o1, o2); | ||
288 | lua_unlock(L); | 287 | lua_unlock(L); |
289 | return i; | 288 | return i; |
290 | } | 289 | } |
@@ -296,7 +295,7 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { | |||
296 | lua_lock(L); /* may call tag method */ | 295 | lua_lock(L); /* may call tag method */ |
297 | o1 = index2adr(L, index1); | 296 | o1 = index2adr(L, index1); |
298 | o2 = index2adr(L, index2); | 297 | o2 = index2adr(L, index2); |
299 | i = (o1 == &luaO_nilobject || o2 == &luaO_nilobject) ? 0 | 298 | i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 |
300 | : luaV_lessthan(L, o1, o2); | 299 | : luaV_lessthan(L, o1, o2); |
301 | lua_unlock(L); | 300 | lua_unlock(L); |
302 | return i; | 301 | return i; |