diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-06 16:49:50 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-06 16:49:50 -0300 |
| commit | a30c66f0fc17bf733c2289a0d7a76930dac80f47 (patch) | |
| tree | 96d7e5fff8245da7540d14818adc28f420036b26 /lapi.c | |
| parent | bb4baa73ea85c0fd49ab2ab96f0f174cd131830a (diff) | |
| download | lua-a30c66f0fc17bf733c2289a0d7a76930dac80f47.tar.gz lua-a30c66f0fc17bf733c2289a0d7a76930dac80f47.tar.bz2 lua-a30c66f0fc17bf733c2289a0d7a76930dac80f47.zip | |
macro 'luai_apicheck'/'api_check' back with a 'lua_State' parameter
(some people use it)
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 76 |
1 files changed, 38 insertions, 38 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.245 2015/01/16 16:54:37 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.246 2015/02/11 18:47:22 roberto Exp $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -51,29 +51,29 @@ const char lua_ident[] = | |||
| 51 | /* test for valid but not pseudo index */ | 51 | /* test for valid but not pseudo index */ |
| 52 | #define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) | 52 | #define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) |
| 53 | 53 | ||
| 54 | #define api_checkvalidindex(o) api_check(isvalid(o), "invalid index") | 54 | #define api_checkvalidindex(l,o) api_check(l, isvalid(o), "invalid index") |
| 55 | 55 | ||
| 56 | #define api_checkstackindex(i, o) \ | 56 | #define api_checkstackindex(l, i, o) \ |
| 57 | api_check(isstackindex(i, o), "index not in the stack") | 57 | api_check(l, isstackindex(i, o), "index not in the stack") |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | static TValue *index2addr (lua_State *L, int idx) { | 60 | static TValue *index2addr (lua_State *L, int idx) { |
| 61 | CallInfo *ci = L->ci; | 61 | CallInfo *ci = L->ci; |
| 62 | if (idx > 0) { | 62 | if (idx > 0) { |
| 63 | TValue *o = ci->func + idx; | 63 | TValue *o = ci->func + idx; |
| 64 | api_check(idx <= ci->top - (ci->func + 1), "unacceptable index"); | 64 | api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index"); |
| 65 | if (o >= L->top) return NONVALIDVALUE; | 65 | if (o >= L->top) return NONVALIDVALUE; |
| 66 | else return o; | 66 | else return o; |
| 67 | } | 67 | } |
| 68 | else if (!ispseudo(idx)) { /* negative index */ | 68 | else if (!ispseudo(idx)) { /* negative index */ |
| 69 | api_check(idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); | 69 | api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); |
| 70 | return L->top + idx; | 70 | return L->top + idx; |
| 71 | } | 71 | } |
| 72 | else if (idx == LUA_REGISTRYINDEX) | 72 | else if (idx == LUA_REGISTRYINDEX) |
| 73 | return &G(L)->l_registry; | 73 | return &G(L)->l_registry; |
| 74 | else { /* upvalues */ | 74 | else { /* upvalues */ |
| 75 | idx = LUA_REGISTRYINDEX - idx; | 75 | idx = LUA_REGISTRYINDEX - idx; |
| 76 | api_check(idx <= MAXUPVAL + 1, "upvalue index too large"); | 76 | api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); |
| 77 | if (ttislcf(ci->func)) /* light C function? */ | 77 | if (ttislcf(ci->func)) /* light C function? */ |
| 78 | return NONVALIDVALUE; /* it has no upvalues */ | 78 | return NONVALIDVALUE; /* it has no upvalues */ |
| 79 | else { | 79 | else { |
| @@ -98,7 +98,7 @@ LUA_API int lua_checkstack (lua_State *L, int n) { | |||
| 98 | int res; | 98 | int res; |
| 99 | CallInfo *ci = L->ci; | 99 | CallInfo *ci = L->ci; |
| 100 | lua_lock(L); | 100 | lua_lock(L); |
| 101 | api_check(n >= 0, "negative 'n'"); | 101 | api_check(L, n >= 0, "negative 'n'"); |
| 102 | if (L->stack_last - L->top > n) /* stack large enough? */ | 102 | if (L->stack_last - L->top > n) /* stack large enough? */ |
| 103 | res = 1; /* yes; check is OK */ | 103 | res = 1; /* yes; check is OK */ |
| 104 | else { /* no; need to grow stack */ | 104 | else { /* no; need to grow stack */ |
| @@ -120,8 +120,8 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { | |||
| 120 | if (from == to) return; | 120 | if (from == to) return; |
| 121 | lua_lock(to); | 121 | lua_lock(to); |
| 122 | api_checknelems(from, n); | 122 | api_checknelems(from, n); |
| 123 | api_check(G(from) == G(to), "moving among independent states"); | 123 | api_check(from, G(from) == G(to), "moving among independent states"); |
| 124 | api_check(to->ci->top - to->top >= n, "not enough elements to move"); | 124 | api_check(from, to->ci->top - to->top >= n, "not enough elements to move"); |
| 125 | from->top -= n; | 125 | from->top -= n; |
| 126 | for (i = 0; i < n; i++) { | 126 | for (i = 0; i < n; i++) { |
| 127 | setobj2s(to, to->top, from->top + i); | 127 | setobj2s(to, to->top, from->top + i); |
| @@ -173,13 +173,13 @@ LUA_API void lua_settop (lua_State *L, int idx) { | |||
| 173 | StkId func = L->ci->func; | 173 | StkId func = L->ci->func; |
| 174 | lua_lock(L); | 174 | lua_lock(L); |
| 175 | if (idx >= 0) { | 175 | if (idx >= 0) { |
| 176 | api_check(idx <= L->stack_last - (func + 1), "new top too large"); | 176 | api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); |
| 177 | while (L->top < (func + 1) + idx) | 177 | while (L->top < (func + 1) + idx) |
| 178 | setnilvalue(L->top++); | 178 | setnilvalue(L->top++); |
| 179 | L->top = (func + 1) + idx; | 179 | L->top = (func + 1) + idx; |
| 180 | } | 180 | } |
| 181 | else { | 181 | else { |
| 182 | api_check(-(idx+1) <= (L->top - (func + 1)), "invalid new top"); | 182 | api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); |
| 183 | L->top += idx+1; /* 'subtract' index (index is negative) */ | 183 | L->top += idx+1; /* 'subtract' index (index is negative) */ |
| 184 | } | 184 | } |
| 185 | lua_unlock(L); | 185 | lua_unlock(L); |
| @@ -209,8 +209,8 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) { | |||
| 209 | lua_lock(L); | 209 | lua_lock(L); |
| 210 | t = L->top - 1; /* end of stack segment being rotated */ | 210 | t = L->top - 1; /* end of stack segment being rotated */ |
| 211 | p = index2addr(L, idx); /* start of segment */ | 211 | p = index2addr(L, idx); /* start of segment */ |
| 212 | api_checkstackindex(idx, p); | 212 | api_checkstackindex(L, idx, p); |
| 213 | api_check((n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); | 213 | api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); |
| 214 | m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ | 214 | m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ |
| 215 | reverse(L, p, m); /* reverse the prefix with length 'n' */ | 215 | reverse(L, p, m); /* reverse the prefix with length 'n' */ |
| 216 | reverse(L, m + 1, t); /* reverse the suffix */ | 216 | reverse(L, m + 1, t); /* reverse the suffix */ |
| @@ -224,7 +224,7 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { | |||
| 224 | lua_lock(L); | 224 | lua_lock(L); |
| 225 | fr = index2addr(L, fromidx); | 225 | fr = index2addr(L, fromidx); |
| 226 | to = index2addr(L, toidx); | 226 | to = index2addr(L, toidx); |
| 227 | api_checkvalidindex(to); | 227 | api_checkvalidindex(L, to); |
| 228 | setobj(L, to, fr); | 228 | setobj(L, to, fr); |
| 229 | if (isupvalue(toidx)) /* function upvalue? */ | 229 | if (isupvalue(toidx)) /* function upvalue? */ |
| 230 | luaC_barrier(L, clCvalue(L->ci->func), fr); | 230 | luaC_barrier(L, clCvalue(L->ci->func), fr); |
| @@ -256,7 +256,7 @@ LUA_API int lua_type (lua_State *L, int idx) { | |||
| 256 | 256 | ||
| 257 | LUA_API const char *lua_typename (lua_State *L, int t) { | 257 | LUA_API const char *lua_typename (lua_State *L, int t) { |
| 258 | UNUSED(L); | 258 | UNUSED(L); |
| 259 | api_check(LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); | 259 | api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); |
| 260 | return ttypename(t); | 260 | return ttypename(t); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| @@ -326,7 +326,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { | |||
| 326 | case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; | 326 | case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; |
| 327 | case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; | 327 | case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; |
| 328 | case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; | 328 | case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; |
| 329 | default: api_check(0, "invalid option"); | 329 | default: api_check(L, 0, "invalid option"); |
| 330 | } | 330 | } |
| 331 | } | 331 | } |
| 332 | lua_unlock(L); | 332 | lua_unlock(L); |
| @@ -534,7 +534,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | |||
| 534 | else { | 534 | else { |
| 535 | CClosure *cl; | 535 | CClosure *cl; |
| 536 | api_checknelems(L, n); | 536 | api_checknelems(L, n); |
| 537 | api_check(n <= MAXUPVAL, "upvalue index too large"); | 537 | api_check(L, n <= MAXUPVAL, "upvalue index too large"); |
| 538 | luaC_checkGC(L); | 538 | luaC_checkGC(L); |
| 539 | cl = luaF_newCclosure(L, n); | 539 | cl = luaF_newCclosure(L, n); |
| 540 | cl->f = fn; | 540 | cl->f = fn; |
| @@ -632,7 +632,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) { | |||
| 632 | StkId t; | 632 | StkId t; |
| 633 | lua_lock(L); | 633 | lua_lock(L); |
| 634 | t = index2addr(L, idx); | 634 | t = index2addr(L, idx); |
| 635 | api_check(ttistable(t), "table expected"); | 635 | api_check(L, ttistable(t), "table expected"); |
| 636 | setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); | 636 | setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); |
| 637 | lua_unlock(L); | 637 | lua_unlock(L); |
| 638 | return ttnov(L->top - 1); | 638 | return ttnov(L->top - 1); |
| @@ -643,7 +643,7 @@ LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) { | |||
| 643 | StkId t; | 643 | StkId t; |
| 644 | lua_lock(L); | 644 | lua_lock(L); |
| 645 | t = index2addr(L, idx); | 645 | t = index2addr(L, idx); |
| 646 | api_check(ttistable(t), "table expected"); | 646 | api_check(L, ttistable(t), "table expected"); |
| 647 | setobj2s(L, L->top, luaH_getint(hvalue(t), n)); | 647 | setobj2s(L, L->top, luaH_getint(hvalue(t), n)); |
| 648 | api_incr_top(L); | 648 | api_incr_top(L); |
| 649 | lua_unlock(L); | 649 | lua_unlock(L); |
| @@ -656,7 +656,7 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) { | |||
| 656 | TValue k; | 656 | TValue k; |
| 657 | lua_lock(L); | 657 | lua_lock(L); |
| 658 | t = index2addr(L, idx); | 658 | t = index2addr(L, idx); |
| 659 | api_check(ttistable(t), "table expected"); | 659 | api_check(L, ttistable(t), "table expected"); |
| 660 | setpvalue(&k, cast(void *, p)); | 660 | setpvalue(&k, cast(void *, p)); |
| 661 | setobj2s(L, L->top, luaH_get(hvalue(t), &k)); | 661 | setobj2s(L, L->top, luaH_get(hvalue(t), &k)); |
| 662 | api_incr_top(L); | 662 | api_incr_top(L); |
| @@ -709,7 +709,7 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) { | |||
| 709 | StkId o; | 709 | StkId o; |
| 710 | lua_lock(L); | 710 | lua_lock(L); |
| 711 | o = index2addr(L, idx); | 711 | o = index2addr(L, idx); |
| 712 | api_check(ttisfulluserdata(o), "full userdata expected"); | 712 | api_check(L, ttisfulluserdata(o), "full userdata expected"); |
| 713 | getuservalue(L, uvalue(o), L->top); | 713 | getuservalue(L, uvalue(o), L->top); |
| 714 | api_incr_top(L); | 714 | api_incr_top(L); |
| 715 | lua_unlock(L); | 715 | lua_unlock(L); |
| @@ -779,7 +779,7 @@ LUA_API void lua_rawset (lua_State *L, int idx) { | |||
| 779 | lua_lock(L); | 779 | lua_lock(L); |
| 780 | api_checknelems(L, 2); | 780 | api_checknelems(L, 2); |
| 781 | o = index2addr(L, idx); | 781 | o = index2addr(L, idx); |
| 782 | api_check(ttistable(o), "table expected"); | 782 | api_check(L, ttistable(o), "table expected"); |
| 783 | t = hvalue(o); | 783 | t = hvalue(o); |
| 784 | setobj2t(L, luaH_set(L, t, L->top-2), L->top-1); | 784 | setobj2t(L, luaH_set(L, t, L->top-2), L->top-1); |
| 785 | invalidateTMcache(t); | 785 | invalidateTMcache(t); |
| @@ -795,7 +795,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { | |||
| 795 | lua_lock(L); | 795 | lua_lock(L); |
| 796 | api_checknelems(L, 1); | 796 | api_checknelems(L, 1); |
| 797 | o = index2addr(L, idx); | 797 | o = index2addr(L, idx); |
| 798 | api_check(ttistable(o), "table expected"); | 798 | api_check(L, ttistable(o), "table expected"); |
| 799 | t = hvalue(o); | 799 | t = hvalue(o); |
| 800 | luaH_setint(L, t, n, L->top - 1); | 800 | luaH_setint(L, t, n, L->top - 1); |
| 801 | luaC_barrierback(L, t, L->top-1); | 801 | luaC_barrierback(L, t, L->top-1); |
| @@ -811,7 +811,7 @@ LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { | |||
| 811 | lua_lock(L); | 811 | lua_lock(L); |
| 812 | api_checknelems(L, 1); | 812 | api_checknelems(L, 1); |
| 813 | o = index2addr(L, idx); | 813 | o = index2addr(L, idx); |
| 814 | api_check(ttistable(o), "table expected"); | 814 | api_check(L, ttistable(o), "table expected"); |
| 815 | t = hvalue(o); | 815 | t = hvalue(o); |
| 816 | setpvalue(&k, cast(void *, p)); | 816 | setpvalue(&k, cast(void *, p)); |
| 817 | setobj2t(L, luaH_set(L, t, &k), L->top - 1); | 817 | setobj2t(L, luaH_set(L, t, &k), L->top - 1); |
| @@ -830,7 +830,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { | |||
| 830 | if (ttisnil(L->top - 1)) | 830 | if (ttisnil(L->top - 1)) |
| 831 | mt = NULL; | 831 | mt = NULL; |
| 832 | else { | 832 | else { |
| 833 | api_check(ttistable(L->top - 1), "table expected"); | 833 | api_check(L, ttistable(L->top - 1), "table expected"); |
| 834 | mt = hvalue(L->top - 1); | 834 | mt = hvalue(L->top - 1); |
| 835 | } | 835 | } |
| 836 | switch (ttnov(obj)) { | 836 | switch (ttnov(obj)) { |
| @@ -866,7 +866,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) { | |||
| 866 | lua_lock(L); | 866 | lua_lock(L); |
| 867 | api_checknelems(L, 1); | 867 | api_checknelems(L, 1); |
| 868 | o = index2addr(L, idx); | 868 | o = index2addr(L, idx); |
| 869 | api_check(ttisfulluserdata(o), "full userdata expected"); | 869 | api_check(L, ttisfulluserdata(o), "full userdata expected"); |
| 870 | setuservalue(L, uvalue(o), L->top - 1); | 870 | setuservalue(L, uvalue(o), L->top - 1); |
| 871 | luaC_barrier(L, gcvalue(o), L->top - 1); | 871 | luaC_barrier(L, gcvalue(o), L->top - 1); |
| 872 | L->top--; | 872 | L->top--; |
| @@ -880,7 +880,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) { | |||
| 880 | 880 | ||
| 881 | 881 | ||
| 882 | #define checkresults(L,na,nr) \ | 882 | #define checkresults(L,na,nr) \ |
| 883 | api_check((nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ | 883 | api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ |
| 884 | "results from function overflow current stack size") | 884 | "results from function overflow current stack size") |
| 885 | 885 | ||
| 886 | 886 | ||
| @@ -888,10 +888,10 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults, | |||
| 888 | lua_KContext ctx, lua_KFunction k) { | 888 | lua_KContext ctx, lua_KFunction k) { |
| 889 | StkId func; | 889 | StkId func; |
| 890 | lua_lock(L); | 890 | lua_lock(L); |
| 891 | api_check(k == NULL || !isLua(L->ci), | 891 | api_check(L, k == NULL || !isLua(L->ci), |
| 892 | "cannot use continuations inside hooks"); | 892 | "cannot use continuations inside hooks"); |
| 893 | api_checknelems(L, nargs+1); | 893 | api_checknelems(L, nargs+1); |
| 894 | api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); | 894 | api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); |
| 895 | checkresults(L, nargs, nresults); | 895 | checkresults(L, nargs, nresults); |
| 896 | func = L->top - (nargs+1); | 896 | func = L->top - (nargs+1); |
| 897 | if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ | 897 | if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ |
| @@ -929,16 +929,16 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, | |||
| 929 | int status; | 929 | int status; |
| 930 | ptrdiff_t func; | 930 | ptrdiff_t func; |
| 931 | lua_lock(L); | 931 | lua_lock(L); |
| 932 | api_check(k == NULL || !isLua(L->ci), | 932 | api_check(L, k == NULL || !isLua(L->ci), |
| 933 | "cannot use continuations inside hooks"); | 933 | "cannot use continuations inside hooks"); |
| 934 | api_checknelems(L, nargs+1); | 934 | api_checknelems(L, nargs+1); |
| 935 | api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); | 935 | api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); |
| 936 | checkresults(L, nargs, nresults); | 936 | checkresults(L, nargs, nresults); |
| 937 | if (errfunc == 0) | 937 | if (errfunc == 0) |
| 938 | func = 0; | 938 | func = 0; |
| 939 | else { | 939 | else { |
| 940 | StkId o = index2addr(L, errfunc); | 940 | StkId o = index2addr(L, errfunc); |
| 941 | api_checkstackindex(errfunc, o); | 941 | api_checkstackindex(L, errfunc, o); |
| 942 | func = savestack(L, o); | 942 | func = savestack(L, o); |
| 943 | } | 943 | } |
| 944 | c.func = L->top - (nargs+1); /* function to be called */ | 944 | c.func = L->top - (nargs+1); /* function to be called */ |
| @@ -1103,7 +1103,7 @@ LUA_API int lua_next (lua_State *L, int idx) { | |||
| 1103 | int more; | 1103 | int more; |
| 1104 | lua_lock(L); | 1104 | lua_lock(L); |
| 1105 | t = index2addr(L, idx); | 1105 | t = index2addr(L, idx); |
| 1106 | api_check(ttistable(t), "table expected"); | 1106 | api_check(L, ttistable(t), "table expected"); |
| 1107 | more = luaH_next(L, hvalue(t), L->top - 1); | 1107 | more = luaH_next(L, hvalue(t), L->top - 1); |
| 1108 | if (more) { | 1108 | if (more) { |
| 1109 | api_incr_top(L); | 1109 | api_incr_top(L); |
| @@ -1235,9 +1235,9 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { | |||
| 1235 | static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { | 1235 | static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { |
| 1236 | LClosure *f; | 1236 | LClosure *f; |
| 1237 | StkId fi = index2addr(L, fidx); | 1237 | StkId fi = index2addr(L, fidx); |
| 1238 | api_check(ttisLclosure(fi), "Lua function expected"); | 1238 | api_check(L, ttisLclosure(fi), "Lua function expected"); |
| 1239 | f = clLvalue(fi); | 1239 | f = clLvalue(fi); |
| 1240 | api_check((1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); | 1240 | api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); |
| 1241 | if (pf) *pf = f; | 1241 | if (pf) *pf = f; |
| 1242 | return &f->upvals[n - 1]; /* get its upvalue pointer */ | 1242 | return &f->upvals[n - 1]; /* get its upvalue pointer */ |
| 1243 | } | 1243 | } |
| @@ -1251,11 +1251,11 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { | |||
| 1251 | } | 1251 | } |
| 1252 | case LUA_TCCL: { /* C closure */ | 1252 | case LUA_TCCL: { /* C closure */ |
| 1253 | CClosure *f = clCvalue(fi); | 1253 | CClosure *f = clCvalue(fi); |
| 1254 | api_check(1 <= n && n <= f->nupvalues, "invalid upvalue index"); | 1254 | api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index"); |
| 1255 | return &f->upvalue[n - 1]; | 1255 | return &f->upvalue[n - 1]; |
| 1256 | } | 1256 | } |
| 1257 | default: { | 1257 | default: { |
| 1258 | api_check(0, "closure expected"); | 1258 | api_check(L, 0, "closure expected"); |
| 1259 | return NULL; | 1259 | return NULL; |
| 1260 | } | 1260 | } |
| 1261 | } | 1261 | } |
