diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-27 09:33:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-27 09:33:07 -0300 |
| commit | e1a424e8a35738bf56ecdad01155fb45b3001660 (patch) | |
| tree | 34c232ea0cb15e410a161ee0f65bd9bdb73838d7 /lapi.c | |
| parent | 59ce42dbd5a2dd2dd8bfbbf3e856742a535afc5b (diff) | |
| download | lua-e1a424e8a35738bf56ecdad01155fb45b3001660.tar.gz lua-e1a424e8a35738bf56ecdad01155fb45b3001660.tar.bz2 lua-e1a424e8a35738bf56ecdad01155fb45b3001660.zip | |
avoid the identifier `index' (clashes with BSD `index' function)
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 158 |
1 files changed, 79 insertions, 79 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.230 2003/02/20 19:33:23 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.231 2003/02/24 16:54:20 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 | */ |
| @@ -45,43 +45,43 @@ const char lua_ident[] = | |||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | static TObject *negindex (lua_State *L, int index) { | 48 | static TObject *negindex (lua_State *L, int idx) { |
| 49 | if (index > LUA_REGISTRYINDEX) { | 49 | if (idx > LUA_REGISTRYINDEX) { |
| 50 | api_check(L, index != 0 && -index <= L->top - L->base); | 50 | api_check(L, idx != 0 && -idx <= L->top - L->base); |
| 51 | return L->top+index; | 51 | return L->top+idx; |
| 52 | } | 52 | } |
| 53 | else switch (index) { /* pseudo-indices */ | 53 | else switch (idx) { /* pseudo-indices */ |
| 54 | case LUA_REGISTRYINDEX: return registry(L); | 54 | case LUA_REGISTRYINDEX: return registry(L); |
| 55 | case LUA_GLOBALSINDEX: return gt(L); | 55 | case LUA_GLOBALSINDEX: return gt(L); |
| 56 | default: { | 56 | default: { |
| 57 | TObject *func = (L->base - 1); | 57 | TObject *func = (L->base - 1); |
| 58 | index = LUA_GLOBALSINDEX - index; | 58 | idx = LUA_GLOBALSINDEX - idx; |
| 59 | api_check(L, iscfunction(func) && index <= clvalue(func)->c.nupvalues); | 59 | api_check(L, iscfunction(func) && idx <= clvalue(func)->c.nupvalues); |
| 60 | return &clvalue(func)->c.upvalue[index-1]; | 60 | return &clvalue(func)->c.upvalue[idx-1]; |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | static TObject *luaA_index (lua_State *L, int index) { | 66 | static TObject *luaA_index (lua_State *L, int idx) { |
| 67 | if (index > 0) { | 67 | if (idx > 0) { |
| 68 | api_check(L, index <= L->top - L->base); | 68 | api_check(L, idx <= L->top - L->base); |
| 69 | return L->base + index - 1; | 69 | return L->base + idx - 1; |
| 70 | } | 70 | } |
| 71 | else | 71 | else |
| 72 | return negindex(L, index); | 72 | return negindex(L, idx); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | static TObject *luaA_indexAcceptable (lua_State *L, int index) { | 76 | static TObject *luaA_indexAcceptable (lua_State *L, int idx) { |
| 77 | if (index > 0) { | 77 | if (idx > 0) { |
| 78 | TObject *o = L->base+(index-1); | 78 | TObject *o = L->base+(idx-1); |
| 79 | api_check(L, index <= L->stack_last - L->base); | 79 | api_check(L, idx <= L->stack_last - L->base); |
| 80 | if (o >= L->top) return NULL; | 80 | if (o >= L->top) return NULL; |
| 81 | else return o; | 81 | else return o; |
| 82 | } | 82 | } |
| 83 | else | 83 | else |
| 84 | return negindex(L, index); | 84 | return negindex(L, idx); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | 87 | ||
| @@ -154,55 +154,55 @@ LUA_API int lua_gettop (lua_State *L) { | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | LUA_API void lua_settop (lua_State *L, int index) { | 157 | LUA_API void lua_settop (lua_State *L, int idx) { |
| 158 | lua_lock(L); | 158 | lua_lock(L); |
| 159 | if (index >= 0) { | 159 | if (idx >= 0) { |
| 160 | api_check(L, index <= L->stack_last - L->base); | 160 | api_check(L, idx <= L->stack_last - L->base); |
| 161 | while (L->top < L->base + index) | 161 | while (L->top < L->base + idx) |
| 162 | setnilvalue(L->top++); | 162 | setnilvalue(L->top++); |
| 163 | L->top = L->base + index; | 163 | L->top = L->base + idx; |
| 164 | } | 164 | } |
| 165 | else { | 165 | else { |
| 166 | api_check(L, -(index+1) <= (L->top - L->base)); | 166 | api_check(L, -(idx+1) <= (L->top - L->base)); |
| 167 | L->top += index+1; /* `subtract' index (index is negative) */ | 167 | L->top += idx+1; /* `subtract' index (index is negative) */ |
| 168 | } | 168 | } |
| 169 | lua_unlock(L); | 169 | lua_unlock(L); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | LUA_API void lua_remove (lua_State *L, int index) { | 173 | LUA_API void lua_remove (lua_State *L, int idx) { |
| 174 | StkId p; | 174 | StkId p; |
| 175 | lua_lock(L); | 175 | lua_lock(L); |
| 176 | p = luaA_index(L, index); | 176 | p = luaA_index(L, idx); |
| 177 | while (++p < L->top) setobjs2s(p-1, p); | 177 | while (++p < L->top) setobjs2s(p-1, p); |
| 178 | L->top--; | 178 | L->top--; |
| 179 | lua_unlock(L); | 179 | lua_unlock(L); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | LUA_API void lua_insert (lua_State *L, int index) { | 183 | LUA_API void lua_insert (lua_State *L, int idx) { |
| 184 | StkId p; | 184 | StkId p; |
| 185 | StkId q; | 185 | StkId q; |
| 186 | lua_lock(L); | 186 | lua_lock(L); |
| 187 | p = luaA_index(L, index); | 187 | p = luaA_index(L, idx); |
| 188 | for (q = L->top; q>p; q--) setobjs2s(q, q-1); | 188 | for (q = L->top; q>p; q--) setobjs2s(q, q-1); |
| 189 | setobjs2s(p, L->top); | 189 | setobjs2s(p, L->top); |
| 190 | lua_unlock(L); | 190 | lua_unlock(L); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | 193 | ||
| 194 | LUA_API void lua_replace (lua_State *L, int index) { | 194 | LUA_API void lua_replace (lua_State *L, int idx) { |
| 195 | lua_lock(L); | 195 | lua_lock(L); |
| 196 | api_checknelems(L, 1); | 196 | api_checknelems(L, 1); |
| 197 | setobj(luaA_index(L, index), L->top - 1); /* write barrier */ | 197 | setobj(luaA_index(L, idx), L->top - 1); /* write barrier */ |
| 198 | L->top--; | 198 | L->top--; |
| 199 | lua_unlock(L); | 199 | lua_unlock(L); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | LUA_API void lua_pushvalue (lua_State *L, int index) { | 203 | LUA_API void lua_pushvalue (lua_State *L, int idx) { |
| 204 | lua_lock(L); | 204 | lua_lock(L); |
| 205 | setobj2s(L->top, luaA_index(L, index)); | 205 | setobj2s(L->top, luaA_index(L, idx)); |
| 206 | api_incr_top(L); | 206 | api_incr_top(L); |
| 207 | lua_unlock(L); | 207 | lua_unlock(L); |
| 208 | } | 208 | } |
| @@ -214,8 +214,8 @@ LUA_API void lua_pushvalue (lua_State *L, int index) { | |||
| 214 | */ | 214 | */ |
| 215 | 215 | ||
| 216 | 216 | ||
| 217 | LUA_API int lua_type (lua_State *L, int index) { | 217 | LUA_API int lua_type (lua_State *L, int idx) { |
| 218 | StkId o = luaA_indexAcceptable(L, index); | 218 | StkId o = luaA_indexAcceptable(L, idx); |
| 219 | return (o == NULL) ? LUA_TNONE : ttype(o); | 219 | return (o == NULL) ? LUA_TNONE : ttype(o); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -226,27 +226,27 @@ LUA_API const char *lua_typename (lua_State *L, int t) { | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | 228 | ||
| 229 | LUA_API int lua_iscfunction (lua_State *L, int index) { | 229 | LUA_API int lua_iscfunction (lua_State *L, int idx) { |
| 230 | StkId o = luaA_indexAcceptable(L, index); | 230 | StkId o = luaA_indexAcceptable(L, idx); |
| 231 | return (o == NULL) ? 0 : iscfunction(o); | 231 | return (o == NULL) ? 0 : iscfunction(o); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | 234 | ||
| 235 | LUA_API int lua_isnumber (lua_State *L, int index) { | 235 | LUA_API int lua_isnumber (lua_State *L, int idx) { |
| 236 | TObject n; | 236 | TObject n; |
| 237 | const TObject *o = luaA_indexAcceptable(L, index); | 237 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 238 | return (o != NULL && tonumber(o, &n)); | 238 | return (o != NULL && tonumber(o, &n)); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | 241 | ||
| 242 | LUA_API int lua_isstring (lua_State *L, int index) { | 242 | LUA_API int lua_isstring (lua_State *L, int idx) { |
| 243 | int t = lua_type(L, index); | 243 | int t = lua_type(L, idx); |
| 244 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 244 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | 247 | ||
| 248 | LUA_API int lua_isuserdata (lua_State *L, int index) { | 248 | LUA_API int lua_isuserdata (lua_State *L, int idx) { |
| 249 | const TObject *o = luaA_indexAcceptable(L, index); | 249 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 250 | return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o))); | 250 | return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o))); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| @@ -286,9 +286,9 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { | |||
| 286 | 286 | ||
| 287 | 287 | ||
| 288 | 288 | ||
| 289 | LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | 289 | LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { |
| 290 | TObject n; | 290 | TObject n; |
| 291 | const TObject *o = luaA_indexAcceptable(L, index); | 291 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 292 | if (o != NULL && tonumber(o, &n)) | 292 | if (o != NULL && tonumber(o, &n)) |
| 293 | return nvalue(o); | 293 | return nvalue(o); |
| 294 | else | 294 | else |
| @@ -296,14 +296,14 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | |||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | 298 | ||
| 299 | LUA_API int lua_toboolean (lua_State *L, int index) { | 299 | LUA_API int lua_toboolean (lua_State *L, int idx) { |
| 300 | const TObject *o = luaA_indexAcceptable(L, index); | 300 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 301 | return (o != NULL) && !l_isfalse(o); | 301 | return (o != NULL) && !l_isfalse(o); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | 304 | ||
| 305 | LUA_API const char *lua_tostring (lua_State *L, int index) { | 305 | LUA_API const char *lua_tostring (lua_State *L, int idx) { |
| 306 | StkId o = luaA_indexAcceptable(L, index); | 306 | StkId o = luaA_indexAcceptable(L, idx); |
| 307 | if (o == NULL) | 307 | if (o == NULL) |
| 308 | return NULL; | 308 | return NULL; |
| 309 | else if (ttisstring(o)) | 309 | else if (ttisstring(o)) |
| @@ -319,8 +319,8 @@ LUA_API const char *lua_tostring (lua_State *L, int index) { | |||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | 321 | ||
| 322 | LUA_API size_t lua_strlen (lua_State *L, int index) { | 322 | LUA_API size_t lua_strlen (lua_State *L, int idx) { |
| 323 | StkId o = luaA_indexAcceptable(L, index); | 323 | StkId o = luaA_indexAcceptable(L, idx); |
| 324 | if (o == NULL) | 324 | if (o == NULL) |
| 325 | return 0; | 325 | return 0; |
| 326 | else if (ttisstring(o)) | 326 | else if (ttisstring(o)) |
| @@ -335,14 +335,14 @@ LUA_API size_t lua_strlen (lua_State *L, int index) { | |||
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | 337 | ||
| 338 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { | 338 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { |
| 339 | StkId o = luaA_indexAcceptable(L, index); | 339 | StkId o = luaA_indexAcceptable(L, idx); |
| 340 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f; | 340 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | 343 | ||
| 344 | LUA_API void *lua_touserdata (lua_State *L, int index) { | 344 | LUA_API void *lua_touserdata (lua_State *L, int idx) { |
| 345 | StkId o = luaA_indexAcceptable(L, index); | 345 | StkId o = luaA_indexAcceptable(L, idx); |
| 346 | if (o == NULL) return NULL; | 346 | if (o == NULL) return NULL; |
| 347 | switch (ttype(o)) { | 347 | switch (ttype(o)) { |
| 348 | case LUA_TUSERDATA: return (uvalue(o) + 1); | 348 | case LUA_TUSERDATA: return (uvalue(o) + 1); |
| @@ -352,14 +352,14 @@ LUA_API void *lua_touserdata (lua_State *L, int index) { | |||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | 354 | ||
| 355 | LUA_API lua_State *lua_tothread (lua_State *L, int index) { | 355 | LUA_API lua_State *lua_tothread (lua_State *L, int idx) { |
| 356 | StkId o = luaA_indexAcceptable(L, index); | 356 | StkId o = luaA_indexAcceptable(L, idx); |
| 357 | return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o); | 357 | return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | 360 | ||
| 361 | LUA_API const void *lua_topointer (lua_State *L, int index) { | 361 | LUA_API const void *lua_topointer (lua_State *L, int idx) { |
| 362 | StkId o = luaA_indexAcceptable(L, index); | 362 | StkId o = luaA_indexAcceptable(L, idx); |
| 363 | if (o == NULL) return NULL; | 363 | if (o == NULL) return NULL; |
| 364 | else { | 364 | else { |
| 365 | switch (ttype(o)) { | 365 | switch (ttype(o)) { |
| @@ -367,7 +367,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index) { | |||
| 367 | case LUA_TFUNCTION: return clvalue(o); | 367 | case LUA_TFUNCTION: return clvalue(o); |
| 368 | case LUA_TUSERDATA: | 368 | case LUA_TUSERDATA: |
| 369 | case LUA_TLIGHTUSERDATA: | 369 | case LUA_TLIGHTUSERDATA: |
| 370 | return lua_touserdata(L, index); | 370 | return lua_touserdata(L, idx); |
| 371 | default: return NULL; | 371 | default: return NULL; |
| 372 | } | 372 | } |
| 373 | } | 373 | } |
| @@ -475,29 +475,29 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { | |||
| 475 | */ | 475 | */ |
| 476 | 476 | ||
| 477 | 477 | ||
| 478 | LUA_API void lua_gettable (lua_State *L, int index) { | 478 | LUA_API void lua_gettable (lua_State *L, int idx) { |
| 479 | StkId t; | 479 | StkId t; |
| 480 | lua_lock(L); | 480 | lua_lock(L); |
| 481 | t = luaA_index(L, index); | 481 | t = luaA_index(L, idx); |
| 482 | setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0)); | 482 | setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0)); |
| 483 | lua_unlock(L); | 483 | lua_unlock(L); |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | 486 | ||
| 487 | LUA_API void lua_rawget (lua_State *L, int index) { | 487 | LUA_API void lua_rawget (lua_State *L, int idx) { |
| 488 | StkId t; | 488 | StkId t; |
| 489 | lua_lock(L); | 489 | lua_lock(L); |
| 490 | t = luaA_index(L, index); | 490 | t = luaA_index(L, idx); |
| 491 | api_check(L, ttistable(t)); | 491 | api_check(L, ttistable(t)); |
| 492 | setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); | 492 | setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); |
| 493 | lua_unlock(L); | 493 | lua_unlock(L); |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | 496 | ||
| 497 | LUA_API void lua_rawgeti (lua_State *L, int index, int n) { | 497 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { |
| 498 | StkId o; | 498 | StkId o; |
| 499 | lua_lock(L); | 499 | lua_lock(L); |
| 500 | o = luaA_index(L, index); | 500 | o = luaA_index(L, idx); |
| 501 | api_check(L, ttistable(o)); | 501 | api_check(L, ttistable(o)); |
| 502 | setobj2s(L->top, luaH_getnum(hvalue(o), n)); | 502 | setobj2s(L->top, luaH_getnum(hvalue(o), n)); |
| 503 | api_incr_top(L); | 503 | api_incr_top(L); |
| @@ -542,10 +542,10 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { | |||
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | 544 | ||
| 545 | LUA_API void lua_getfenv (lua_State *L, int index) { | 545 | LUA_API void lua_getfenv (lua_State *L, int idx) { |
| 546 | StkId o; | 546 | StkId o; |
| 547 | lua_lock(L); | 547 | lua_lock(L); |
| 548 | o = luaA_index(L, index); | 548 | o = luaA_index(L, idx); |
| 549 | setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); | 549 | setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); |
| 550 | api_incr_top(L); | 550 | api_incr_top(L); |
| 551 | lua_unlock(L); | 551 | lua_unlock(L); |
| @@ -557,22 +557,22 @@ LUA_API void lua_getfenv (lua_State *L, int index) { | |||
| 557 | */ | 557 | */ |
| 558 | 558 | ||
| 559 | 559 | ||
| 560 | LUA_API void lua_settable (lua_State *L, int index) { | 560 | LUA_API void lua_settable (lua_State *L, int idx) { |
| 561 | StkId t; | 561 | StkId t; |
| 562 | lua_lock(L); | 562 | lua_lock(L); |
| 563 | api_checknelems(L, 2); | 563 | api_checknelems(L, 2); |
| 564 | t = luaA_index(L, index); | 564 | t = luaA_index(L, idx); |
| 565 | luaV_settable(L, t, L->top - 2, L->top - 1); | 565 | luaV_settable(L, t, L->top - 2, L->top - 1); |
| 566 | L->top -= 2; /* pop index and value */ | 566 | L->top -= 2; /* pop index and value */ |
| 567 | lua_unlock(L); | 567 | lua_unlock(L); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | 570 | ||
| 571 | LUA_API void lua_rawset (lua_State *L, int index) { | 571 | LUA_API void lua_rawset (lua_State *L, int idx) { |
| 572 | StkId t; | 572 | StkId t; |
| 573 | lua_lock(L); | 573 | lua_lock(L); |
| 574 | api_checknelems(L, 2); | 574 | api_checknelems(L, 2); |
| 575 | t = luaA_index(L, index); | 575 | t = luaA_index(L, idx); |
| 576 | api_check(L, ttistable(t)); | 576 | api_check(L, ttistable(t)); |
| 577 | setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); /* write barrier */ | 577 | setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); /* write barrier */ |
| 578 | L->top -= 2; | 578 | L->top -= 2; |
| @@ -580,11 +580,11 @@ LUA_API void lua_rawset (lua_State *L, int index) { | |||
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | 582 | ||
| 583 | LUA_API void lua_rawseti (lua_State *L, int index, int n) { | 583 | LUA_API void lua_rawseti (lua_State *L, int idx, int n) { |
| 584 | StkId o; | 584 | StkId o; |
| 585 | lua_lock(L); | 585 | lua_lock(L); |
| 586 | api_checknelems(L, 1); | 586 | api_checknelems(L, 1); |
| 587 | o = luaA_index(L, index); | 587 | o = luaA_index(L, idx); |
| 588 | api_check(L, ttistable(o)); | 588 | api_check(L, ttistable(o)); |
| 589 | setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); /* write barrier */ | 589 | setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); /* write barrier */ |
| 590 | L->top--; | 590 | L->top--; |
| @@ -620,12 +620,12 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { | |||
| 620 | } | 620 | } |
| 621 | 621 | ||
| 622 | 622 | ||
| 623 | LUA_API int lua_setfenv (lua_State *L, int index) { | 623 | LUA_API int lua_setfenv (lua_State *L, int idx) { |
| 624 | StkId o; | 624 | StkId o; |
| 625 | int res = 0; | 625 | int res = 0; |
| 626 | lua_lock(L); | 626 | lua_lock(L); |
| 627 | api_checknelems(L, 1); | 627 | api_checknelems(L, 1); |
| 628 | o = luaA_index(L, index); | 628 | o = luaA_index(L, idx); |
| 629 | L->top--; | 629 | L->top--; |
| 630 | api_check(L, ttistable(L->top)); | 630 | api_check(L, ttistable(L->top)); |
| 631 | if (isLfunction(o)) { | 631 | if (isLfunction(o)) { |
| @@ -803,11 +803,11 @@ LUA_API int lua_error (lua_State *L) { | |||
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | 805 | ||
| 806 | LUA_API int lua_next (lua_State *L, int index) { | 806 | LUA_API int lua_next (lua_State *L, int idx) { |
| 807 | StkId t; | 807 | StkId t; |
| 808 | int more; | 808 | int more; |
| 809 | lua_lock(L); | 809 | lua_lock(L); |
| 810 | t = luaA_index(L, index); | 810 | t = luaA_index(L, idx); |
| 811 | api_check(L, ttistable(t)); | 811 | api_check(L, ttistable(t)); |
| 812 | more = luaH_next(L, hvalue(t), L->top - 1); | 812 | more = luaH_next(L, hvalue(t), L->top - 1); |
| 813 | if (more) { | 813 | if (more) { |
