diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-05 11:50:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-05 11:50:39 -0300 |
commit | 5037196f6fddb828056578b1c0d352cdef672d6a (patch) | |
tree | d1be52a5ad8fd5cebf30f7023a9c66b7bdc9563f /lapi.c | |
parent | 9fb80bde3c80557f8ad2d5642bcbeac343999994 (diff) | |
download | lua-5037196f6fddb828056578b1c0d352cdef672d6a.tar.gz lua-5037196f6fddb828056578b1c0d352cdef672d6a.tar.bz2 lua-5037196f6fddb828056578b1c0d352cdef672d6a.zip |
new macros `ttis*'
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.204 2002/06/26 19:28:44 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.205 2002/07/17 16:25:13 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 | */ |
@@ -266,7 +266,7 @@ LUA_API const char *lua_tostring (lua_State *L, int index) { | |||
266 | StkId o = luaA_indexAcceptable(L, index); | 266 | StkId o = luaA_indexAcceptable(L, index); |
267 | if (o == NULL) | 267 | if (o == NULL) |
268 | return NULL; | 268 | return NULL; |
269 | else if (ttype(o) == LUA_TSTRING) | 269 | else if (ttisstring(o)) |
270 | return svalue(o); | 270 | return svalue(o); |
271 | else { | 271 | else { |
272 | const char *s; | 272 | const char *s; |
@@ -282,7 +282,7 @@ LUA_API size_t lua_strlen (lua_State *L, int index) { | |||
282 | StkId o = luaA_indexAcceptable(L, index); | 282 | StkId o = luaA_indexAcceptable(L, index); |
283 | if (o == NULL) | 283 | if (o == NULL) |
284 | return 0; | 284 | return 0; |
285 | else if (ttype(o) == LUA_TSTRING) | 285 | else if (ttisstring(o)) |
286 | return tsvalue(o)->tsv.len; | 286 | return tsvalue(o)->tsv.len; |
287 | else { | 287 | else { |
288 | size_t l; | 288 | size_t l; |
@@ -439,7 +439,7 @@ LUA_API void lua_rawget (lua_State *L, int index) { | |||
439 | StkId t; | 439 | StkId t; |
440 | lua_lock(L); | 440 | lua_lock(L); |
441 | t = luaA_index(L, index); | 441 | t = luaA_index(L, index); |
442 | api_check(L, ttype(t) == LUA_TTABLE); | 442 | api_check(L, ttistable(t)); |
443 | setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1)); | 443 | setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1)); |
444 | lua_unlock(L); | 444 | lua_unlock(L); |
445 | } | 445 | } |
@@ -449,7 +449,7 @@ LUA_API void lua_rawgeti (lua_State *L, int index, int n) { | |||
449 | StkId o; | 449 | StkId o; |
450 | lua_lock(L); | 450 | lua_lock(L); |
451 | o = luaA_index(L, index); | 451 | o = luaA_index(L, index); |
452 | api_check(L, ttype(o) == LUA_TTABLE); | 452 | api_check(L, ttistable(o)); |
453 | setobj(L->top, luaH_getnum(hvalue(o), n)); | 453 | setobj(L->top, luaH_getnum(hvalue(o), n)); |
454 | api_incr_top(L); | 454 | api_incr_top(L); |
455 | lua_unlock(L); | 455 | lua_unlock(L); |
@@ -536,7 +536,7 @@ LUA_API void lua_rawset (lua_State *L, int index) { | |||
536 | lua_lock(L); | 536 | lua_lock(L); |
537 | api_checknelems(L, 2); | 537 | api_checknelems(L, 2); |
538 | t = luaA_index(L, index); | 538 | t = luaA_index(L, index); |
539 | api_check(L, ttype(t) == LUA_TTABLE); | 539 | api_check(L, ttistable(t)); |
540 | setobj(luaH_set(L, hvalue(t), L->top-2), L->top-1); | 540 | setobj(luaH_set(L, hvalue(t), L->top-2), L->top-1); |
541 | L->top -= 2; | 541 | L->top -= 2; |
542 | lua_unlock(L); | 542 | lua_unlock(L); |
@@ -548,7 +548,7 @@ LUA_API void lua_rawseti (lua_State *L, int index, int n) { | |||
548 | lua_lock(L); | 548 | lua_lock(L); |
549 | api_checknelems(L, 1); | 549 | api_checknelems(L, 1); |
550 | o = luaA_index(L, index); | 550 | o = luaA_index(L, index); |
551 | api_check(L, ttype(o) == LUA_TTABLE); | 551 | api_check(L, ttistable(o)); |
552 | setobj(luaH_setnum(L, hvalue(o), n), L->top-1); | 552 | setobj(luaH_setnum(L, hvalue(o), n), L->top-1); |
553 | L->top--; | 553 | L->top--; |
554 | lua_unlock(L); | 554 | lua_unlock(L); |
@@ -561,8 +561,8 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { | |||
561 | lua_lock(L); | 561 | lua_lock(L); |
562 | api_checknelems(L, 1); | 562 | api_checknelems(L, 1); |
563 | obj = luaA_index(L, objindex); | 563 | obj = luaA_index(L, objindex); |
564 | mt = (ttype(L->top - 1) != LUA_TNIL) ? L->top - 1 : defaultmeta(L); | 564 | mt = (!ttisnil(L->top - 1)) ? L->top - 1 : defaultmeta(L); |
565 | api_check(L, ttype(mt) == LUA_TTABLE); | 565 | api_check(L, ttistable(mt)); |
566 | switch (ttype(obj)) { | 566 | switch (ttype(obj)) { |
567 | case LUA_TTABLE: { | 567 | case LUA_TTABLE: { |
568 | hvalue(obj)->metatable = hvalue(mt); | 568 | hvalue(obj)->metatable = hvalue(mt); |
@@ -589,7 +589,7 @@ LUA_API int lua_setglobals (lua_State *L, int level) { | |||
589 | api_checknelems(L, 1); | 589 | api_checknelems(L, 1); |
590 | f = getfunc(L, level); | 590 | f = getfunc(L, level); |
591 | L->top--; | 591 | L->top--; |
592 | api_check(L, ttype(L->top) == LUA_TTABLE); | 592 | api_check(L, ttistable(L->top)); |
593 | if (f) f->g = *(L->top); | 593 | if (f) f->g = *(L->top); |
594 | lua_unlock(L); | 594 | lua_unlock(L); |
595 | return (f != NULL); | 595 | return (f != NULL); |
@@ -619,6 +619,13 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults) { | |||
619 | } | 619 | } |
620 | 620 | ||
621 | 621 | ||
622 | LUA_API void lua_pcallreset (lua_State *L) { | ||
623 | lua_lock(L); | ||
624 | luaD_resetprotection(L); /* reset error handler */ | ||
625 | lua_unlock(L); | ||
626 | } | ||
627 | |||
628 | |||
622 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, | 629 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, |
623 | const char *chunkname) { | 630 | const char *chunkname) { |
624 | ZIO z; | 631 | ZIO z; |
@@ -688,7 +695,7 @@ LUA_API int lua_next (lua_State *L, int index) { | |||
688 | int more; | 695 | int more; |
689 | lua_lock(L); | 696 | lua_lock(L); |
690 | t = luaA_index(L, index); | 697 | t = luaA_index(L, index); |
691 | api_check(L, ttype(t) == LUA_TTABLE); | 698 | api_check(L, ttistable(t)); |
692 | more = luaH_next(L, hvalue(t), L->top - 1); | 699 | more = luaH_next(L, hvalue(t), L->top - 1); |
693 | if (more) { | 700 | if (more) { |
694 | api_incr_top(L); | 701 | api_incr_top(L); |