L 41 lib/lua/lapi.c #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) L 43 lib/lua/lapi.c #define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) L 45 lib/lua/lapi.c #define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} L 49 lib/lua/lapi.c static TValue *index2adr (lua_State *L, int idx) { L 51 lib/lua/lapi.c TValue *o = L->base + (idx - 1); L 52 lib/lua/lapi.c api_check(L, idx <= L->ci->top - L->base); L 53 lib/lua/lapi.c if (o >= L->top) return cast(TValue *, luaO_nilobject); L 57 lib/lua/lapi.c api_check(L, idx != 0 && -idx <= L->top - L->base); L 58 lib/lua/lapi.c return L->top + idx; L 61 lib/lua/lapi.c case LUA_REGISTRYINDEX: return registry(L); L 63 lib/lua/lapi.c Closure *func = curr_func(L); L 64 lib/lua/lapi.c sethvalue(L, &L->env, func->c.env); L 65 lib/lua/lapi.c return &L->env; L 67 lib/lua/lapi.c case LUA_GLOBALSINDEX: return gt(L); L 69 lib/lua/lapi.c Closure *func = curr_func(L); L 79 lib/lua/lapi.c static Table *getcurrenv (lua_State *L) { L 80 lib/lua/lapi.c if (L->ci == L->base_ci) /* no enclosing function? */ L 81 lib/lua/lapi.c return hvalue(gt(L)); /* use global table as environment */ L 83 lib/lua/lapi.c Closure *func = curr_func(L); L 89 lib/lua/lapi.c LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o) { L 90 lib/lua/lapi.c setobj2s(L, L->top, o); L 91 lib/lua/lapi.c api_incr_top(L); L 95 lib/lua/lapi.c LUA_API int lua_checkstack (lua_State *L, int size) { L 97 lib/lua/lapi.c lua_lock(L); L 98 lib/lua/lapi.c if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) L 101 lib/lua/lapi.c luaD_checkstack(L, size); L 102 lib/lua/lapi.c if (L->ci->top < L->top + size) L 103 lib/lua/lapi.c L->ci->top = L->top + size; L 105 lib/lua/lapi.c lua_unlock(L); L 130 lib/lua/lapi.c LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { L 132 lib/lua/lapi.c lua_lock(L); L 133 lib/lua/lapi.c old = G(L)->panic; L 134 lib/lua/lapi.c G(L)->panic = panicf; L 135 lib/lua/lapi.c lua_unlock(L); L 140 lib/lua/lapi.c LUA_API lua_State *lua_newthread (lua_State *L) { L 142 lib/lua/lapi.c lua_lock(L); L 143 lib/lua/lapi.c luaC_checkGC(L); L 144 lib/lua/lapi.c L1 = luaE_newthread(L); L 145 lib/lua/lapi.c setthvalue(L, L->top, L1); L 146 lib/lua/lapi.c api_incr_top(L); L 147 lib/lua/lapi.c lua_unlock(L); L 148 lib/lua/lapi.c luai_userstatethread(L, L1); L 159 lib/lua/lapi.c LUA_API int lua_gettop (lua_State *L) { L 160 lib/lua/lapi.c return cast_int(L->top - L->base); L 164 lib/lua/lapi.c LUA_API void lua_settop (lua_State *L, int idx) { L 165 lib/lua/lapi.c lua_lock(L); L 167 lib/lua/lapi.c api_check(L, idx <= L->stack_last - L->base); L 168 lib/lua/lapi.c while (L->top < L->base + idx) L 169 lib/lua/lapi.c setnilvalue(L->top++); L 170 lib/lua/lapi.c L->top = L->base + idx; L 173 lib/lua/lapi.c api_check(L, -(idx+1) <= (L->top - L->base)); L 174 lib/lua/lapi.c L->top += idx+1; /* `subtract' index (index is negative) */ L 176 lib/lua/lapi.c lua_unlock(L); L 180 lib/lua/lapi.c LUA_API void lua_remove (lua_State *L, int idx) { L 182 lib/lua/lapi.c lua_lock(L); L 183 lib/lua/lapi.c p = index2adr(L, idx); L 184 lib/lua/lapi.c api_checkvalidindex(L, p); L 185 lib/lua/lapi.c while (++p < L->top) setobjs2s(L, p-1, p); L 186 lib/lua/lapi.c L->top--; L 187 lib/lua/lapi.c lua_unlock(L); L 191 lib/lua/lapi.c LUA_API void lua_insert (lua_State *L, int idx) { L 194 lib/lua/lapi.c lua_lock(L); L 195 lib/lua/lapi.c p = index2adr(L, idx); L 196 lib/lua/lapi.c api_checkvalidindex(L, p); L 197 lib/lua/lapi.c for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); L 198 lib/lua/lapi.c setobjs2s(L, p, L->top); L 199 lib/lua/lapi.c lua_unlock(L); L 203 lib/lua/lapi.c LUA_API void lua_replace (lua_State *L, int idx) { L 205 lib/lua/lapi.c lua_lock(L); L 207 lib/lua/lapi.c if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) L 208 lib/lua/lapi.c luaG_runerror(L, "no calling environment"); L 209 lib/lua/lapi.c api_checknelems(L, 1); L 210 lib/lua/lapi.c o = index2adr(L, idx); L 211 lib/lua/lapi.c api_checkvalidindex(L, o); L 213 lib/lua/lapi.c Closure *func = curr_func(L); L 214 lib/lua/lapi.c api_check(L, ttistable(L->top - 1)); L 215 lib/lua/lapi.c func->c.env = hvalue(L->top - 1); L 216 lib/lua/lapi.c luaC_barrier(L, func, L->top - 1); L 219 lib/lua/lapi.c setobj(L, o, L->top - 1); L 221 lib/lua/lapi.c luaC_barrier(L, curr_func(L), L->top - 1); L 223 lib/lua/lapi.c L->top--; L 224 lib/lua/lapi.c lua_unlock(L); L 228 lib/lua/lapi.c LUA_API void lua_pushvalue (lua_State *L, int idx) { L 229 lib/lua/lapi.c lua_lock(L); L 230 lib/lua/lapi.c setobj2s(L, L->top, index2adr(L, idx)); L 231 lib/lua/lapi.c api_incr_top(L); L 232 lib/lua/lapi.c lua_unlock(L); L 242 lib/lua/lapi.c LUA_API int lua_type (lua_State *L, int idx) { L 243 lib/lua/lapi.c StkId o = index2adr(L, idx); L 248 lib/lua/lapi.c LUA_API const char *lua_typename (lua_State *L, int t) { L 249 lib/lua/lapi.c UNUSED(L); L 254 lib/lua/lapi.c LUA_API int lua_iscfunction (lua_State *L, int idx) { L 255 lib/lua/lapi.c StkId o = index2adr(L, idx); L 260 lib/lua/lapi.c LUA_API int lua_isnumber (lua_State *L, int idx) { L 262 lib/lua/lapi.c const TValue *o = index2adr(L, idx); L 267 lib/lua/lapi.c LUA_API int lua_isstring (lua_State *L, int idx) { L 268 lib/lua/lapi.c int t = lua_type(L, idx); L 273 lib/lua/lapi.c LUA_API int lua_isuserdata (lua_State *L, int idx) { L 274 lib/lua/lapi.c const TValue *o = index2adr(L, idx); L 279 lib/lua/lapi.c LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { L 280 lib/lua/lapi.c StkId o1 = index2adr(L, index1); L 281 lib/lua/lapi.c StkId o2 = index2adr(L, index2); L 287 lib/lua/lapi.c LUA_API int lua_equal (lua_State *L, int index1, int index2) { L 290 lib/lua/lapi.c lua_lock(L); /* may call tag method */ L 291 lib/lua/lapi.c o1 = index2adr(L, index1); L 292 lib/lua/lapi.c o2 = index2adr(L, index2); L 293 lib/lua/lapi.c i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); L 294 lib/lua/lapi.c lua_unlock(L); L 299 lib/lua/lapi.c LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { L 302 lib/lua/lapi.c lua_lock(L); /* may call tag method */ L 303 lib/lua/lapi.c o1 = index2adr(L, index1); L 304 lib/lua/lapi.c o2 = index2adr(L, index2); L 306 lib/lua/lapi.c : luaV_lessthan(L, o1, o2); L 307 lib/lua/lapi.c lua_unlock(L); L 313 lib/lua/lapi.c LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { L 315 lib/lua/lapi.c const TValue *o = index2adr(L, idx); L 323 lib/lua/lapi.c LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { L 325 lib/lua/lapi.c const TValue *o = index2adr(L, idx); L 337 lib/lua/lapi.c LUA_API int lua_toboolean (lua_State *L, int idx) { L 338 lib/lua/lapi.c const TValue *o = index2adr(L, idx); L 343 lib/lua/lapi.c LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { L 344 lib/lua/lapi.c StkId o = index2adr(L, idx); L 346 lib/lua/lapi.c lua_lock(L); /* `luaV_tostring' may create a new string */ L 347 lib/lua/lapi.c if (!luaV_tostring(L, o)) { /* conversion failed? */ L 349 lib/lua/lapi.c lua_unlock(L); L 352 lib/lua/lapi.c luaC_checkGC(L); L 353 lib/lua/lapi.c o = index2adr(L, idx); /* previous call may reallocate the stack */ L 354 lib/lua/lapi.c lua_unlock(L); L 361 lib/lua/lapi.c LUA_API size_t lua_objlen (lua_State *L, int idx) { L 362 lib/lua/lapi.c StkId o = index2adr(L, idx); L 369 lib/lua/lapi.c lua_lock(L); /* `luaV_tostring' may create a new string */ L 370 lib/lua/lapi.c l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); L 371 lib/lua/lapi.c lua_unlock(L); L 379 lib/lua/lapi.c LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { L 380 lib/lua/lapi.c StkId o = index2adr(L, idx); L 385 lib/lua/lapi.c LUA_API void *lua_touserdata (lua_State *L, int idx) { L 386 lib/lua/lapi.c StkId o = index2adr(L, idx); L 395 lib/lua/lapi.c LUA_API lua_State *lua_tothread (lua_State *L, int idx) { L 396 lib/lua/lapi.c StkId o = index2adr(L, idx); L 401 lib/lua/lapi.c LUA_API const void *lua_topointer (lua_State *L, int idx) { L 402 lib/lua/lapi.c StkId o = index2adr(L, idx); L 409 lib/lua/lapi.c return lua_touserdata(L, idx); L 421 lib/lua/lapi.c LUA_API void lua_pushnil (lua_State *L) { L 422 lib/lua/lapi.c lua_lock(L); L 423 lib/lua/lapi.c setnilvalue(L->top); L 424 lib/lua/lapi.c api_incr_top(L); L 425 lib/lua/lapi.c lua_unlock(L); L 429 lib/lua/lapi.c LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { L 430 lib/lua/lapi.c lua_lock(L); L 431 lib/lua/lapi.c setnvalue(L->top, n); L 432 lib/lua/lapi.c api_incr_top(L); L 433 lib/lua/lapi.c lua_unlock(L); L 437 lib/lua/lapi.c LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { L 438 lib/lua/lapi.c lua_lock(L); L 439 lib/lua/lapi.c setnvalue(L->top, cast_num(n)); L 440 lib/lua/lapi.c api_incr_top(L); L 441 lib/lua/lapi.c lua_unlock(L); L 445 lib/lua/lapi.c LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { L 446 lib/lua/lapi.c lua_lock(L); L 447 lib/lua/lapi.c luaC_checkGC(L); L 448 lib/lua/lapi.c setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); L 449 lib/lua/lapi.c api_incr_top(L); L 450 lib/lua/lapi.c lua_unlock(L); L 454 lib/lua/lapi.c LUA_API void lua_pushstring (lua_State *L, const char *s) { L 456 lib/lua/lapi.c lua_pushnil(L); L 458 lib/lua/lapi.c lua_pushlstring(L, s, strlen(s)); L 462 lib/lua/lapi.c LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, L 465 lib/lua/lapi.c lua_lock(L); L 466 lib/lua/lapi.c luaC_checkGC(L); L 467 lib/lua/lapi.c ret = luaO_pushvfstring(L, fmt, argp); L 468 lib/lua/lapi.c lua_unlock(L); L 473 lib/lua/lapi.c LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { L 476 lib/lua/lapi.c lua_lock(L); L 477 lib/lua/lapi.c luaC_checkGC(L); L 479 lib/lua/lapi.c ret = luaO_pushvfstring(L, fmt, argp); L 481 lib/lua/lapi.c lua_unlock(L); L 486 lib/lua/lapi.c LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { L 488 lib/lua/lapi.c lua_lock(L); L 489 lib/lua/lapi.c luaC_checkGC(L); L 490 lib/lua/lapi.c api_checknelems(L, n); L 491 lib/lua/lapi.c cl = luaF_newCclosure(L, n, getcurrenv(L)); L 493 lib/lua/lapi.c L->top -= n; L 495 lib/lua/lapi.c setobj2n(L, &cl->c.upvalue[n], L->top+n); L 496 lib/lua/lapi.c setclvalue(L, L->top, cl); L 498 lib/lua/lapi.c api_incr_top(L); L 499 lib/lua/lapi.c lua_unlock(L); L 503 lib/lua/lapi.c LUA_API void lua_pushboolean (lua_State *L, int b) { L 504 lib/lua/lapi.c lua_lock(L); L 505 lib/lua/lapi.c setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ L 506 lib/lua/lapi.c api_incr_top(L); L 507 lib/lua/lapi.c lua_unlock(L); L 511 lib/lua/lapi.c LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { L 512 lib/lua/lapi.c lua_lock(L); L 513 lib/lua/lapi.c setpvalue(L->top, p); L 514 lib/lua/lapi.c api_incr_top(L); L 515 lib/lua/lapi.c lua_unlock(L); L 519 lib/lua/lapi.c LUA_API int lua_pushthread (lua_State *L) { L 520 lib/lua/lapi.c lua_lock(L); L 521 lib/lua/lapi.c setthvalue(L, L->top, L); L 522 lib/lua/lapi.c api_incr_top(L); L 523 lib/lua/lapi.c lua_unlock(L); L 524 lib/lua/lapi.c return (G(L)->mainthread == L); L 534 lib/lua/lapi.c LUA_API void lua_gettable (lua_State *L, int idx) { L 536 lib/lua/lapi.c lua_lock(L); L 537 lib/lua/lapi.c t = index2adr(L, idx); L 538 lib/lua/lapi.c api_checkvalidindex(L, t); L 539 lib/lua/lapi.c luaV_gettable(L, t, L->top - 1, L->top - 1); L 540 lib/lua/lapi.c lua_unlock(L); L 544 lib/lua/lapi.c LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { L 547 lib/lua/lapi.c lua_lock(L); L 548 lib/lua/lapi.c t = index2adr(L, idx); L 549 lib/lua/lapi.c api_checkvalidindex(L, t); L 550 lib/lua/lapi.c setsvalue(L, &key, luaS_new(L, k)); L 551 lib/lua/lapi.c luaV_gettable(L, t, &key, L->top); L 552 lib/lua/lapi.c api_incr_top(L); L 553 lib/lua/lapi.c lua_unlock(L); L 557 lib/lua/lapi.c LUA_API void lua_rawget (lua_State *L, int idx) { L 559 lib/lua/lapi.c lua_lock(L); L 560 lib/lua/lapi.c t = index2adr(L, idx); L 561 lib/lua/lapi.c api_check(L, ttistable(t)); L 562 lib/lua/lapi.c setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); L 563 lib/lua/lapi.c lua_unlock(L); L 567 lib/lua/lapi.c LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { L 569 lib/lua/lapi.c lua_lock(L); L 570 lib/lua/lapi.c o = index2adr(L, idx); L 571 lib/lua/lapi.c api_check(L, ttistable(o)); L 572 lib/lua/lapi.c setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); L 573 lib/lua/lapi.c api_incr_top(L); L 574 lib/lua/lapi.c lua_unlock(L); L 578 lib/lua/lapi.c LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { L 579 lib/lua/lapi.c lua_lock(L); L 580 lib/lua/lapi.c luaC_checkGC(L); L 581 lib/lua/lapi.c sethvalue(L, L->top, luaH_new(L, narray, nrec)); L 582 lib/lua/lapi.c api_incr_top(L); L 583 lib/lua/lapi.c lua_unlock(L); L 587 lib/lua/lapi.c LUA_API int lua_getmetatable (lua_State *L, int objindex) { L 591 lib/lua/lapi.c lua_lock(L); L 592 lib/lua/lapi.c obj = index2adr(L, objindex); L 601 lib/lua/lapi.c mt = G(L)->mt[ttype(obj)]; L 607 lib/lua/lapi.c sethvalue(L, L->top, mt); L 608 lib/lua/lapi.c api_incr_top(L); L 611 lib/lua/lapi.c lua_unlock(L); L 616 lib/lua/lapi.c LUA_API void lua_getfenv (lua_State *L, int idx) { L 618 lib/lua/lapi.c lua_lock(L); L 619 lib/lua/lapi.c o = index2adr(L, idx); L 620 lib/lua/lapi.c api_checkvalidindex(L, o); L 623 lib/lua/lapi.c sethvalue(L, L->top, clvalue(o)->c.env); L 626 lib/lua/lapi.c sethvalue(L, L->top, uvalue(o)->env); L 629 lib/lua/lapi.c setobj2s(L, L->top, gt(thvalue(o))); L 632 lib/lua/lapi.c setnilvalue(L->top); L 635 lib/lua/lapi.c api_incr_top(L); L 636 lib/lua/lapi.c lua_unlock(L); L 645 lib/lua/lapi.c LUA_API void lua_settable (lua_State *L, int idx) { L 647 lib/lua/lapi.c lua_lock(L); L 648 lib/lua/lapi.c api_checknelems(L, 2); L 649 lib/lua/lapi.c t = index2adr(L, idx); L 650 lib/lua/lapi.c api_checkvalidindex(L, t); L 651 lib/lua/lapi.c luaV_settable(L, t, L->top - 2, L->top - 1); L 652 lib/lua/lapi.c L->top -= 2; /* pop index and value */ L 653 lib/lua/lapi.c lua_unlock(L); L 657 lib/lua/lapi.c LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { L 660 lib/lua/lapi.c lua_lock(L); L 661 lib/lua/lapi.c api_checknelems(L, 1); L 662 lib/lua/lapi.c t = index2adr(L, idx); L 663 lib/lua/lapi.c api_checkvalidindex(L, t); L 664 lib/lua/lapi.c setsvalue(L, &key, luaS_new(L, k)); L 665 lib/lua/lapi.c luaV_settable(L, t, &key, L->top - 1); L 666 lib/lua/lapi.c L->top--; /* pop value */ L 667 lib/lua/lapi.c lua_unlock(L); L 671 lib/lua/lapi.c LUA_API void lua_rawset (lua_State *L, int idx) { L 673 lib/lua/lapi.c lua_lock(L); L 674 lib/lua/lapi.c api_checknelems(L, 2); L 675 lib/lua/lapi.c t = index2adr(L, idx); L 676 lib/lua/lapi.c api_check(L, ttistable(t)); L 677 lib/lua/lapi.c setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); L 678 lib/lua/lapi.c luaC_barriert(L, hvalue(t), L->top-1); L 679 lib/lua/lapi.c L->top -= 2; L 680 lib/lua/lapi.c lua_unlock(L); L 684 lib/lua/lapi.c LUA_API void lua_rawseti (lua_State *L, int idx, int n) { L 686 lib/lua/lapi.c lua_lock(L); L 687 lib/lua/lapi.c api_checknelems(L, 1); L 688 lib/lua/lapi.c o = index2adr(L, idx); L 689 lib/lua/lapi.c api_check(L, ttistable(o)); L 690 lib/lua/lapi.c setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); L 691 lib/lua/lapi.c luaC_barriert(L, hvalue(o), L->top-1); L 692 lib/lua/lapi.c L->top--; L 693 lib/lua/lapi.c lua_unlock(L); L 697 lib/lua/lapi.c LUA_API int lua_setmetatable (lua_State *L, int objindex) { L 700 lib/lua/lapi.c lua_lock(L); L 701 lib/lua/lapi.c api_checknelems(L, 1); L 702 lib/lua/lapi.c obj = index2adr(L, objindex); L 703 lib/lua/lapi.c api_checkvalidindex(L, obj); L 704 lib/lua/lapi.c if (ttisnil(L->top - 1)) L 707 lib/lua/lapi.c api_check(L, ttistable(L->top - 1)); L 708 lib/lua/lapi.c mt = hvalue(L->top - 1); L 714 lib/lua/lapi.c luaC_objbarriert(L, hvalue(obj), mt); L 720 lib/lua/lapi.c luaC_objbarrier(L, rawuvalue(obj), mt); L 724 lib/lua/lapi.c G(L)->mt[ttype(obj)] = mt; L 728 lib/lua/lapi.c L->top--; L 729 lib/lua/lapi.c lua_unlock(L); L 734 lib/lua/lapi.c LUA_API int lua_setfenv (lua_State *L, int idx) { L 737 lib/lua/lapi.c lua_lock(L); L 738 lib/lua/lapi.c api_checknelems(L, 1); L 739 lib/lua/lapi.c o = index2adr(L, idx); L 740 lib/lua/lapi.c api_checkvalidindex(L, o); L 741 lib/lua/lapi.c api_check(L, ttistable(L->top - 1)); L 744 lib/lua/lapi.c clvalue(o)->c.env = hvalue(L->top - 1); L 747 lib/lua/lapi.c uvalue(o)->env = hvalue(L->top - 1); L 750 lib/lua/lapi.c sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); L 756 lib/lua/lapi.c if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); L 757 lib/lua/lapi.c L->top--; L 758 lib/lua/lapi.c lua_unlock(L); L 768 lib/lua/lapi.c #define adjustresults(L,nres) \ L 769 lib/lua/lapi.c { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } L 772 lib/lua/lapi.c #define checkresults(L,na,nr) \ L 773 lib/lua/lapi.c api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) L 776 lib/lua/lapi.c LUA_API void lua_call (lua_State *L, int nargs, int nresults) { L 778 lib/lua/lapi.c lua_lock(L); L 779 lib/lua/lapi.c api_checknelems(L, nargs+1); L 780 lib/lua/lapi.c checkresults(L, nargs, nresults); L 781 lib/lua/lapi.c func = L->top - (nargs+1); L 782 lib/lua/lapi.c luaD_call(L, func, nresults); L 783 lib/lua/lapi.c adjustresults(L, nresults); L 784 lib/lua/lapi.c lua_unlock(L); L 798 lib/lua/lapi.c static void f_call (lua_State *L, void *ud) { L 800 lib/lua/lapi.c luaD_call(L, c->func, c->nresults); L 805 lib/lua/lapi.c LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { L 809 lib/lua/lapi.c lua_lock(L); L 810 lib/lua/lapi.c api_checknelems(L, nargs+1); L 811 lib/lua/lapi.c checkresults(L, nargs, nresults); L 815 lib/lua/lapi.c StkId o = index2adr(L, errfunc); L 816 lib/lua/lapi.c api_checkvalidindex(L, o); L 817 lib/lua/lapi.c func = savestack(L, o); L 819 lib/lua/lapi.c c.func = L->top - (nargs+1); /* function to be called */ L 821 lib/lua/lapi.c status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); L 822 lib/lua/lapi.c adjustresults(L, nresults); L 823 lib/lua/lapi.c lua_unlock(L); L 837 lib/lua/lapi.c static void f_Ccall (lua_State *L, void *ud) { L 840 lib/lua/lapi.c cl = luaF_newCclosure(L, 0, getcurrenv(L)); L 842 lib/lua/lapi.c setclvalue(L, L->top, cl); /* push function */ L 843 lib/lua/lapi.c api_incr_top(L); L 844 lib/lua/lapi.c setpvalue(L->top, c->ud); /* push only argument */ L 845 lib/lua/lapi.c api_incr_top(L); L 846 lib/lua/lapi.c luaD_call(L, L->top - 2, 0); L 850 lib/lua/lapi.c LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { L 853 lib/lua/lapi.c lua_lock(L); L 856 lib/lua/lapi.c status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); L 857 lib/lua/lapi.c lua_unlock(L); L 862 lib/lua/lapi.c LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, L 866 lib/lua/lapi.c lua_lock(L); L 868 lib/lua/lapi.c luaZ_init(L, &z, reader, data); L 869 lib/lua/lapi.c status = luaD_protectedparser(L, &z, chunkname); L 870 lib/lua/lapi.c lua_unlock(L); L 875 lib/lua/lapi.c LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { L 878 lib/lua/lapi.c lua_lock(L); L 879 lib/lua/lapi.c api_checknelems(L, 1); L 880 lib/lua/lapi.c o = L->top - 1; L 882 lib/lua/lapi.c status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); L 885 lib/lua/lapi.c lua_unlock(L); L 890 lib/lua/lapi.c LUA_API int lua_status (lua_State *L) { L 891 lib/lua/lapi.c return L->status; L 899 lib/lua/lapi.c LUA_API int lua_gc (lua_State *L, int what, int data) { L 902 lib/lua/lapi.c lua_lock(L); L 903 lib/lua/lapi.c g = G(L); L 914 lib/lua/lapi.c luaC_fullgc(L); L 933 lib/lua/lapi.c luaC_step(L); L 953 lib/lua/lapi.c lua_unlock(L); L 964 lib/lua/lapi.c LUA_API int lua_error (lua_State *L) { L 965 lib/lua/lapi.c lua_lock(L); L 966 lib/lua/lapi.c api_checknelems(L, 1); L 967 lib/lua/lapi.c luaG_errormsg(L); L 968 lib/lua/lapi.c lua_unlock(L); L 973 lib/lua/lapi.c LUA_API int lua_next (lua_State *L, int idx) { L 976 lib/lua/lapi.c lua_lock(L); L 977 lib/lua/lapi.c t = index2adr(L, idx); L 978 lib/lua/lapi.c api_check(L, ttistable(t)); L 979 lib/lua/lapi.c more = luaH_next(L, hvalue(t), L->top - 1); L 981 lib/lua/lapi.c api_incr_top(L); L 984 lib/lua/lapi.c L->top -= 1; /* remove key */ L 985 lib/lua/lapi.c lua_unlock(L); L 990 lib/lua/lapi.c LUA_API void lua_concat (lua_State *L, int n) { L 991 lib/lua/lapi.c lua_lock(L); L 992 lib/lua/lapi.c api_checknelems(L, n); L 994 lib/lua/lapi.c luaC_checkGC(L); L 995 lib/lua/lapi.c luaV_concat(L, n, cast_int(L->top - L->base) - 1); L 996 lib/lua/lapi.c L->top -= (n-1); L 999 lib/lua/lapi.c setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); L 1000 lib/lua/lapi.c api_incr_top(L); L 1003 lib/lua/lapi.c lua_unlock(L); L 1007 lib/lua/lapi.c LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { L 1009 lib/lua/lapi.c lua_lock(L); L 1010 lib/lua/lapi.c if (ud) *ud = G(L)->ud; L 1011 lib/lua/lapi.c f = G(L)->frealloc; L 1012 lib/lua/lapi.c lua_unlock(L); L 1017 lib/lua/lapi.c LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { L 1018 lib/lua/lapi.c lua_lock(L); L 1019 lib/lua/lapi.c G(L)->ud = ud; L 1020 lib/lua/lapi.c G(L)->frealloc = f; L 1021 lib/lua/lapi.c lua_unlock(L); L 1025 lib/lua/lapi.c LUA_API void *lua_newuserdata (lua_State *L, size_t size) { L 1027 lib/lua/lapi.c lua_lock(L); L 1028 lib/lua/lapi.c luaC_checkGC(L); L 1029 lib/lua/lapi.c u = luaS_newudata(L, size, getcurrenv(L)); L 1030 lib/lua/lapi.c setuvalue(L, L->top, u); L 1031 lib/lua/lapi.c api_incr_top(L); L 1032 lib/lua/lapi.c lua_unlock(L); L 1057 lib/lua/lapi.c LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { L 1060 lib/lua/lapi.c lua_lock(L); L 1061 lib/lua/lapi.c name = aux_upvalue(index2adr(L, funcindex), n, &val); L 1063 lib/lua/lapi.c setobj2s(L, L->top, val); L 1064 lib/lua/lapi.c api_incr_top(L); L 1066 lib/lua/lapi.c lua_unlock(L); L 1071 lib/lua/lapi.c LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { L 1075 lib/lua/lapi.c lua_lock(L); L 1076 lib/lua/lapi.c fi = index2adr(L, funcindex); L 1077 lib/lua/lapi.c api_checknelems(L, 1); L 1080 lib/lua/lapi.c L->top--; L 1081 lib/lua/lapi.c setobj(L, val, L->top); L 1082 lib/lua/lapi.c luaC_barrier(L, clvalue(fi), L->top); L 1084 lib/lua/lapi.c lua_unlock(L); L 14 lib/lua/lapi.h LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); L 32 lib/lua/lauxlib.c #define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ L 33 lib/lua/lauxlib.c lua_gettop(L) + (i) + 1) L 43 lib/lua/lauxlib.c LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { L 45 lib/lua/lauxlib.c if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ L 46 lib/lua/lauxlib.c return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); L 47 lib/lua/lauxlib.c lua_getinfo(L, "n", &ar); L 51 lib/lua/lauxlib.c return luaL_error(L, "calling " LUA_QS " on bad self (%s)", L 56 lib/lua/lauxlib.c return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", L 61 lib/lua/lauxlib.c LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { L 62 lib/lua/lauxlib.c const char *msg = lua_pushfstring(L, "%s expected, got %s", L 63 lib/lua/lauxlib.c tname, luaL_typename(L, narg)); L 64 lib/lua/lauxlib.c return luaL_argerror(L, narg, msg); L 68 lib/lua/lauxlib.c static void tag_error (lua_State *L, int narg, int tag) { L 69 lib/lua/lauxlib.c luaL_typerror(L, narg, lua_typename(L, tag)); L 73 lib/lua/lauxlib.c LUALIB_API void luaL_where (lua_State *L, int level) { L 75 lib/lua/lauxlib.c if (lua_getstack(L, level, &ar)) { /* check function at level */ L 76 lib/lua/lauxlib.c lua_getinfo(L, "Sl", &ar); /* get info about it */ L 78 lib/lua/lauxlib.c lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); L 82 lib/lua/lauxlib.c lua_pushliteral(L, ""); /* else, no information available... */ L 86 lib/lua/lauxlib.c LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { L 89 lib/lua/lauxlib.c luaL_where(L, 1); L 90 lib/lua/lauxlib.c lua_pushvfstring(L, fmt, argp); L 92 lib/lua/lauxlib.c lua_concat(L, 2); L 93 lib/lua/lauxlib.c return lua_error(L); L 99 lib/lua/lauxlib.c LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, L 101 lib/lua/lauxlib.c const char *name = (def) ? luaL_optstring(L, narg, def) : L 102 lib/lua/lauxlib.c luaL_checkstring(L, narg); L 107 lib/lua/lauxlib.c return luaL_argerror(L, narg, L 108 lib/lua/lauxlib.c lua_pushfstring(L, "invalid option " LUA_QS, name)); L 112 lib/lua/lauxlib.c LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { L 113 lib/lua/lauxlib.c lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ L 114 lib/lua/lauxlib.c if (!lua_isnil(L, -1)) /* name already in use? */ L 116 lib/lua/lauxlib.c lua_pop(L, 1); L 117 lib/lua/lauxlib.c lua_newtable(L); /* create metatable */ L 118 lib/lua/lauxlib.c lua_pushvalue(L, -1); L 119 lib/lua/lauxlib.c lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ L 124 lib/lua/lauxlib.c LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { L 125 lib/lua/lauxlib.c void *p = lua_touserdata(L, ud); L 127 lib/lua/lauxlib.c if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ L 128 lib/lua/lauxlib.c lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ L 129 lib/lua/lauxlib.c if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ L 130 lib/lua/lauxlib.c lua_pop(L, 2); /* remove both metatables */ L 135 lib/lua/lauxlib.c luaL_typerror(L, ud, tname); /* else error */ L 140 lib/lua/lauxlib.c LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { L 141 lib/lua/lauxlib.c if (!lua_checkstack(L, space)) L 142 lib/lua/lauxlib.c luaL_error(L, "stack overflow (%s)", mes); L 146 lib/lua/lauxlib.c LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { L 147 lib/lua/lauxlib.c if (lua_type(L, narg) != t) L 148 lib/lua/lauxlib.c tag_error(L, narg, t); L 152 lib/lua/lauxlib.c LUALIB_API void luaL_checkany (lua_State *L, int narg) { L 153 lib/lua/lauxlib.c if (lua_type(L, narg) == LUA_TNONE) L 154 lib/lua/lauxlib.c luaL_argerror(L, narg, "value expected"); L 158 lib/lua/lauxlib.c LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { L 159 lib/lua/lauxlib.c const char *s = lua_tolstring(L, narg, len); L 160 lib/lua/lauxlib.c if (!s) tag_error(L, narg, LUA_TSTRING); L 165 lib/lua/lauxlib.c LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, L 167 lib/lua/lauxlib.c if (lua_isnoneornil(L, narg)) { L 172 lib/lua/lauxlib.c else return luaL_checklstring(L, narg, len); L 176 lib/lua/lauxlib.c LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { L 177 lib/lua/lauxlib.c lua_Number d = lua_tonumber(L, narg); L 178 lib/lua/lauxlib.c if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ L 179 lib/lua/lauxlib.c tag_error(L, narg, LUA_TNUMBER); L 184 lib/lua/lauxlib.c LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { L 185 lib/lua/lauxlib.c return luaL_opt(L, luaL_checknumber, narg, def); L 189 lib/lua/lauxlib.c LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { L 190 lib/lua/lauxlib.c lua_Integer d = lua_tointeger(L, narg); L 191 lib/lua/lauxlib.c if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ L 192 lib/lua/lauxlib.c tag_error(L, narg, LUA_TNUMBER); L 197 lib/lua/lauxlib.c LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, L 199 lib/lua/lauxlib.c return luaL_opt(L, luaL_checkinteger, narg, def); L 203 lib/lua/lauxlib.c LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { L 204 lib/lua/lauxlib.c if (!lua_getmetatable(L, obj)) /* no metatable? */ L 206 lib/lua/lauxlib.c lua_pushstring(L, event); L 207 lib/lua/lauxlib.c lua_rawget(L, -2); L 208 lib/lua/lauxlib.c if (lua_isnil(L, -1)) { L 209 lib/lua/lauxlib.c lua_pop(L, 2); /* remove metatable and metafield */ L 213 lib/lua/lauxlib.c lua_remove(L, -2); /* remove only metatable */ L 219 lib/lua/lauxlib.c LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { L 220 lib/lua/lauxlib.c obj = abs_index(L, obj); L 221 lib/lua/lauxlib.c if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ L 223 lib/lua/lauxlib.c lua_pushvalue(L, obj); L 224 lib/lua/lauxlib.c lua_call(L, 1, 1); L 229 lib/lua/lauxlib.c LUALIB_API void (luaL_register) (lua_State *L, const char *libname, L 231 lib/lua/lauxlib.c luaI_openlib(L, libname, l, 0); L 242 lib/lua/lauxlib.c LUALIB_API void luaI_openlib (lua_State *L, const char *libname, L 247 lib/lua/lauxlib.c luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); L 248 lib/lua/lauxlib.c lua_getfield(L, -1, libname); /* get _LOADED[libname] */ L 249 lib/lua/lauxlib.c if (!lua_istable(L, -1)) { /* not found? */ L 250 lib/lua/lauxlib.c lua_pop(L, 1); /* remove previous result */ L 252 lib/lua/lauxlib.c if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) L 253 lib/lua/lauxlib.c luaL_error(L, "name conflict for module " LUA_QS, libname); L 254 lib/lua/lauxlib.c lua_pushvalue(L, -1); L 255 lib/lua/lauxlib.c lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ L 257 lib/lua/lauxlib.c lua_remove(L, -2); /* remove _LOADED table */ L 258 lib/lua/lauxlib.c lua_insert(L, -(nup+1)); /* move library table to below upvalues */ L 263 lib/lua/lauxlib.c lua_pushvalue(L, -nup); L 264 lib/lua/lauxlib.c lua_pushcclosure(L, l->func, nup); L 265 lib/lua/lauxlib.c lua_setfield(L, -(nup+2), l->name); L 267 lib/lua/lauxlib.c lua_pop(L, nup); /* remove upvalues */ L 280 lib/lua/lauxlib.c static int checkint (lua_State *L, int topop) { L 281 lib/lua/lauxlib.c int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; L 282 lib/lua/lauxlib.c lua_pop(L, topop); L 287 lib/lua/lauxlib.c static void getsizes (lua_State *L) { L 288 lib/lua/lauxlib.c lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); L 289 lib/lua/lauxlib.c if (lua_isnil(L, -1)) { /* no `size' table? */ L 290 lib/lua/lauxlib.c lua_pop(L, 1); /* remove nil */ L 291 lib/lua/lauxlib.c lua_newtable(L); /* create it */ L 292 lib/lua/lauxlib.c lua_pushvalue(L, -1); /* `size' will be its own metatable */ L 293 lib/lua/lauxlib.c lua_setmetatable(L, -2); L 294 lib/lua/lauxlib.c lua_pushliteral(L, "kv"); L 295 lib/lua/lauxlib.c lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ L 296 lib/lua/lauxlib.c lua_pushvalue(L, -1); L 297 lib/lua/lauxlib.c lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ L 302 lib/lua/lauxlib.c LUALIB_API void luaL_setn (lua_State *L, int t, int n) { L 303 lib/lua/lauxlib.c t = abs_index(L, t); L 304 lib/lua/lauxlib.c lua_pushliteral(L, "n"); L 305 lib/lua/lauxlib.c lua_rawget(L, t); L 306 lib/lua/lauxlib.c if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ L 307 lib/lua/lauxlib.c lua_pushliteral(L, "n"); /* use it */ L 308 lib/lua/lauxlib.c lua_pushinteger(L, n); L 309 lib/lua/lauxlib.c lua_rawset(L, t); L 312 lib/lua/lauxlib.c getsizes(L); L 313 lib/lua/lauxlib.c lua_pushvalue(L, t); L 314 lib/lua/lauxlib.c lua_pushinteger(L, n); L 315 lib/lua/lauxlib.c lua_rawset(L, -3); /* sizes[t] = n */ L 316 lib/lua/lauxlib.c lua_pop(L, 1); /* remove `sizes' */ L 321 lib/lua/lauxlib.c LUALIB_API int luaL_getn (lua_State *L, int t) { L 323 lib/lua/lauxlib.c t = abs_index(L, t); L 324 lib/lua/lauxlib.c lua_pushliteral(L, "n"); /* try t.n */ L 325 lib/lua/lauxlib.c lua_rawget(L, t); L 326 lib/lua/lauxlib.c if ((n = checkint(L, 1)) >= 0) return n; L 327 lib/lua/lauxlib.c getsizes(L); /* else try sizes[t] */ L 328 lib/lua/lauxlib.c lua_pushvalue(L, t); L 329 lib/lua/lauxlib.c lua_rawget(L, -2); L 330 lib/lua/lauxlib.c if ((n = checkint(L, 2)) >= 0) return n; L 331 lib/lua/lauxlib.c return (int)lua_objlen(L, t); L 339 lib/lua/lauxlib.c LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, L 344 lib/lua/lauxlib.c luaL_buffinit(L, &b); L 352 lib/lua/lauxlib.c return lua_tostring(L, -1); L 355 lib/lua/lauxlib.c LUALIB_API const char *luaL_findtable (lua_State *L, int idx, L 358 lib/lua/lauxlib.c lua_pushvalue(L, idx); L 362 lib/lua/lauxlib.c lua_pushlstring(L, fname, e - fname); L 363 lib/lua/lauxlib.c lua_rawget(L, -2); L 364 lib/lua/lauxlib.c if (lua_isnil(L, -1)) { /* no such field? */ L 365 lib/lua/lauxlib.c lua_pop(L, 1); /* remove this nil */ L 366 lib/lua/lauxlib.c lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ L 367 lib/lua/lauxlib.c lua_pushlstring(L, fname, e - fname); L 368 lib/lua/lauxlib.c lua_pushvalue(L, -2); L 369 lib/lua/lauxlib.c lua_settable(L, -4); /* set new table into field */ L 371 lib/lua/lauxlib.c else if (!lua_istable(L, -1)) { /* field has a non-table value? */ L 372 lib/lua/lauxlib.c lua_pop(L, 2); /* remove table and value */ L 375 lib/lua/lauxlib.c lua_remove(L, -2); /* remove previous table */ L 400 lib/lua/lauxlib.c lua_pushlstring(B->L, B->buffer, l); L 410 lib/lua/lauxlib.c lua_State *L = B->L; L 412 lib/lua/lauxlib.c size_t toplen = lua_strlen(L, -1); L 414 lib/lua/lauxlib.c size_t l = lua_strlen(L, -(toget+1)); L 421 lib/lua/lauxlib.c lua_concat(L, toget); L 447 lib/lua/lauxlib.c lua_concat(B->L, B->lvl); L 453 lib/lua/lauxlib.c lua_State *L = B->L; L 455 lib/lua/lauxlib.c const char *s = lua_tolstring(L, -1, &vl); L 459 lib/lua/lauxlib.c lua_pop(L, 1); /* remove from stack */ L 463 lib/lua/lauxlib.c lua_insert(L, -2); /* put buffer before new value */ L 470 lib/lua/lauxlib.c LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { L 471 lib/lua/lauxlib.c B->L = L; L 479 lib/lua/lauxlib.c LUALIB_API int luaL_ref (lua_State *L, int t) { L 481 lib/lua/lauxlib.c t = abs_index(L, t); L 482 lib/lua/lauxlib.c if (lua_isnil(L, -1)) { L 483 lib/lua/lauxlib.c lua_pop(L, 1); /* remove from stack */ L 486 lib/lua/lauxlib.c lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ L 487 lib/lua/lauxlib.c ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ L 488 lib/lua/lauxlib.c lua_pop(L, 1); /* remove it from stack */ L 490 lib/lua/lauxlib.c lua_rawgeti(L, t, ref); /* remove it from list */ L 491 lib/lua/lauxlib.c lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ L 494 lib/lua/lauxlib.c ref = (int)lua_objlen(L, t); L 497 lib/lua/lauxlib.c lua_rawseti(L, t, ref); L 502 lib/lua/lauxlib.c LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { L 504 lib/lua/lauxlib.c t = abs_index(L, t); L 505 lib/lua/lauxlib.c lua_rawgeti(L, t, FREELIST_REF); L 506 lib/lua/lauxlib.c lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ L 507 lib/lua/lauxlib.c lua_pushinteger(L, ref); L 508 lib/lua/lauxlib.c lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ L 527 lib/lua/lauxlib.c static const char *getF (lua_State *L, void *ud, size_t *size) { L 529 lib/lua/lauxlib.c (void)L; L 545 lib/lua/lauxlib.c static const char *getF (lua_State *L, void *ud, size_t *size) { L 547 lib/lua/lauxlib.c (void)L; L 554 lib/lua/lauxlib.c static int errfile (lua_State *L, const char *what, int fnameindex) { L 557 lib/lua/lauxlib.c const char *filename = lua_tostring(L, fnameindex) + 1; L 558 lib/lua/lauxlib.c lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); L 560 lib/lua/lauxlib.c const char *filename = lua_tostring(L, fnameindex) + 1; L 561 lib/lua/lauxlib.c lua_pushfstring(L, "cannot %s %s", what, filename); L 563 lib/lua/lauxlib.c lua_remove(L, fnameindex); L 568 lib/lua/lauxlib.c LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { L 572 lib/lua/lauxlib.c int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ L 575 lib/lua/lauxlib.c lua_pushliteral(L, "=stdin"); L 579 lib/lua/lauxlib.c lua_pushfstring(L, "@%s", filename); L 581 lib/lua/lauxlib.c if (lf.f == NULL) return errfile(L, "open", fnameindex); L 591 lib/lua/lauxlib.c if (lf.f == NULL) return errfile(L, "reopen", fnameindex); L 597 lib/lua/lauxlib.c status = lua_load(L, getF, &lf, lua_tostring(L, -1)); L 601 lib/lua/lauxlib.c lua_settop(L, fnameindex); /* ignore results from `lua_load' */ L 602 lib/lua/lauxlib.c return errfile(L, "read", fnameindex); L 604 lib/lua/lauxlib.c lua_remove(L, fnameindex); L 608 lib/lua/lauxlib.c LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { L 612 lib/lua/lauxlib.c int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ L 613 lib/lua/lauxlib.c lua_pushfstring(L, "@%s", filename); L 615 lib/lua/lauxlib.c if (lf.f == NULL) return errfile(L, "fopen", fnameindex); L 616 lib/lua/lauxlib.c status = lua_load(L, getF, &lf, lua_tostring(L, -1)); L 622 lib/lua/lauxlib.c lua_settop(L, fnameindex); /* ignore results from `lua_load' */ L 623 lib/lua/lauxlib.c return errfile(L, "read", fnameindex); L 625 lib/lua/lauxlib.c lua_remove(L, fnameindex); L 636 lib/lua/lauxlib.c static const char *getS (lua_State *L, void *ud, size_t *size) { L 638 lib/lua/lauxlib.c (void)L; L 646 lib/lua/lauxlib.c LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, L 651 lib/lua/lauxlib.c return lua_load(L, getS, &ls, name); L 655 lib/lua/lauxlib.c LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { L 656 lib/lua/lauxlib.c return luaL_loadbuffer(L, s, strlen(s), s); L 685 lib/lua/lauxlib.c static int panic (lua_State *L) { L 686 lib/lua/lauxlib.c (void)L; /* to avoid warnings */ L 689 lib/lua/lauxlib.c lua_tostring(L, -1)); L 696 lib/lua/lauxlib.c lua_State *L = lua_newstate(l_alloc, NULL); L 697 lib/lua/lauxlib.c if (L) lua_atpanic(L, &panic); L 698 lib/lua/lauxlib.c return L; L 19 lib/lua/lauxlib.h LUALIB_API int (luaL_getn) (lua_State *L, int t); L 20 lib/lua/lauxlib.h LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); L 22 lib/lua/lauxlib.h #define luaL_getn(L,i) ((int)lua_objlen(L, i)) L 23 lib/lua/lauxlib.h #define luaL_setn(L,i,j) ((void)0) /* no op! */ L 42 lib/lua/lauxlib.h LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, L 44 lib/lua/lauxlib.h LUALIB_API void (luaL_register) (lua_State *L, const char *libname, L 46 lib/lua/lauxlib.h LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); L 47 lib/lua/lauxlib.h LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); L 48 lib/lua/lauxlib.h LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); L 49 lib/lua/lauxlib.h LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); L 50 lib/lua/lauxlib.h LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, L 52 lib/lua/lauxlib.h LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, L 54 lib/lua/lauxlib.h LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); L 55 lib/lua/lauxlib.h LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); L 57 lib/lua/lauxlib.h LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); L 58 lib/lua/lauxlib.h LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, L 61 lib/lua/lauxlib.h LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); L 62 lib/lua/lauxlib.h LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); L 63 lib/lua/lauxlib.h LUALIB_API void (luaL_checkany) (lua_State *L, int narg); L 65 lib/lua/lauxlib.h LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); L 66 lib/lua/lauxlib.h LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); L 68 lib/lua/lauxlib.h LUALIB_API void (luaL_where) (lua_State *L, int lvl); L 69 lib/lua/lauxlib.h LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); L 71 lib/lua/lauxlib.h LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, L 74 lib/lua/lauxlib.h LUALIB_API int (luaL_ref) (lua_State *L, int t); L 75 lib/lua/lauxlib.h LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); L 77 lib/lua/lauxlib.h LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); L 78 lib/lua/lauxlib.h LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, L 80 lib/lua/lauxlib.h LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); L 85 lib/lua/lauxlib.h LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, L 88 lib/lua/lauxlib.h LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, L 100 lib/lua/lauxlib.h #define luaL_argcheck(L, cond,numarg,extramsg) \ L 101 lib/lua/lauxlib.h ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) L 102 lib/lua/lauxlib.h #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) L 103 lib/lua/lauxlib.h #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) L 104 lib/lua/lauxlib.h #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) L 105 lib/lua/lauxlib.h #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) L 106 lib/lua/lauxlib.h #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) L 107 lib/lua/lauxlib.h #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) L 109 lib/lua/lauxlib.h #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) L 111 lib/lua/lauxlib.h #define luaL_dofile(L, fn) \ L 112 lib/lua/lauxlib.h (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) L 114 lib/lua/lauxlib.h #define luaL_dostring(L, s) \ L 115 lib/lua/lauxlib.h (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) L 117 lib/lua/lauxlib.h #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) L 119 lib/lua/lauxlib.h #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) L 132 lib/lua/lauxlib.h lua_State *L; L 145 lib/lua/lauxlib.h LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); L 162 lib/lua/lauxlib.h #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ L 163 lib/lua/lauxlib.h (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) L 165 lib/lua/lauxlib.h #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) L 167 lib/lua/lauxlib.h #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) L 34 lib/lua/lbaselib.c static int luaB_print (lua_State *L) { L 35 lib/lua/lbaselib.c int n = lua_gettop(L); /* number of arguments */ L 37 lib/lua/lbaselib.c lua_getglobal(L, "tostring"); L 47 lib/lua/lbaselib.c if(lua_type(L,i) == LUA_TNUMBER) { L 48 lib/lua/lbaselib.c sprintf(numbuf,LUA_NUMBER_FMT,lua_tonumber(L,i)); L 52 lib/lua/lbaselib.c lua_pushvalue(L, -1); /* function to be called */ L 53 lib/lua/lbaselib.c lua_pushvalue(L, i); /* value to print */ L 54 lib/lua/lbaselib.c lua_call(L, 1, 1); L 55 lib/lua/lbaselib.c s = lua_tostring(L, -1); /* get result */ L 57 lib/lua/lbaselib.c return luaL_error(L, LUA_QL("tostring") " must return a string to " L 59 lib/lua/lbaselib.c lua_pop(L, 1); /* pop result */ L 86 lib/lua/lbaselib.c static int luaB_tonumber (lua_State *L) { L 87 lib/lua/lbaselib.c int base = luaL_optint(L, 2, 10); L 89 lib/lua/lbaselib.c luaL_checkany(L, 1); L 90 lib/lua/lbaselib.c if (lua_isnumber(L, 1)) { L 91 lib/lua/lbaselib.c lua_pushnumber(L, lua_tonumber(L, 1)); L 96 lib/lua/lbaselib.c const char *s1 = luaL_checkstring(L, 1); L 99 lib/lua/lbaselib.c luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); L 104 lib/lua/lbaselib.c lua_pushnumber(L, (lua_Number)n); L 109 lib/lua/lbaselib.c lua_pushnil(L); /* else not a number */ L 114 lib/lua/lbaselib.c static int luaB_error (lua_State *L) { L 115 lib/lua/lbaselib.c int level = luaL_optint(L, 2, 1); L 116 lib/lua/lbaselib.c lua_settop(L, 1); L 117 lib/lua/lbaselib.c if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ L 118 lib/lua/lbaselib.c luaL_where(L, level); L 119 lib/lua/lbaselib.c lua_pushvalue(L, 1); L 120 lib/lua/lbaselib.c lua_concat(L, 2); L 122 lib/lua/lbaselib.c return lua_error(L); L 126 lib/lua/lbaselib.c static int luaB_getmetatable (lua_State *L) { L 127 lib/lua/lbaselib.c luaL_checkany(L, 1); L 128 lib/lua/lbaselib.c if (!lua_getmetatable(L, 1)) { L 129 lib/lua/lbaselib.c lua_pushnil(L); L 132 lib/lua/lbaselib.c luaL_getmetafield(L, 1, "__metatable"); L 137 lib/lua/lbaselib.c static int luaB_setmetatable (lua_State *L) { L 138 lib/lua/lbaselib.c int t = lua_type(L, 2); L 139 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 140 lib/lua/lbaselib.c luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, L 142 lib/lua/lbaselib.c if (luaL_getmetafield(L, 1, "__metatable")) L 143 lib/lua/lbaselib.c luaL_error(L, "cannot change a protected metatable"); L 144 lib/lua/lbaselib.c lua_settop(L, 2); L 145 lib/lua/lbaselib.c lua_setmetatable(L, 1); L 150 lib/lua/lbaselib.c static void getfunc (lua_State *L, int opt) { L 151 lib/lua/lbaselib.c if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); L 154 lib/lua/lbaselib.c int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); L 155 lib/lua/lbaselib.c luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); L 156 lib/lua/lbaselib.c if (lua_getstack(L, level, &ar) == 0) L 157 lib/lua/lbaselib.c luaL_argerror(L, 1, "invalid level"); L 158 lib/lua/lbaselib.c lua_getinfo(L, "f", &ar); L 159 lib/lua/lbaselib.c if (lua_isnil(L, -1)) L 160 lib/lua/lbaselib.c luaL_error(L, "no function environment for tail call at level %d", L 166 lib/lua/lbaselib.c static int luaB_getfenv (lua_State *L) { L 167 lib/lua/lbaselib.c getfunc(L, 1); L 168 lib/lua/lbaselib.c if (lua_iscfunction(L, -1)) /* is a C function? */ L 169 lib/lua/lbaselib.c lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ L 171 lib/lua/lbaselib.c lua_getfenv(L, -1); L 176 lib/lua/lbaselib.c static int luaB_setfenv (lua_State *L) { L 177 lib/lua/lbaselib.c luaL_checktype(L, 2, LUA_TTABLE); L 178 lib/lua/lbaselib.c getfunc(L, 0); L 179 lib/lua/lbaselib.c lua_pushvalue(L, 2); L 180 lib/lua/lbaselib.c if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { L 182 lib/lua/lbaselib.c lua_pushthread(L); L 183 lib/lua/lbaselib.c lua_insert(L, -2); L 184 lib/lua/lbaselib.c lua_setfenv(L, -2); L 187 lib/lua/lbaselib.c else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) L 188 lib/lua/lbaselib.c luaL_error(L, L 194 lib/lua/lbaselib.c static int luaB_rawequal (lua_State *L) { L 195 lib/lua/lbaselib.c luaL_checkany(L, 1); L 196 lib/lua/lbaselib.c luaL_checkany(L, 2); L 197 lib/lua/lbaselib.c lua_pushboolean(L, lua_rawequal(L, 1, 2)); L 202 lib/lua/lbaselib.c static int luaB_rawget (lua_State *L) { L 203 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 204 lib/lua/lbaselib.c luaL_checkany(L, 2); L 205 lib/lua/lbaselib.c lua_settop(L, 2); L 206 lib/lua/lbaselib.c lua_rawget(L, 1); L 210 lib/lua/lbaselib.c static int luaB_rawset (lua_State *L) { L 211 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 212 lib/lua/lbaselib.c luaL_checkany(L, 2); L 213 lib/lua/lbaselib.c luaL_checkany(L, 3); L 214 lib/lua/lbaselib.c lua_settop(L, 3); L 215 lib/lua/lbaselib.c lua_rawset(L, 1); L 220 lib/lua/lbaselib.c static int luaB_gcinfo (lua_State *L) { L 221 lib/lua/lbaselib.c lua_pushinteger(L, lua_getgccount(L)); L 226 lib/lua/lbaselib.c static int luaB_collectgarbage (lua_State *L) { L 231 lib/lua/lbaselib.c int o = luaL_checkoption(L, 1, "collect", opts); L 232 lib/lua/lbaselib.c int ex = luaL_optint(L, 2, 0); L 233 lib/lua/lbaselib.c int res = lua_gc(L, optsnum[o], ex); L 236 lib/lua/lbaselib.c int b = lua_gc(L, LUA_GCCOUNTB, 0); L 237 lib/lua/lbaselib.c lua_pushnumber(L, res + ((lua_Number)b/1024)); L 241 lib/lua/lbaselib.c lua_pushboolean(L, res); L 245 lib/lua/lbaselib.c lua_pushnumber(L, res); L 252 lib/lua/lbaselib.c static int luaB_type (lua_State *L) { L 253 lib/lua/lbaselib.c luaL_checkany(L, 1); L 254 lib/lua/lbaselib.c lua_pushstring(L, luaL_typename(L, 1)); L 259 lib/lua/lbaselib.c static int luaB_next (lua_State *L) { L 260 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 261 lib/lua/lbaselib.c lua_settop(L, 2); /* create a 2nd argument if there isn't one */ L 262 lib/lua/lbaselib.c if (lua_next(L, 1)) L 265 lib/lua/lbaselib.c lua_pushnil(L); L 271 lib/lua/lbaselib.c static int luaB_pairs (lua_State *L) { L 272 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 273 lib/lua/lbaselib.c lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ L 274 lib/lua/lbaselib.c lua_pushvalue(L, 1); /* state, */ L 275 lib/lua/lbaselib.c lua_pushnil(L); /* and initial value */ L 280 lib/lua/lbaselib.c static int ipairsaux (lua_State *L) { L 281 lib/lua/lbaselib.c int i = luaL_checkint(L, 2); L 282 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 284 lib/lua/lbaselib.c lua_pushinteger(L, i); L 285 lib/lua/lbaselib.c lua_rawgeti(L, 1, i); L 286 lib/lua/lbaselib.c return (lua_isnil(L, -1)) ? 0 : 2; L 290 lib/lua/lbaselib.c static int luaB_ipairs (lua_State *L) { L 291 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 292 lib/lua/lbaselib.c lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ L 293 lib/lua/lbaselib.c lua_pushvalue(L, 1); /* state, */ L 294 lib/lua/lbaselib.c lua_pushinteger(L, 0); /* and initial value */ L 299 lib/lua/lbaselib.c static int load_aux (lua_State *L, int status) { L 303 lib/lua/lbaselib.c lua_pushnil(L); L 304 lib/lua/lbaselib.c lua_insert(L, -2); /* put before error message */ L 310 lib/lua/lbaselib.c static int luaB_loadstring (lua_State *L) { L 312 lib/lua/lbaselib.c const char *s = luaL_checklstring(L, 1, &l); L 313 lib/lua/lbaselib.c const char *chunkname = luaL_optstring(L, 2, s); L 314 lib/lua/lbaselib.c return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); L 318 lib/lua/lbaselib.c static int luaB_loadfile (lua_State *L) { L 319 lib/lua/lbaselib.c const char *fname = luaL_optstring(L, 1, NULL); L 320 lib/lua/lbaselib.c return load_aux(L, luaL_loadfile(L, fname)); L 330 lib/lua/lbaselib.c static const char *generic_reader (lua_State *L, void *ud, size_t *size) { L 332 lib/lua/lbaselib.c luaL_checkstack(L, 2, "too many nested functions"); L 333 lib/lua/lbaselib.c lua_pushvalue(L, 1); /* get function */ L 334 lib/lua/lbaselib.c lua_call(L, 0, 1); /* call it */ L 335 lib/lua/lbaselib.c if (lua_isnil(L, -1)) { L 339 lib/lua/lbaselib.c else if (lua_isstring(L, -1)) { L 340 lib/lua/lbaselib.c lua_replace(L, 3); /* save string in a reserved stack slot */ L 341 lib/lua/lbaselib.c return lua_tolstring(L, 3, size); L 343 lib/lua/lbaselib.c else luaL_error(L, "reader function must return a string"); L 348 lib/lua/lbaselib.c static int luaB_load (lua_State *L) { L 350 lib/lua/lbaselib.c const char *cname = luaL_optstring(L, 2, "=(load)"); L 351 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TFUNCTION); L 352 lib/lua/lbaselib.c lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ L 353 lib/lua/lbaselib.c status = lua_load(L, generic_reader, NULL, cname); L 354 lib/lua/lbaselib.c return load_aux(L, status); L 358 lib/lua/lbaselib.c static int luaB_dofile (lua_State *L) { L 359 lib/lua/lbaselib.c const char *fname = luaL_optstring(L, 1, NULL); L 360 lib/lua/lbaselib.c int n = lua_gettop(L); L 361 lib/lua/lbaselib.c if (luaL_loadfile(L, fname) != 0) lua_error(L); L 362 lib/lua/lbaselib.c lua_call(L, 0, LUA_MULTRET); L 363 lib/lua/lbaselib.c return lua_gettop(L) - n; L 367 lib/lua/lbaselib.c static int luaB_assert (lua_State *L) { L 368 lib/lua/lbaselib.c luaL_checkany(L, 1); L 369 lib/lua/lbaselib.c if (!lua_toboolean(L, 1)) L 370 lib/lua/lbaselib.c return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); L 371 lib/lua/lbaselib.c return lua_gettop(L); L 375 lib/lua/lbaselib.c static int luaB_unpack (lua_State *L) { L 377 lib/lua/lbaselib.c luaL_checktype(L, 1, LUA_TTABLE); L 378 lib/lua/lbaselib.c i = luaL_optint(L, 2, 1); L 379 lib/lua/lbaselib.c e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); L 382 lib/lua/lbaselib.c if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ L 383 lib/lua/lbaselib.c return luaL_error(L, "too many results to unpack"); L 384 lib/lua/lbaselib.c lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ L 386 lib/lua/lbaselib.c lua_rawgeti(L, 1, i); L 391 lib/lua/lbaselib.c static int luaB_select (lua_State *L) { L 392 lib/lua/lbaselib.c int n = lua_gettop(L); L 393 lib/lua/lbaselib.c if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { L 394 lib/lua/lbaselib.c lua_pushinteger(L, n-1); L 398 lib/lua/lbaselib.c int i = luaL_checkint(L, 1); L 401 lib/lua/lbaselib.c luaL_argcheck(L, 1 <= i, 1, "index out of range"); L 407 lib/lua/lbaselib.c static int luaB_pcall (lua_State *L) { L 409 lib/lua/lbaselib.c luaL_checkany(L, 1); L 410 lib/lua/lbaselib.c status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); L 411 lib/lua/lbaselib.c lua_pushboolean(L, (status == 0)); L 412 lib/lua/lbaselib.c lua_insert(L, 1); L 413 lib/lua/lbaselib.c return lua_gettop(L); /* return status + all results */ L 417 lib/lua/lbaselib.c static int luaB_xpcall (lua_State *L) { L 419 lib/lua/lbaselib.c luaL_checkany(L, 2); L 420 lib/lua/lbaselib.c lua_settop(L, 2); L 421 lib/lua/lbaselib.c lua_insert(L, 1); /* put error function under function to be called */ L 422 lib/lua/lbaselib.c status = lua_pcall(L, 0, LUA_MULTRET, 1); L 423 lib/lua/lbaselib.c lua_pushboolean(L, (status == 0)); L 424 lib/lua/lbaselib.c lua_replace(L, 1); L 425 lib/lua/lbaselib.c return lua_gettop(L); /* return status + all results */ L 429 lib/lua/lbaselib.c static int luaB_tostring (lua_State *L) { L 430 lib/lua/lbaselib.c luaL_checkany(L, 1); L 431 lib/lua/lbaselib.c if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ L 433 lib/lua/lbaselib.c switch (lua_type(L, 1)) { L 435 lib/lua/lbaselib.c lua_pushstring(L, lua_tostring(L, 1)); L 438 lib/lua/lbaselib.c lua_pushvalue(L, 1); L 441 lib/lua/lbaselib.c lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); L 444 lib/lua/lbaselib.c lua_pushliteral(L, "nil"); L 447 lib/lua/lbaselib.c lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); L 454 lib/lua/lbaselib.c static int luaB_newproxy (lua_State *L) { L 455 lib/lua/lbaselib.c lua_settop(L, 1); L 456 lib/lua/lbaselib.c lua_newuserdata(L, 0); /* create proxy */ L 457 lib/lua/lbaselib.c if (lua_toboolean(L, 1) == 0) L 459 lib/lua/lbaselib.c else if (lua_isboolean(L, 1)) { L 460 lib/lua/lbaselib.c lua_newtable(L); /* create a new metatable `m' ... */ L 461 lib/lua/lbaselib.c lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ L 462 lib/lua/lbaselib.c lua_pushboolean(L, 1); L 463 lib/lua/lbaselib.c lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ L 467 lib/lua/lbaselib.c if (lua_getmetatable(L, 1)) { L 468 lib/lua/lbaselib.c lua_rawget(L, lua_upvalueindex(1)); L 469 lib/lua/lbaselib.c validproxy = lua_toboolean(L, -1); L 470 lib/lua/lbaselib.c lua_pop(L, 1); /* remove value */ L 472 lib/lua/lbaselib.c luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); L 473 lib/lua/lbaselib.c lua_getmetatable(L, 1); /* metatable is valid; get it */ L 475 lib/lua/lbaselib.c lua_setmetatable(L, 2); L 527 lib/lua/lbaselib.c static int costatus (lua_State *L, lua_State *co) { L 528 lib/lua/lbaselib.c if (L == co) return CO_RUN; L 547 lib/lua/lbaselib.c static int luaB_costatus (lua_State *L) { L 548 lib/lua/lbaselib.c lua_State *co = lua_tothread(L, 1); L 549 lib/lua/lbaselib.c luaL_argcheck(L, co, 1, "coroutine expected"); L 550 lib/lua/lbaselib.c lua_pushstring(L, statnames[costatus(L, co)]); L 555 lib/lua/lbaselib.c static int auxresume (lua_State *L, lua_State *co, int narg) { L 556 lib/lua/lbaselib.c int status = costatus(L, co); L 558 lib/lua/lbaselib.c luaL_error(L, "too many arguments to resume"); L 560 lib/lua/lbaselib.c lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); L 563 lib/lua/lbaselib.c lua_xmove(L, co, narg); L 564 lib/lua/lbaselib.c lua_setlevel(L, co); L 568 lib/lua/lbaselib.c if (!lua_checkstack(L, nres + 1)) L 569 lib/lua/lbaselib.c luaL_error(L, "too many results to resume"); L 570 lib/lua/lbaselib.c lua_xmove(co, L, nres); /* move yielded values */ L 574 lib/lua/lbaselib.c lua_xmove(co, L, 1); /* move error message */ L 580 lib/lua/lbaselib.c static int luaB_coresume (lua_State *L) { L 581 lib/lua/lbaselib.c lua_State *co = lua_tothread(L, 1); L 583 lib/lua/lbaselib.c luaL_argcheck(L, co, 1, "coroutine expected"); L 584 lib/lua/lbaselib.c r = auxresume(L, co, lua_gettop(L) - 1); L 586 lib/lua/lbaselib.c lua_pushboolean(L, 0); L 587 lib/lua/lbaselib.c lua_insert(L, -2); L 591 lib/lua/lbaselib.c lua_pushboolean(L, 1); L 592 lib/lua/lbaselib.c lua_insert(L, -(r + 1)); L 598 lib/lua/lbaselib.c static int luaB_auxwrap (lua_State *L) { L 599 lib/lua/lbaselib.c lua_State *co = lua_tothread(L, lua_upvalueindex(1)); L 600 lib/lua/lbaselib.c int r = auxresume(L, co, lua_gettop(L)); L 602 lib/lua/lbaselib.c if (lua_isstring(L, -1)) { /* error object is a string? */ L 603 lib/lua/lbaselib.c luaL_where(L, 1); /* add extra info */ L 604 lib/lua/lbaselib.c lua_insert(L, -2); L 605 lib/lua/lbaselib.c lua_concat(L, 2); L 607 lib/lua/lbaselib.c lua_error(L); /* propagate error */ L 613 lib/lua/lbaselib.c static int luaB_cocreate (lua_State *L) { L 614 lib/lua/lbaselib.c lua_State *NL = lua_newthread(L); L 615 lib/lua/lbaselib.c luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, L 617 lib/lua/lbaselib.c lua_pushvalue(L, 1); /* move function to top */ L 618 lib/lua/lbaselib.c lua_xmove(L, NL, 1); /* move function from L to NL */ L 623 lib/lua/lbaselib.c static int luaB_cowrap (lua_State *L) { L 624 lib/lua/lbaselib.c luaB_cocreate(L); L 625 lib/lua/lbaselib.c lua_pushcclosure(L, luaB_auxwrap, 1); L 630 lib/lua/lbaselib.c static int luaB_yield (lua_State *L) { L 631 lib/lua/lbaselib.c return lua_yield(L, lua_gettop(L)); L 635 lib/lua/lbaselib.c static int luaB_corunning (lua_State *L) { L 636 lib/lua/lbaselib.c if (lua_pushthread(L)) L 637 lib/lua/lbaselib.c lua_pushnil(L); /* main thread is not a coroutine */ L 655 lib/lua/lbaselib.c static void auxopen (lua_State *L, const char *name, L 657 lib/lua/lbaselib.c lua_pushcfunction(L, u); L 658 lib/lua/lbaselib.c lua_pushcclosure(L, f, 1); L 659 lib/lua/lbaselib.c lua_setfield(L, -2, name); L 663 lib/lua/lbaselib.c static void base_open (lua_State *L) { L 665 lib/lua/lbaselib.c lua_pushvalue(L, LUA_GLOBALSINDEX); L 666 lib/lua/lbaselib.c lua_setglobal(L, "_G"); L 668 lib/lua/lbaselib.c luaL_register(L, "_G", base_funcs); L 669 lib/lua/lbaselib.c lua_pushliteral(L, LUA_VERSION); L 670 lib/lua/lbaselib.c lua_setglobal(L, "_VERSION"); /* set global _VERSION */ L 672 lib/lua/lbaselib.c auxopen(L, "ipairs", luaB_ipairs, ipairsaux); L 673 lib/lua/lbaselib.c auxopen(L, "pairs", luaB_pairs, luaB_next); L 675 lib/lua/lbaselib.c lua_createtable(L, 0, 1); /* new table `w' */ L 676 lib/lua/lbaselib.c lua_pushvalue(L, -1); /* `w' will be its own metatable */ L 677 lib/lua/lbaselib.c lua_setmetatable(L, -2); L 678 lib/lua/lbaselib.c lua_pushliteral(L, "kv"); L 679 lib/lua/lbaselib.c lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ L 680 lib/lua/lbaselib.c lua_pushcclosure(L, luaB_newproxy, 1); L 681 lib/lua/lbaselib.c lua_setglobal(L, "newproxy"); /* set global `newproxy' */ L 685 lib/lua/lbaselib.c LUALIB_API int luaopen_base (lua_State *L) { L 686 lib/lua/lbaselib.c base_open(L); L 689 lib/lua/lbaselib.c luaL_register(L, LUA_COLIBNAME, co_funcs); L 230 lib/lua/lcode.c lua_State *L = fs->L; L 231 lib/lua/lcode.c TValue *idx = luaH_set(L, fs->h, k); L 240 lib/lua/lcode.c luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, L 243 lib/lua/lcode.c setobj(L, &f->k[fs->nk], v); L 244 lib/lua/lcode.c luaC_barrier(L, f, v); L 252 lib/lua/lcode.c setsvalue(fs->L, &o, s); L 275 lib/lua/lcode.c sethvalue(fs->L, &k, fs->h); L 793 lib/lua/lcode.c luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, L 797 lib/lua/lcode.c luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, L 22 lib/lua/ldblib.c static int db_getregistry (lua_State *L) { L 23 lib/lua/ldblib.c lua_pushvalue(L, LUA_REGISTRYINDEX); L 28 lib/lua/ldblib.c static int db_getmetatable (lua_State *L) { L 29 lib/lua/ldblib.c luaL_checkany(L, 1); L 30 lib/lua/ldblib.c if (!lua_getmetatable(L, 1)) { L 31 lib/lua/ldblib.c lua_pushnil(L); /* no metatable */ L 37 lib/lua/ldblib.c static int db_setmetatable (lua_State *L) { L 38 lib/lua/ldblib.c int t = lua_type(L, 2); L 39 lib/lua/ldblib.c luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, L 41 lib/lua/ldblib.c lua_settop(L, 2); L 42 lib/lua/ldblib.c lua_pushboolean(L, lua_setmetatable(L, 1)); L 47 lib/lua/ldblib.c static int db_getfenv (lua_State *L) { L 48 lib/lua/ldblib.c luaL_checkany(L, 1); L 49 lib/lua/ldblib.c lua_getfenv(L, 1); L 54 lib/lua/ldblib.c static int db_setfenv (lua_State *L) { L 55 lib/lua/ldblib.c luaL_checktype(L, 2, LUA_TTABLE); L 56 lib/lua/ldblib.c lua_settop(L, 2); L 57 lib/lua/ldblib.c if (lua_setfenv(L, 1) == 0) L 58 lib/lua/ldblib.c luaL_error(L, LUA_QL("setfenv") L 64 lib/lua/ldblib.c static void settabss (lua_State *L, const char *i, const char *v) { L 65 lib/lua/ldblib.c lua_pushstring(L, v); L 66 lib/lua/ldblib.c lua_setfield(L, -2, i); L 70 lib/lua/ldblib.c static void settabsi (lua_State *L, const char *i, int v) { L 71 lib/lua/ldblib.c lua_pushinteger(L, v); L 72 lib/lua/ldblib.c lua_setfield(L, -2, i); L 76 lib/lua/ldblib.c static lua_State *getthread (lua_State *L, int *arg) { L 77 lib/lua/ldblib.c if (lua_isthread(L, 1)) { L 79 lib/lua/ldblib.c return lua_tothread(L, 1); L 83 lib/lua/ldblib.c return L; L 88 lib/lua/ldblib.c static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { L 89 lib/lua/ldblib.c if (L == L1) { L 90 lib/lua/ldblib.c lua_pushvalue(L, -2); L 91 lib/lua/ldblib.c lua_remove(L, -3); L 94 lib/lua/ldblib.c lua_xmove(L1, L, 1); L 95 lib/lua/ldblib.c lua_setfield(L, -2, fname); L 99 lib/lua/ldblib.c static int db_getinfo (lua_State *L) { L 102 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 103 lib/lua/ldblib.c const char *options = luaL_optstring(L, arg+2, "flnSu"); L 104 lib/lua/ldblib.c if (lua_isnumber(L, arg+1)) { L 105 lib/lua/ldblib.c if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { L 106 lib/lua/ldblib.c lua_pushnil(L); /* level out of range */ L 110 lib/lua/ldblib.c else if (lua_isfunction(L, arg+1)) { L 111 lib/lua/ldblib.c lua_pushfstring(L, ">%s", options); L 112 lib/lua/ldblib.c options = lua_tostring(L, -1); L 113 lib/lua/ldblib.c lua_pushvalue(L, arg+1); L 114 lib/lua/ldblib.c lua_xmove(L, L1, 1); L 117 lib/lua/ldblib.c return luaL_argerror(L, arg+1, "function or level expected"); L 119 lib/lua/ldblib.c return luaL_argerror(L, arg+2, "invalid option"); L 120 lib/lua/ldblib.c lua_createtable(L, 0, 2); L 122 lib/lua/ldblib.c settabss(L, "source", ar.source); L 123 lib/lua/ldblib.c settabss(L, "short_src", ar.short_src); L 124 lib/lua/ldblib.c settabsi(L, "linedefined", ar.linedefined); L 125 lib/lua/ldblib.c settabsi(L, "lastlinedefined", ar.lastlinedefined); L 126 lib/lua/ldblib.c settabss(L, "what", ar.what); L 129 lib/lua/ldblib.c settabsi(L, "currentline", ar.currentline); L 131 lib/lua/ldblib.c settabsi(L, "nups", ar.nups); L 133 lib/lua/ldblib.c settabss(L, "name", ar.name); L 134 lib/lua/ldblib.c settabss(L, "namewhat", ar.namewhat); L 137 lib/lua/ldblib.c treatstackoption(L, L1, "activelines"); L 139 lib/lua/ldblib.c treatstackoption(L, L1, "func"); L 144 lib/lua/ldblib.c static int db_getlocal (lua_State *L) { L 146 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 149 lib/lua/ldblib.c if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ L 150 lib/lua/ldblib.c return luaL_argerror(L, arg+1, "level out of range"); L 151 lib/lua/ldblib.c name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); L 153 lib/lua/ldblib.c lua_xmove(L1, L, 1); L 154 lib/lua/ldblib.c lua_pushstring(L, name); L 155 lib/lua/ldblib.c lua_pushvalue(L, -2); L 159 lib/lua/ldblib.c lua_pushnil(L); L 165 lib/lua/ldblib.c static int db_setlocal (lua_State *L) { L 167 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 169 lib/lua/ldblib.c if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ L 170 lib/lua/ldblib.c return luaL_argerror(L, arg+1, "level out of range"); L 171 lib/lua/ldblib.c luaL_checkany(L, arg+3); L 172 lib/lua/ldblib.c lua_settop(L, arg+3); L 173 lib/lua/ldblib.c lua_xmove(L, L1, 1); L 174 lib/lua/ldblib.c lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); L 179 lib/lua/ldblib.c static int auxupvalue (lua_State *L, int get) { L 181 lib/lua/ldblib.c int n = luaL_checkint(L, 2); L 182 lib/lua/ldblib.c luaL_checktype(L, 1, LUA_TFUNCTION); L 183 lib/lua/ldblib.c if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ L 184 lib/lua/ldblib.c name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); L 186 lib/lua/ldblib.c lua_pushstring(L, name); L 187 lib/lua/ldblib.c lua_insert(L, -(get+1)); L 192 lib/lua/ldblib.c static int db_getupvalue (lua_State *L) { L 193 lib/lua/ldblib.c return auxupvalue(L, 1); L 197 lib/lua/ldblib.c static int db_setupvalue (lua_State *L) { L 198 lib/lua/ldblib.c luaL_checkany(L, 3); L 199 lib/lua/ldblib.c return auxupvalue(L, 0); L 207 lib/lua/ldblib.c static void hookf (lua_State *L, lua_Debug *ar) { L 210 lib/lua/ldblib.c lua_pushlightuserdata(L, (void *)&KEY_HOOK); L 211 lib/lua/ldblib.c lua_rawget(L, LUA_REGISTRYINDEX); L 212 lib/lua/ldblib.c lua_pushlightuserdata(L, L); L 213 lib/lua/ldblib.c lua_rawget(L, -2); L 214 lib/lua/ldblib.c if (lua_isfunction(L, -1)) { L 215 lib/lua/ldblib.c lua_pushstring(L, hooknames[(int)ar->event]); L 217 lib/lua/ldblib.c lua_pushinteger(L, ar->currentline); L 218 lib/lua/ldblib.c else lua_pushnil(L); L 219 lib/lua/ldblib.c lua_assert(lua_getinfo(L, "lS", ar)); L 220 lib/lua/ldblib.c lua_call(L, 2, 0); L 245 lib/lua/ldblib.c static void gethooktable (lua_State *L) { L 246 lib/lua/ldblib.c lua_pushlightuserdata(L, (void *)&KEY_HOOK); L 247 lib/lua/ldblib.c lua_rawget(L, LUA_REGISTRYINDEX); L 248 lib/lua/ldblib.c if (!lua_istable(L, -1)) { L 249 lib/lua/ldblib.c lua_pop(L, 1); L 250 lib/lua/ldblib.c lua_createtable(L, 0, 1); L 251 lib/lua/ldblib.c lua_pushlightuserdata(L, (void *)&KEY_HOOK); L 252 lib/lua/ldblib.c lua_pushvalue(L, -2); L 253 lib/lua/ldblib.c lua_rawset(L, LUA_REGISTRYINDEX); L 258 lib/lua/ldblib.c static int db_sethook (lua_State *L) { L 261 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 262 lib/lua/ldblib.c if (lua_isnoneornil(L, arg+1)) { L 263 lib/lua/ldblib.c lua_settop(L, arg+1); L 267 lib/lua/ldblib.c const char *smask = luaL_checkstring(L, arg+2); L 268 lib/lua/ldblib.c luaL_checktype(L, arg+1, LUA_TFUNCTION); L 269 lib/lua/ldblib.c count = luaL_optint(L, arg+3, 0); L 272 lib/lua/ldblib.c gethooktable(L); L 273 lib/lua/ldblib.c lua_pushlightuserdata(L, L1); L 274 lib/lua/ldblib.c lua_pushvalue(L, arg+1); L 275 lib/lua/ldblib.c lua_rawset(L, -3); /* set new hook */ L 276 lib/lua/ldblib.c lua_pop(L, 1); /* remove hook table */ L 282 lib/lua/ldblib.c static int db_gethook (lua_State *L) { L 284 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 289 lib/lua/ldblib.c lua_pushliteral(L, "external hook"); L 291 lib/lua/ldblib.c gethooktable(L); L 292 lib/lua/ldblib.c lua_pushlightuserdata(L, L1); L 293 lib/lua/ldblib.c lua_rawget(L, -2); /* get hook */ L 294 lib/lua/ldblib.c lua_remove(L, -2); /* remove hook table */ L 296 lib/lua/ldblib.c lua_pushstring(L, unmakemask(mask, buff)); L 297 lib/lua/ldblib.c lua_pushinteger(L, lua_gethookcount(L1)); L 302 lib/lua/ldblib.c static int db_debug (lua_State *L) { L 309 lib/lua/ldblib.c if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || L 310 lib/lua/ldblib.c lua_pcall(L, 0, 0, 0)) { L 311 lib/lua/ldblib.c fputs(lua_tostring(L, -1), stderr); L 314 lib/lua/ldblib.c lua_settop(L, 0); /* remove eventual returns */ L 322 lib/lua/ldblib.c static int db_errorfb (lua_State *L) { L 326 lib/lua/ldblib.c lua_State *L1 = getthread(L, &arg); L 328 lib/lua/ldblib.c if (lua_isnumber(L, arg+2)) { L 329 lib/lua/ldblib.c level = (int)lua_tointeger(L, arg+2); L 330 lib/lua/ldblib.c lua_pop(L, 1); L 333 lib/lua/ldblib.c level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ L 334 lib/lua/ldblib.c if (lua_gettop(L) == arg) L 335 lib/lua/ldblib.c lua_pushliteral(L, ""); L 336 lib/lua/ldblib.c else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ L 337 lib/lua/ldblib.c else lua_pushliteral(L, "\n"); L 338 lib/lua/ldblib.c lua_pushliteral(L, "stack traceback:"); L 345 lib/lua/ldblib.c lua_pushliteral(L, "\n\t..."); /* too many levels */ L 352 lib/lua/ldblib.c lua_pushliteral(L, "\n\t"); L 354 lib/lua/ldblib.c lua_pushfstring(L, "%s:", ar.short_src); L 356 lib/lua/ldblib.c lua_pushfstring(L, "%d:", ar.currentline); L 358 lib/lua/ldblib.c lua_pushfstring(L, " in function " LUA_QS, ar.name); L 361 lib/lua/ldblib.c lua_pushfstring(L, " in main chunk"); L 363 lib/lua/ldblib.c lua_pushliteral(L, " ?"); /* C function or tail call */ L 365 lib/lua/ldblib.c lua_pushfstring(L, " in function <%s:%d>", L 368 lib/lua/ldblib.c lua_concat(L, lua_gettop(L) - arg); L 370 lib/lua/ldblib.c lua_concat(L, lua_gettop(L) - arg); L 394 lib/lua/ldblib.c LUALIB_API int luaopen_debug (lua_State *L) { L 395 lib/lua/ldblib.c luaL_register(L, LUA_DBLIBNAME, dblib); L 33 lib/lua/ldebug.c static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); L 36 lib/lua/ldebug.c static int currentpc (lua_State *L, CallInfo *ci) { L 38 lib/lua/ldebug.c if (ci == L->ci) L 39 lib/lua/ldebug.c ci->savedpc = L->savedpc; L 44 lib/lua/ldebug.c static int currentline (lua_State *L, CallInfo *ci) { L 45 lib/lua/ldebug.c int pc = currentpc(L, ci); L 56 lib/lua/ldebug.c LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { L 61 lib/lua/ldebug.c L->hook = func; L 62 lib/lua/ldebug.c L->basehookcount = count; L 63 lib/lua/ldebug.c resethookcount(L); L 64 lib/lua/ldebug.c L->hookmask = cast_byte(mask); L 69 lib/lua/ldebug.c LUA_API lua_Hook lua_gethook (lua_State *L) { L 70 lib/lua/ldebug.c return L->hook; L 74 lib/lua/ldebug.c LUA_API int lua_gethookmask (lua_State *L) { L 75 lib/lua/ldebug.c return L->hookmask; L 79 lib/lua/ldebug.c LUA_API int lua_gethookcount (lua_State *L) { L 80 lib/lua/ldebug.c return L->basehookcount; L 84 lib/lua/ldebug.c LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { L 87 lib/lua/ldebug.c lua_lock(L); L 88 lib/lua/ldebug.c for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { L 93 lib/lua/ldebug.c if (level == 0 && ci > L->base_ci) { /* level found? */ L 95 lib/lua/ldebug.c ar->i_ci = cast_int(ci - L->base_ci); L 102 lib/lua/ldebug.c lua_unlock(L); L 112 lib/lua/ldebug.c static const char *findlocal (lua_State *L, CallInfo *ci, int n) { L 115 lib/lua/ldebug.c if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) L 118 lib/lua/ldebug.c StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; L 127 lib/lua/ldebug.c LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { L 128 lib/lua/ldebug.c CallInfo *ci = L->base_ci + ar->i_ci; L 129 lib/lua/ldebug.c const char *name = findlocal(L, ci, n); L 130 lib/lua/ldebug.c lua_lock(L); L 132 lib/lua/ldebug.c luaA_pushobject(L, ci->base + (n - 1)); L 133 lib/lua/ldebug.c lua_unlock(L); L 138 lib/lua/ldebug.c LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { L 139 lib/lua/ldebug.c CallInfo *ci = L->base_ci + ar->i_ci; L 140 lib/lua/ldebug.c const char *name = findlocal(L, ci, n); L 141 lib/lua/ldebug.c lua_lock(L); L 143 lib/lua/ldebug.c setobjs2s(L, ci->base + (n - 1), L->top - 1); L 144 lib/lua/ldebug.c L->top--; /* pop value */ L 145 lib/lua/ldebug.c lua_unlock(L); L 177 lib/lua/ldebug.c static void collectvalidlines (lua_State *L, Closure *f) { L 179 lib/lua/ldebug.c setnilvalue(L->top); L 182 lib/lua/ldebug.c Table *t = luaH_new(L, 0, 0); L 186 lib/lua/ldebug.c setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); L 187 lib/lua/ldebug.c sethvalue(L, L->top, t); L 189 lib/lua/ldebug.c incr_top(L); L 193 lib/lua/ldebug.c static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, L 207 lib/lua/ldebug.c ar->currentline = (ci) ? currentline(L, ci) : -1; L 215 lib/lua/ldebug.c ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; L 232 lib/lua/ldebug.c LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { L 236 lib/lua/ldebug.c lua_lock(L); L 238 lib/lua/ldebug.c StkId func = L->top - 1; L 239 lib/lua/ldebug.c luai_apicheck(L, ttisfunction(func)); L 242 lib/lua/ldebug.c L->top--; /* pop function */ L 245 lib/lua/ldebug.c ci = L->base_ci + ar->i_ci; L 249 lib/lua/ldebug.c status = auxgetinfo(L, what, ar, f, ci); L 251 lib/lua/ldebug.c if (f == NULL) setnilvalue(L->top); L 252 lib/lua/ldebug.c else setclvalue(L, L->top, f); L 253 lib/lua/ldebug.c incr_top(L); L 256 lib/lua/ldebug.c collectvalidlines(L, f); L 257 lib/lua/ldebug.c lua_unlock(L); L 497 lib/lua/ldebug.c static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, L 501 lib/lua/ldebug.c int pc = currentpc(L, ci); L 519 lib/lua/ldebug.c return getobjname(L, ci, b, name); /* get name for `b' */ L 544 lib/lua/ldebug.c static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { L 549 lib/lua/ldebug.c i = ci_func(ci)->l.p->code[currentpc(L, ci)]; L 552 lib/lua/ldebug.c return getobjname(L, ci, GETARG_A(i), name); L 567 lib/lua/ldebug.c LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { L 570 lib/lua/ldebug.c const char *kind = (isinstack(L->ci, o)) ? L 571 lib/lua/ldebug.c getobjname(L, L->ci, cast_int(o - L->base), &name) : L 574 lib/lua/ldebug.c luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", L 577 lib/lua/ldebug.c luaG_runerror(L, "attempt to %s a %s value", op, t); L 581 lib/lua/ldebug.c LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { L 584 lib/lua/ldebug.c luaG_typeerror(L, p1, "concatenate"); L 588 lib/lua/ldebug.c LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { L 592 lib/lua/ldebug.c luaG_typeerror(L, p2, "perform arithmetic on"); L 596 lib/lua/ldebug.c LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { L 600 lib/lua/ldebug.c luaG_runerror(L, "attempt to compare two %s values", t1); L 602 lib/lua/ldebug.c luaG_runerror(L, "attempt to compare %s with %s", t1, t2); L 607 lib/lua/ldebug.c static void addinfo (lua_State *L, const char *msg) { L 608 lib/lua/ldebug.c CallInfo *ci = L->ci; L 611 lib/lua/ldebug.c int line = currentline(L, ci); L 613 lib/lua/ldebug.c luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); L 618 lib/lua/ldebug.c LUAI_FUNC void luaG_errormsg (lua_State *L) { L 619 lib/lua/ldebug.c if (L->errfunc != 0) { /* is there an error handling function? */ L 620 lib/lua/ldebug.c StkId errfunc = restorestack(L, L->errfunc); L 621 lib/lua/ldebug.c if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); L 622 lib/lua/ldebug.c setobjs2s(L, L->top, L->top - 1); /* move argument */ L 623 lib/lua/ldebug.c setobjs2s(L, L->top - 1, errfunc); /* push function */ L 624 lib/lua/ldebug.c incr_top(L); L 625 lib/lua/ldebug.c luaD_call(L, L->top - 2, 1); /* call it */ L 627 lib/lua/ldebug.c luaD_throw(L, LUA_ERRRUN); L 631 lib/lua/ldebug.c LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...) { L 634 lib/lua/ldebug.c addinfo(L, luaO_pushvfstring(L, fmt, argp)); L 636 lib/lua/ldebug.c luaG_errormsg(L); L 18 lib/lua/ldebug.h #define resethookcount(L) (L->hookcount = L->basehookcount) L 21 lib/lua/ldebug.h LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, L 23 lib/lua/ldebug.h LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); L 24 lib/lua/ldebug.h LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, L 26 lib/lua/ldebug.h LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, L 28 lib/lua/ldebug.h LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); L 29 lib/lua/ldebug.h LUAI_FUNC void luaG_errormsg (lua_State *L); L 51 lib/lua/ldo.c LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { L 54 lib/lua/ldo.c setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); L 58 lib/lua/ldo.c setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); L 63 lib/lua/ldo.c setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ L 67 lib/lua/ldo.c L->top = oldtop + 1; L 71 lib/lua/ldo.c static void restore_stack_limit (lua_State *L) { L 72 lib/lua/ldo.c lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); L 73 lib/lua/ldo.c if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ L 74 lib/lua/ldo.c int inuse = cast_int(L->ci - L->base_ci); L 76 lib/lua/ldo.c luaD_reallocCI(L, LUAI_MAXCALLS); L 81 lib/lua/ldo.c static void resetstack (lua_State *L, int status) { L 82 lib/lua/ldo.c L->ci = L->base_ci; L 83 lib/lua/ldo.c L->base = L->ci->base; L 84 lib/lua/ldo.c luaF_close(L, L->base); /* close eventual pending closures */ L 85 lib/lua/ldo.c luaD_seterrorobj(L, status, L->base); L 86 lib/lua/ldo.c L->nCcalls = L->baseCcalls; L 87 lib/lua/ldo.c L->allowhook = 1; L 88 lib/lua/ldo.c restore_stack_limit(L); L 89 lib/lua/ldo.c L->errfunc = 0; L 90 lib/lua/ldo.c L->errorJmp = NULL; L 94 lib/lua/ldo.c LUAI_FUNC void luaD_throw (lua_State *L, int errcode) { L 95 lib/lua/ldo.c if (L->errorJmp) { L 96 lib/lua/ldo.c L->errorJmp->status = errcode; L 97 lib/lua/ldo.c LUAI_THROW(L, L->errorJmp); L 100 lib/lua/ldo.c L->status = cast_byte(errcode); L 101 lib/lua/ldo.c if (G(L)->panic) { L 102 lib/lua/ldo.c resetstack(L, errcode); L 103 lib/lua/ldo.c lua_unlock(L); L 104 lib/lua/ldo.c G(L)->panic(L); L 111 lib/lua/ldo.c LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { L 114 lib/lua/ldo.c lj.previous = L->errorJmp; /* chain new error handler */ L 115 lib/lua/ldo.c L->errorJmp = &lj; L 116 lib/lua/ldo.c LUAI_TRY(L, &lj, L 117 lib/lua/ldo.c (*f)(L, ud); L 119 lib/lua/ldo.c L->errorJmp = lj.previous; /* restore old error handler */ L 126 lib/lua/ldo.c static void correctstack (lua_State *L, TValue *oldstack) { L 129 lib/lua/ldo.c L->top = (L->top - oldstack) + L->stack; L 130 lib/lua/ldo.c for (up = L->openupval; up != NULL; up = up->gch.next) L 131 lib/lua/ldo.c gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; L 132 lib/lua/ldo.c for (ci = L->base_ci; ci <= L->ci; ci++) { L 133 lib/lua/ldo.c ci->top = (ci->top - oldstack) + L->stack; L 134 lib/lua/ldo.c ci->base = (ci->base - oldstack) + L->stack; L 135 lib/lua/ldo.c ci->func = (ci->func - oldstack) + L->stack; L 137 lib/lua/ldo.c L->base = (L->base - oldstack) + L->stack; L 141 lib/lua/ldo.c LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize) { L 142 lib/lua/ldo.c TValue *oldstack = L->stack; L 144 lib/lua/ldo.c lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); L 145 lib/lua/ldo.c luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); L 146 lib/lua/ldo.c L->stacksize = realsize; L 147 lib/lua/ldo.c L->stack_last = L->stack+newsize; L 148 lib/lua/ldo.c correctstack(L, oldstack); L 152 lib/lua/ldo.c LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize) { L 153 lib/lua/ldo.c CallInfo *oldci = L->base_ci; L 154 lib/lua/ldo.c luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); L 155 lib/lua/ldo.c L->size_ci = newsize; L 156 lib/lua/ldo.c L->ci = (L->ci - oldci) + L->base_ci; L 157 lib/lua/ldo.c L->end_ci = L->base_ci + L->size_ci - 1; L 161 lib/lua/ldo.c LUAI_FUNC void luaD_growstack (lua_State *L, int n) { L 162 lib/lua/ldo.c if (n <= L->stacksize) /* double size is enough? */ L 163 lib/lua/ldo.c luaD_reallocstack(L, 2*L->stacksize); L 165 lib/lua/ldo.c luaD_reallocstack(L, L->stacksize + n); L 169 lib/lua/ldo.c static CallInfo *growCI (lua_State *L) { L 170 lib/lua/ldo.c if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ L 171 lib/lua/ldo.c luaD_throw(L, LUA_ERRERR); L 173 lib/lua/ldo.c luaD_reallocCI(L, 2*L->size_ci); L 174 lib/lua/ldo.c if (L->size_ci > LUAI_MAXCALLS) L 175 lib/lua/ldo.c luaG_runerror(L, "stack overflow"); L 177 lib/lua/ldo.c return ++L->ci; L 181 lib/lua/ldo.c LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line) { L 182 lib/lua/ldo.c lua_Hook hook = L->hook; L 183 lib/lua/ldo.c if (hook && L->allowhook) { L 184 lib/lua/ldo.c ptrdiff_t top = savestack(L, L->top); L 185 lib/lua/ldo.c ptrdiff_t ci_top = savestack(L, L->ci->top); L 192 lib/lua/ldo.c ar.i_ci = cast_int(L->ci - L->base_ci); L 193 lib/lua/ldo.c luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ L 194 lib/lua/ldo.c L->ci->top = L->top + LUA_MINSTACK; L 195 lib/lua/ldo.c lua_assert(L->ci->top <= L->stack_last); L 196 lib/lua/ldo.c L->allowhook = 0; /* cannot call hooks inside a hook */ L 197 lib/lua/ldo.c lua_unlock(L); L 198 lib/lua/ldo.c (*hook)(L, &ar); L 199 lib/lua/ldo.c lua_lock(L); L 200 lib/lua/ldo.c lua_assert(!L->allowhook); L 201 lib/lua/ldo.c L->allowhook = 1; L 202 lib/lua/ldo.c L->ci->top = restorestack(L, ci_top); L 203 lib/lua/ldo.c L->top = restorestack(L, top); L 208 lib/lua/ldo.c static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { L 214 lib/lua/ldo.c setnilvalue(L->top++); L 219 lib/lua/ldo.c luaC_checkGC(L); L 220 lib/lua/ldo.c luaD_checkstack(L, p->maxstacksize); L 221 lib/lua/ldo.c htab = luaH_new(L, nvar, 1); /* create `arg' table */ L 223 lib/lua/ldo.c setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i); L 225 lib/lua/ldo.c setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); L 229 lib/lua/ldo.c fixed = L->top - actual; /* first fixed argument */ L 230 lib/lua/ldo.c base = L->top; /* final position of first argument */ L 232 lib/lua/ldo.c setobjs2s(L, L->top++, fixed+i); L 237 lib/lua/ldo.c sethvalue(L, L->top++, htab); L 244 lib/lua/ldo.c static StkId tryfuncTM (lua_State *L, StkId func) { L 245 lib/lua/ldo.c const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); L 247 lib/lua/ldo.c ptrdiff_t funcr = savestack(L, func); L 249 lib/lua/ldo.c luaG_typeerror(L, func, "call"); L 251 lib/lua/ldo.c for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); L 252 lib/lua/ldo.c incr_top(L); L 253 lib/lua/ldo.c func = restorestack(L, funcr); /* previous call may change stack */ L 254 lib/lua/ldo.c setobj2s(L, func, tm); /* tag method is the new function to be called */ L 260 lib/lua/ldo.c #define inc_ci(L) \ L 261 lib/lua/ldo.c ((L->ci == L->end_ci) ? growCI(L) : \ L 262 lib/lua/ldo.c (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) L 265 lib/lua/ldo.c LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults) { L 269 lib/lua/ldo.c func = tryfuncTM(L, func); /* check the `function' tag method */ L 270 lib/lua/ldo.c funcr = savestack(L, func); L 272 lib/lua/ldo.c L->ci->savedpc = L->savedpc; L 277 lib/lua/ldo.c luaD_checkstack(L, p->maxstacksize + p->numparams); L 278 lib/lua/ldo.c func = restorestack(L, funcr); L 281 lib/lua/ldo.c if (L->top > base + p->numparams) L 282 lib/lua/ldo.c L->top = base + p->numparams; L 285 lib/lua/ldo.c int nargs = cast_int(L->top - func) - 1; L 286 lib/lua/ldo.c base = adjust_varargs(L, p, nargs); L 287 lib/lua/ldo.c func = restorestack(L, funcr); /* previous call may change the stack */ L 289 lib/lua/ldo.c ci = inc_ci(L); /* now `enter' new function */ L 291 lib/lua/ldo.c L->base = ci->base = base; L 292 lib/lua/ldo.c ci->top = L->base + p->maxstacksize; L 293 lib/lua/ldo.c lua_assert(ci->top <= L->stack_last); L 294 lib/lua/ldo.c L->savedpc = p->code; /* starting point */ L 297 lib/lua/ldo.c for (st = L->top; st < ci->top; st++) L 299 lib/lua/ldo.c L->top = ci->top; L 300 lib/lua/ldo.c if (L->hookmask & LUA_MASKCALL) { L 301 lib/lua/ldo.c L->savedpc++; /* hooks assume 'pc' is already incremented */ L 302 lib/lua/ldo.c luaD_callhook(L, LUA_HOOKCALL, -1); L 303 lib/lua/ldo.c L->savedpc--; /* correct 'pc' */ L 310 lib/lua/ldo.c luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ L 311 lib/lua/ldo.c ci = inc_ci(L); /* now `enter' new function */ L 312 lib/lua/ldo.c ci->func = restorestack(L, funcr); L 313 lib/lua/ldo.c L->base = ci->base = ci->func + 1; L 314 lib/lua/ldo.c ci->top = L->top + LUA_MINSTACK; L 315 lib/lua/ldo.c lua_assert(ci->top <= L->stack_last); L 317 lib/lua/ldo.c if (L->hookmask & LUA_MASKCALL) L 318 lib/lua/ldo.c luaD_callhook(L, LUA_HOOKCALL, -1); L 319 lib/lua/ldo.c lua_unlock(L); L 320 lib/lua/ldo.c n = (*curr_func(L)->c.f)(L); /* do the actual call */ L 321 lib/lua/ldo.c lua_lock(L); L 325 lib/lua/ldo.c luaD_poscall(L, L->top - n); L 332 lib/lua/ldo.c static StkId callrethooks (lua_State *L, StkId firstResult) { L 333 lib/lua/ldo.c ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ L 334 lib/lua/ldo.c luaD_callhook(L, LUA_HOOKRET, -1); L 335 lib/lua/ldo.c if (f_isLua(L->ci)) { /* Lua function? */ L 336 lib/lua/ldo.c while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ L 337 lib/lua/ldo.c luaD_callhook(L, LUA_HOOKTAILRET, -1); L 339 lib/lua/ldo.c return restorestack(L, fr); L 343 lib/lua/ldo.c LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult) { L 347 lib/lua/ldo.c if (L->hookmask & LUA_MASKRET) L 348 lib/lua/ldo.c firstResult = callrethooks(L, firstResult); L 349 lib/lua/ldo.c ci = L->ci--; L 352 lib/lua/ldo.c L->base = (ci - 1)->base; /* restore base */ L 353 lib/lua/ldo.c L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ L 355 lib/lua/ldo.c for (i = wanted; i != 0 && firstResult < L->top; i--) L 356 lib/lua/ldo.c setobjs2s(L, res++, firstResult++); L 359 lib/lua/ldo.c L->top = res; L 370 lib/lua/ldo.c LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults) { L 371 lib/lua/ldo.c if (++L->nCcalls >= LUAI_MAXCCALLS) { L 372 lib/lua/ldo.c if (L->nCcalls == LUAI_MAXCCALLS) L 373 lib/lua/ldo.c luaG_runerror(L, "C stack overflow"); L 374 lib/lua/ldo.c else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) L 375 lib/lua/ldo.c luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ L 377 lib/lua/ldo.c if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ L 378 lib/lua/ldo.c luaV_execute(L, 1); /* call it */ L 379 lib/lua/ldo.c L->nCcalls--; L 380 lib/lua/ldo.c luaC_checkGC(L); L 384 lib/lua/ldo.c static void resume (lua_State *L, void *ud) { L 386 lib/lua/ldo.c CallInfo *ci = L->ci; L 387 lib/lua/ldo.c if (L->status == 0) { /* start coroutine? */ L 388 lib/lua/ldo.c lua_assert(ci == L->base_ci && firstArg > L->base); L 389 lib/lua/ldo.c if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) L 393 lib/lua/ldo.c lua_assert(L->status == LUA_YIELD); L 394 lib/lua/ldo.c L->status = 0; L 399 lib/lua/ldo.c if (luaD_poscall(L, firstArg)) /* complete it... */ L 400 lib/lua/ldo.c L->top = L->ci->top; /* and correct top if not multiple results */ L 403 lib/lua/ldo.c L->base = L->ci->base; L 405 lib/lua/ldo.c luaV_execute(L, cast_int(L->ci - L->base_ci)); L 409 lib/lua/ldo.c static int resume_error (lua_State *L, const char *msg) { L 410 lib/lua/ldo.c L->top = L->ci->base; L 411 lib/lua/ldo.c setsvalue2s(L, L->top, luaS_new(L, msg)); L 412 lib/lua/ldo.c incr_top(L); L 413 lib/lua/ldo.c lua_unlock(L); L 418 lib/lua/ldo.c LUA_API int lua_resume (lua_State *L, int nargs) { L 420 lib/lua/ldo.c lua_lock(L); L 421 lib/lua/ldo.c if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) L 422 lib/lua/ldo.c return resume_error(L, "cannot resume non-suspended coroutine"); L 423 lib/lua/ldo.c if (L->nCcalls >= LUAI_MAXCCALLS) L 424 lib/lua/ldo.c return resume_error(L, "C stack overflow"); L 425 lib/lua/ldo.c luai_userstateresume(L, nargs); L 426 lib/lua/ldo.c lua_assert(L->errfunc == 0); L 427 lib/lua/ldo.c L->baseCcalls = ++L->nCcalls; L 428 lib/lua/ldo.c status = luaD_rawrunprotected(L, resume, L->top - nargs); L 430 lib/lua/ldo.c L->status = cast_byte(status); /* mark thread as `dead' */ L 431 lib/lua/ldo.c luaD_seterrorobj(L, status, L->top); L 432 lib/lua/ldo.c L->ci->top = L->top; L 435 lib/lua/ldo.c lua_assert(L->nCcalls == L->baseCcalls); L 436 lib/lua/ldo.c status = L->status; L 438 lib/lua/ldo.c --L->nCcalls; L 439 lib/lua/ldo.c lua_unlock(L); L 444 lib/lua/ldo.c LUA_API int lua_yield (lua_State *L, int nresults) { L 445 lib/lua/ldo.c luai_userstateyield(L, nresults); L 446 lib/lua/ldo.c lua_lock(L); L 447 lib/lua/ldo.c if (L->nCcalls > L->baseCcalls) L 448 lib/lua/ldo.c luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); L 449 lib/lua/ldo.c L->base = L->top - nresults; /* protect stack slots below */ L 450 lib/lua/ldo.c L->status = LUA_YIELD; L 451 lib/lua/ldo.c lua_unlock(L); L 456 lib/lua/ldo.c LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, L 459 lib/lua/ldo.c unsigned short oldnCcalls = L->nCcalls; L 460 lib/lua/ldo.c ptrdiff_t old_ci = saveci(L, L->ci); L 461 lib/lua/ldo.c lu_byte old_allowhooks = L->allowhook; L 462 lib/lua/ldo.c ptrdiff_t old_errfunc = L->errfunc; L 463 lib/lua/ldo.c L->errfunc = ef; L 464 lib/lua/ldo.c status = luaD_rawrunprotected(L, func, u); L 466 lib/lua/ldo.c StkId oldtop = restorestack(L, old_top); L 467 lib/lua/ldo.c luaF_close(L, oldtop); /* close eventual pending closures */ L 468 lib/lua/ldo.c luaD_seterrorobj(L, status, oldtop); L 469 lib/lua/ldo.c L->nCcalls = oldnCcalls; L 470 lib/lua/ldo.c L->ci = restoreci(L, old_ci); L 471 lib/lua/ldo.c L->base = L->ci->base; L 472 lib/lua/ldo.c L->savedpc = L->ci->savedpc; L 473 lib/lua/ldo.c L->allowhook = old_allowhooks; L 474 lib/lua/ldo.c restore_stack_limit(L); L 476 lib/lua/ldo.c L->errfunc = old_errfunc; L 491 lib/lua/ldo.c static void f_parser (lua_State *L, void *ud) { L 497 lib/lua/ldo.c luaC_checkGC(L); L 498 lib/lua/ldo.c tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, L 500 lib/lua/ldo.c cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); L 503 lib/lua/ldo.c cl->l.upvals[i] = luaF_newupval(L); L 504 lib/lua/ldo.c setclvalue(L, L->top, cl); L 505 lib/lua/ldo.c incr_top(L); L 509 lib/lua/ldo.c LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { L 513 lib/lua/ldo.c luaZ_initbuffer(L, &p.buff); L 514 lib/lua/ldo.c status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); L 515 lib/lua/ldo.c luaZ_freebuffer(L, &p.buff); L 16 lib/lua/ldo.h #define luaD_checkstack(L,n) \ L 17 lib/lua/ldo.h if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ L 18 lib/lua/ldo.h luaD_growstack(L, n); \ L 19 lib/lua/ldo.h else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); L 22 lib/lua/ldo.h #define incr_top(L) {luaD_checkstack(L,1); L->top++;} L 24 lib/lua/ldo.h #define savestack(L,p) ((char *)(p) - (char *)L->stack) L 25 lib/lua/ldo.h #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) L 27 lib/lua/ldo.h #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) L 28 lib/lua/ldo.h #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) L 38 lib/lua/ldo.h typedef void (*Pfunc) (lua_State *L, void *ud); L 40 lib/lua/ldo.h LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); L 41 lib/lua/ldo.h LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); L 42 lib/lua/ldo.h LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); L 43 lib/lua/ldo.h LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); L 44 lib/lua/ldo.h LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, L 46 lib/lua/ldo.h LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); L 47 lib/lua/ldo.h LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); L 48 lib/lua/ldo.h LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); L 49 lib/lua/ldo.h LUAI_FUNC void luaD_growstack (lua_State *L, int n); L 51 lib/lua/ldo.h LUAI_FUNC void luaD_throw (lua_State *L, int errcode); L 52 lib/lua/ldo.h LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); L 54 lib/lua/ldo.h LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); L 19 lib/lua/ldump.c lua_State* L; L 33 lib/lua/ldump.c lua_unlock(D->L); L 34 lib/lua/ldump.c D->status=(*D->writer)(D->L,b,size,D->data); L 35 lib/lua/ldump.c lua_lock(D->L); L 153 lib/lua/ldump.c LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) L 156 lib/lua/ldump.c D.L=L; L 72 lib/lua/lfmathlib.c static double arg(lua_State *L, int n) { L 73 lib/lua/lfmathlib.c double* v = (double*)lua_touserdata(L, n); L 75 lib/lua/lfmathlib.c int i = luaL_checknumber(L, n); L 82 lib/lua/lfmathlib.c static double* newval(lua_State *L, double v) { L 83 lib/lua/lfmathlib.c double* r = (double*)lua_newuserdata(L, sizeof(double)); L 84 lib/lua/lfmathlib.c luaL_getmetatable(L, "fmathmeta"); L 85 lib/lua/lfmathlib.c lua_setmetatable(L, -2); L 90 lib/lua/lfmathlib.c static int fmath_new (lua_State *L) { L 91 lib/lua/lfmathlib.c int n = luaL_checknumber(L, 1); L 92 lib/lua/lfmathlib.c int d = luaL_optnumber(L, 2, 1); L 93 lib/lua/lfmathlib.c newval(L, (double)n / (double)d); L 99 lib/lua/lfmathlib.c static int fmath_toStr (lua_State *L) { L 102 lib/lua/lfmathlib.c double a = arg(L, 1); L 104 lib/lua/lfmathlib.c int p = luaL_optnumber(L, 2, 6); L 127 lib/lua/lfmathlib.c lua_pushstring(L, buf); L 278 lib/lua/lfmathlib.c static int twoargfn (lua_State *L, int fn) { L 279 lib/lua/lfmathlib.c double a = arg(L, 1); L 280 lib/lua/lfmathlib.c double b = arg(L, 2); L 304 lib/lua/lfmathlib.c newval(L, r); L 308 lib/lua/lfmathlib.c static int oneargfn (lua_State *L, int fn) { L 309 lib/lua/lfmathlib.c double a = arg(L, 1); L 336 lib/lua/lfmathlib.c newval(L, r); L 340 lib/lua/lfmathlib.c static int boolfn (lua_State *L, int fn) { L 341 lib/lua/lfmathlib.c double a = arg(L, 1); L 342 lib/lua/lfmathlib.c double b = arg(L, 2); L 357 lib/lua/lfmathlib.c lua_pushboolean(L, r); L 361 lib/lua/lfmathlib.c static int intfn (lua_State *L, int fn) { L 362 lib/lua/lfmathlib.c double a = arg(L, 1); L 390 lib/lua/lfmathlib.c lua_pushnumber(L, r); L 394 lib/lua/lfmathlib.c static int trigfn(lua_State *L, int fn) { L 395 lib/lua/lfmathlib.c double a = arg(L, 1); L 412 lib/lua/lfmathlib.c newval(L, r); L 416 lib/lua/lfmathlib.c static int atrigfn(lua_State *L, int fn) { L 417 lib/lua/lfmathlib.c double x = arg(L, 1); L 436 lib/lua/lfmathlib.c newval(L, phi); L 440 lib/lua/lfmathlib.c static int fmath_rec(lua_State *L) { L 441 lib/lua/lfmathlib.c double r = arg(L, 1); L 442 lib/lua/lfmathlib.c double theta = arg(L, 2); L 445 lib/lua/lfmathlib.c newval(L, r * _cos); L 446 lib/lua/lfmathlib.c newval(L, r * _sin); L 450 lib/lua/lfmathlib.c static int fmath_pol (lua_State *L) { L 451 lib/lua/lfmathlib.c double px = arg(L, 1); L 452 lib/lua/lfmathlib.c double py = arg(L, 2); L 455 lib/lua/lfmathlib.c newval(L, hyp * INV_GAIN_CIRCLE); L 456 lib/lua/lfmathlib.c newval(L, phi); L 460 lib/lua/lfmathlib.c static int fmath_mul (lua_State *L) { return twoargfn(L, FN_MUL); } L 461 lib/lua/lfmathlib.c static int fmath_div (lua_State *L) { return twoargfn(L, FN_DIV); } L 462 lib/lua/lfmathlib.c static int fmath_add (lua_State *L) { return twoargfn(L, FN_ADD); } L 463 lib/lua/lfmathlib.c static int fmath_sub (lua_State *L) { return twoargfn(L, FN_SUB); } L 464 lib/lua/lfmathlib.c static int fmath_pow (lua_State *L) { return twoargfn(L, FN_POW); } L 465 lib/lua/lfmathlib.c static int fmath_mod (lua_State *L) { return twoargfn(L, FN_MOD); } L 467 lib/lua/lfmathlib.c static int fmath_eq (lua_State *L) { return boolfn(L, FN_EQ); } L 468 lib/lua/lfmathlib.c static int fmath_lt (lua_State *L) { return boolfn(L, FN_LT); } L 469 lib/lua/lfmathlib.c static int fmath_le (lua_State *L) { return boolfn(L, FN_LE); } L 471 lib/lua/lfmathlib.c static int fmath_neg (lua_State *L) { return oneargfn(L, FN_NEG); } L 472 lib/lua/lfmathlib.c static int fmath_log (lua_State *L) { return oneargfn(L, FN_LOG); } L 473 lib/lua/lfmathlib.c static int fmath_log2 (lua_State *L) { return oneargfn(L, FN_LOG2); } L 474 lib/lua/lfmathlib.c static int fmath_log10 (lua_State *L) { return oneargfn(L, FN_LOG10); } L 475 lib/lua/lfmathlib.c static int fmath_sqrt (lua_State *L) { return oneargfn(L, FN_SQRT); } L 476 lib/lua/lfmathlib.c static int fmath_deg (lua_State *L) { return oneargfn(L, FN_DEG); } L 477 lib/lua/lfmathlib.c static int fmath_rad (lua_State *L) { return oneargfn(L, FN_RAD); } L 479 lib/lua/lfmathlib.c static int fmath_int (lua_State *L) { return intfn(L, FN_INT); } L 480 lib/lua/lfmathlib.c static int fmath_ceil (lua_State *L) { return intfn(L, FN_CEIL); } L 481 lib/lua/lfmathlib.c static int fmath_floor (lua_State *L) { return intfn(L, FN_FLOOR); } L 482 lib/lua/lfmathlib.c static int fmath_round (lua_State *L) { return intfn(L, FN_ROUND); } L 484 lib/lua/lfmathlib.c static int fmath_sin (lua_State *L) { return trigfn(L, FN_SIN); } L 485 lib/lua/lfmathlib.c static int fmath_cos (lua_State *L) { return trigfn(L, FN_COS); } L 486 lib/lua/lfmathlib.c static int fmath_tan (lua_State *L) { return trigfn(L, FN_TAN); } L 488 lib/lua/lfmathlib.c static int fmath_asin (lua_State *L) { return atrigfn(L, FN_ASIN); } L 489 lib/lua/lfmathlib.c static int fmath_acos (lua_State *L) { return atrigfn(L, FN_ACOS); } L 490 lib/lua/lfmathlib.c static int fmath_atan (lua_State *L) { return atrigfn(L, FN_ATAN); } L 530 lib/lua/lfmathlib.c LUALIB_API int luaopen_fmath (lua_State *L) { L 531 lib/lua/lfmathlib.c luaL_newmetatable(L, "fmathmeta"); L 532 lib/lua/lfmathlib.c lua_pushstring(L, "__index"); L 533 lib/lua/lfmathlib.c lua_pushvalue(L, -2); /* pushes the metatable */ L 534 lib/lua/lfmathlib.c lua_settable(L, -3); /* metatable.__index = metatable */ L 535 lib/lua/lfmathlib.c luaL_register(L, NULL, fmathlib_m); L 537 lib/lua/lfmathlib.c luaL_register(L, LUA_FMATHLIBNAME, &fmathlib_m[7]); // adjust offset if table is changed L 539 lib/lua/lfmathlib.c newval(L, M_PI * 2.0); L 540 lib/lua/lfmathlib.c lua_setfield(L, -2, "pi2"); L 541 lib/lua/lfmathlib.c newval(L, M_PI); L 542 lib/lua/lfmathlib.c lua_setfield(L, -2, "pi"); L 543 lib/lua/lfmathlib.c newval(L, M_PI / 2.0); L 544 lib/lua/lfmathlib.c lua_setfield(L, -2, "pi_2"); L 23 lib/lua/lfunc.c LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { L 24 lib/lua/lfunc.c Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); L 25 lib/lua/lfunc.c luaC_link(L, obj2gco(c), LUA_TFUNCTION); L 33 lib/lua/lfunc.c LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { L 34 lib/lua/lfunc.c Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); L 35 lib/lua/lfunc.c luaC_link(L, obj2gco(c), LUA_TFUNCTION); L 44 lib/lua/lfunc.c LUAI_FUNC UpVal *luaF_newupval (lua_State *L) { L 45 lib/lua/lfunc.c UpVal *uv = luaM_new(L, UpVal); L 46 lib/lua/lfunc.c luaC_link(L, obj2gco(uv), LUA_TUPVAL); L 53 lib/lua/lfunc.c LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level) { L 54 lib/lua/lfunc.c global_State *g = G(L); L 55 lib/lua/lfunc.c GCObject **pp = &L->openupval; L 67 lib/lua/lfunc.c uv = luaM_new(L, UpVal); /* not found: create a new one */ L 89 lib/lua/lfunc.c LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv) { L 92 lib/lua/lfunc.c luaM_free(L, uv); /* free upvalue */ L 96 lib/lua/lfunc.c LUAI_FUNC void luaF_close (lua_State *L, StkId level) { L 98 lib/lua/lfunc.c global_State *g = G(L); L 99 lib/lua/lfunc.c while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { L 102 lib/lua/lfunc.c L->openupval = uv->next; /* remove from `open' list */ L 104 lib/lua/lfunc.c luaF_freeupval(L, uv); /* free upvalue */ L 107 lib/lua/lfunc.c setobj(L, &uv->u.value, uv->v); L 109 lib/lua/lfunc.c luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ L 115 lib/lua/lfunc.c LUAI_FUNC Proto *luaF_newproto (lua_State *L) { L 116 lib/lua/lfunc.c Proto *f = luaM_new(L, Proto); L 117 lib/lua/lfunc.c luaC_link(L, obj2gco(f), LUA_TPROTO); L 141 lib/lua/lfunc.c LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f) { L 142 lib/lua/lfunc.c luaM_freearray(L, f->code, f->sizecode, Instruction); L 143 lib/lua/lfunc.c luaM_freearray(L, f->p, f->sizep, Proto *); L 144 lib/lua/lfunc.c luaM_freearray(L, f->k, f->sizek, TValue); L 145 lib/lua/lfunc.c luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); L 146 lib/lua/lfunc.c luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); L 147 lib/lua/lfunc.c luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); L 148 lib/lua/lfunc.c luaM_free(L, f); L 152 lib/lua/lfunc.c LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c) { L 155 lib/lua/lfunc.c luaM_freemem(L, c, size); L 21 lib/lua/lfunc.h LUAI_FUNC Proto *luaF_newproto (lua_State *L); L 22 lib/lua/lfunc.h LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); L 23 lib/lua/lfunc.h LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); L 24 lib/lua/lfunc.h LUAI_FUNC UpVal *luaF_newupval (lua_State *L); L 25 lib/lua/lfunc.h LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); L 26 lib/lua/lfunc.h LUAI_FUNC void luaF_close (lua_State *L, StkId level); L 27 lib/lua/lfunc.h LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); L 28 lib/lua/lfunc.h LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); L 29 lib/lua/lfunc.h LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); L 128 lib/lua/lgc.c LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all) { L 129 lib/lua/lgc.c global_State *g = G(L); L 136 lib/lua/lgc.c else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { L 241 lib/lua/lgc.c static void checkstacksizes (lua_State *L, StkId max) { L 242 lib/lua/lgc.c int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ L 243 lib/lua/lgc.c int s_used = cast_int(max - L->stack); /* part of stack in use */ L 244 lib/lua/lgc.c if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ L 246 lib/lua/lgc.c if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) L 247 lib/lua/lgc.c luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ L 248 lib/lua/lgc.c condhardstacktests(luaD_reallocCI(L, ci_used + 1)); L 249 lib/lua/lgc.c if (4*s_used < L->stacksize && L 250 lib/lua/lgc.c 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) L 251 lib/lua/lgc.c luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ L 252 lib/lua/lgc.c condhardstacktests(luaD_reallocstack(L, s_used)); L 378 lib/lua/lgc.c static void freeobj (lua_State *L, GCObject *o) { L 380 lib/lua/lgc.c case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; L 381 lib/lua/lgc.c case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; L 382 lib/lua/lgc.c case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; L 383 lib/lua/lgc.c case LUA_TTABLE: luaH_free(L, gco2h(o)); break; L 385 lib/lua/lgc.c lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); L 386 lib/lua/lgc.c luaE_freethread(L, gco2th(o)); L 390 lib/lua/lgc.c G(L)->strt.nuse--; L 391 lib/lua/lgc.c luaM_freemem(L, o, sizestring(gco2ts(o))); L 395 lib/lua/lgc.c luaM_freemem(L, o, sizeudata(gco2u(o))); L 404 lib/lua/lgc.c #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) L 407 lib/lua/lgc.c static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { L 409 lib/lua/lgc.c global_State *g = G(L); L 413 lib/lua/lgc.c sweepwholelist(L, &gco2th(curr)->openupval); L 424 lib/lua/lgc.c freeobj(L, curr); L 431 lib/lua/lgc.c static void checkSizes (lua_State *L) { L 432 lib/lua/lgc.c global_State *g = G(L); L 436 lib/lua/lgc.c luaS_resize(L, g->strt.size/2); /* table is too big */ L 440 lib/lua/lgc.c luaZ_resizebuffer(L, &g->buff, newsize); L 445 lib/lua/lgc.c static void GCTM (lua_State *L) { L 446 lib/lua/lgc.c global_State *g = G(L); L 458 lib/lua/lgc.c tm = fasttm(L, udata->uv.metatable, TM_GC); L 460 lib/lua/lgc.c lu_byte oldah = L->allowhook; L 462 lib/lua/lgc.c L->allowhook = 0; /* stop debug hooks during GC tag method */ L 464 lib/lua/lgc.c setobj2s(L, L->top, tm); L 465 lib/lua/lgc.c setuvalue(L, L->top+1, udata); L 466 lib/lua/lgc.c L->top += 2; L 467 lib/lua/lgc.c luaD_call(L, L->top - 2, 0); L 468 lib/lua/lgc.c L->allowhook = oldah; /* restore hooks */ L 477 lib/lua/lgc.c LUAI_FUNC void luaC_callGCTM (lua_State *L) { L 478 lib/lua/lgc.c while (G(L)->tmudata) L 479 lib/lua/lgc.c GCTM(L); L 483 lib/lua/lgc.c LUAI_FUNC void luaC_freeall (lua_State *L) { L 484 lib/lua/lgc.c global_State *g = G(L); L 487 lib/lua/lgc.c sweepwholelist(L, &g->rootgc); L 489 lib/lua/lgc.c sweepwholelist(L, &g->strt.hash[i]); L 501 lib/lua/lgc.c static void markroot (lua_State *L) { L 502 lib/lua/lgc.c global_State *g = G(L); L 509 lib/lua/lgc.c markvalue(g, registry(L)); L 525 lib/lua/lgc.c static void atomic (lua_State *L) { L 526 lib/lua/lgc.c global_State *g = G(L); L 536 lib/lua/lgc.c markobject(g, L); /* mark running thread */ L 543 lib/lua/lgc.c udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ L 556 lib/lua/lgc.c static l_mem singlestep (lua_State *L) { L 557 lib/lua/lgc.c global_State *g = G(L); L 561 lib/lua/lgc.c markroot(L); /* start a new collection */ L 568 lib/lua/lgc.c atomic(L); /* finish mark phase */ L 574 lib/lua/lgc.c sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); L 583 lib/lua/lgc.c g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); L 585 lib/lua/lgc.c checkSizes(L); L 594 lib/lua/lgc.c GCTM(L); L 610 lib/lua/lgc.c LUAI_FUNC void luaC_step (lua_State *L) { L 611 lib/lua/lgc.c global_State *g = G(L); L 617 lib/lua/lgc.c lim -= singlestep(L); L 635 lib/lua/lgc.c LUAI_FUNC void luaC_fullgc (lua_State *L) { L 636 lib/lua/lgc.c global_State *g = G(L); L 651 lib/lua/lgc.c singlestep(L); L 653 lib/lua/lgc.c markroot(L); L 655 lib/lua/lgc.c singlestep(L); L 661 lib/lua/lgc.c LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { L 662 lib/lua/lgc.c global_State *g = G(L); L 674 lib/lua/lgc.c LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t) { L 675 lib/lua/lgc.c global_State *g = G(L); L 685 lib/lua/lgc.c LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { L 686 lib/lua/lgc.c global_State *g = G(L); L 694 lib/lua/lgc.c LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv) { L 695 lib/lua/lgc.c global_State *g = G(L); L 702 lib/lua/lgc.c luaC_barrier(L, uv, uv->v); L 80 lib/lua/lgc.h #define luaC_checkGC(L) { \ L 81 lib/lua/lgc.h condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ L 82 lib/lua/lgc.h if (G(L)->totalbytes >= G(L)->GCthreshold) \ L 83 lib/lua/lgc.h luaC_step(L); } L 86 lib/lua/lgc.h #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ L 87 lib/lua/lgc.h luaC_barrierf(L,obj2gco(p),gcvalue(v)); } L 89 lib/lua/lgc.h #define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ L 90 lib/lua/lgc.h luaC_barrierback(L,t); } L 92 lib/lua/lgc.h #define luaC_objbarrier(L,p,o) \ L 94 lib/lua/lgc.h luaC_barrierf(L,obj2gco(p),obj2gco(o)); } L 96 lib/lua/lgc.h #define luaC_objbarriert(L,t,o) \ L 97 lib/lua/lgc.h { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } L 99 lib/lua/lgc.h LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); L 100 lib/lua/lgc.h LUAI_FUNC void luaC_callGCTM (lua_State *L); L 101 lib/lua/lgc.h LUAI_FUNC void luaC_freeall (lua_State *L); L 102 lib/lua/lgc.h LUAI_FUNC void luaC_step (lua_State *L); L 103 lib/lua/lgc.h LUAI_FUNC void luaC_fullgc (lua_State *L); L 104 lib/lua/lgc.h LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); L 105 lib/lua/lgc.h LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); L 106 lib/lua/lgc.h LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); L 107 lib/lua/lgc.h LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); L 30 lib/lua/limathlib.c static int imath_muldiv (lua_State *L) { L 31 lib/lua/limathlib.c int c = luaL_checknumber(L, 3); L 32 lib/lua/limathlib.c if (c == 0) luaL_error(L, "divide by 0"); L 33 lib/lua/limathlib.c lua_pushnumber(L, muldivScaled(luaL_checknumber(L, 1), L 34 lib/lua/limathlib.c luaL_checknumber(L, 2), c)); L 38 lib/lua/limathlib.c static int imath_mul (lua_State *L) { L 39 lib/lua/limathlib.c lua_pushnumber(L, muldivScaled(luaL_checknumber(L, 1), L 40 lib/lua/limathlib.c luaL_checknumber(L, 2), INT_SCALE)); L 44 lib/lua/limathlib.c static int imath_div (lua_State *L) { L 45 lib/lua/limathlib.c int c = luaL_checknumber(L, 2); L 46 lib/lua/limathlib.c if (c == 0) luaL_error(L, "divide by 0"); L 47 lib/lua/limathlib.c lua_pushnumber(L, muldivScaled(INT_SCALE, luaL_checknumber(L, 1), c)); L 52 lib/lua/limathlib.c static int imath_sinr (lua_State *L) { L 53 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(sinr(INT2FIXED(luaL_checknumber(L, 1))))); L 57 lib/lua/limathlib.c static int imath_cosr (lua_State *L) { L 58 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(cosr(INT2FIXED(luaL_checknumber(L, 1))))); L 62 lib/lua/limathlib.c static int imath_tanr (lua_State *L) { L 63 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(tanr(INT2FIXED(luaL_checknumber(L, 1))))); L 67 lib/lua/limathlib.c static int imath_recr (lua_State *L) { L 69 lib/lua/limathlib.c recr(INT2FIXED(luaL_checknumber(L, 1)), L 70 lib/lua/limathlib.c INT2FIXED(luaL_checknumber(L, 2)), &px, &py); L 71 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(px)); L 72 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(py)); L 76 lib/lua/limathlib.c static int imath_asinr (lua_State *L) { L 77 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(asinr(INT2FIXED(luaL_checknumber(L, 1))))); L 81 lib/lua/limathlib.c static int imath_acosr (lua_State *L) { L 82 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(acosr(INT2FIXED(luaL_checknumber(L, 1))))); L 86 lib/lua/limathlib.c static int imath_atanr (lua_State *L) { L 87 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(atanr(INT2FIXED(luaL_checknumber(L, 1))))); L 91 lib/lua/limathlib.c static int imath_polr (lua_State *L) { L 93 lib/lua/limathlib.c polr(INT2FIXED(luaL_checknumber(L, 1)), L 94 lib/lua/limathlib.c INT2FIXED(luaL_checknumber(L, 2)), &r, &theta); L 95 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(r)); L 96 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(theta)); L 101 lib/lua/limathlib.c static int imath_sind (lua_State *L) { L 102 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(sind(INT2FIXED(luaL_checknumber(L, 1))))); L 106 lib/lua/limathlib.c static int imath_cosd (lua_State *L) { L 107 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(cosd(INT2FIXED(luaL_checknumber(L, 1))))); L 111 lib/lua/limathlib.c static int imath_tand (lua_State *L) { L 112 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(tand(INT2FIXED(luaL_checknumber(L, 1))))); L 116 lib/lua/limathlib.c static int imath_recd (lua_State *L) { L 118 lib/lua/limathlib.c recd(INT2FIXED(luaL_checknumber(L, 1)), L 119 lib/lua/limathlib.c INT2FIXED(luaL_checknumber(L, 2)), &px, &py); L 120 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(px)); L 121 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(py)); L 125 lib/lua/limathlib.c static int imath_asind (lua_State *L) { L 126 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(asind(INT2FIXED(luaL_checknumber(L, 1))))); L 130 lib/lua/limathlib.c static int imath_acosd (lua_State *L) { L 131 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(acosd(INT2FIXED(luaL_checknumber(L, 1))))); L 135 lib/lua/limathlib.c static int imath_atand (lua_State *L) { L 136 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(atand(INT2FIXED(luaL_checknumber(L, 1))))); L 140 lib/lua/limathlib.c static int imath_pold (lua_State *L) { L 142 lib/lua/limathlib.c pold(INT2FIXED(luaL_checknumber(L, 1)), L 143 lib/lua/limathlib.c INT2FIXED(luaL_checknumber(L, 2)), &r, &theta); L 144 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(r)); L 145 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(theta)); L 149 lib/lua/limathlib.c static int imath_deg (lua_State *L) { L 150 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(intToFloat(luaL_checknumber(L, 1)) * 180 / M_PI)); L 154 lib/lua/limathlib.c static int imath_rad (lua_State *L) { L 155 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(intToFloat(luaL_checknumber(L, 1)) * M_PI / 180)); L 159 lib/lua/limathlib.c static int imath_log (lua_State *L) { L 160 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(log(intToFloat(luaL_checknumber(L, 1))))); L 164 lib/lua/limathlib.c static int imath_log2 (lua_State *L) { L 165 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(log2(intToFloat(luaL_checknumber(L, 1))))); L 169 lib/lua/limathlib.c static int imath_log10 (lua_State *L) { L 170 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(log10(intToFloat(luaL_checknumber(L, 1))))); L 174 lib/lua/limathlib.c static int imath_pow (lua_State *L) { L 175 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(pow(intToFloat(luaL_checknumber(L, 1)), L 176 lib/lua/limathlib.c intToFloat(luaL_checknumber(L, 2))))); L 180 lib/lua/limathlib.c static int imath_sqrt (lua_State *L) { L 181 lib/lua/limathlib.c lua_pushnumber(L, floatToInt(sqrt(intToFloat(luaL_checknumber(L, 1))))); L 186 lib/lua/limathlib.c static int imath_int (lua_State *L) { L 187 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INT(fint(INT2FIXED(luaL_checknumber(L, 1))))); L 191 lib/lua/limathlib.c static int imath_frac (lua_State *L) { L 192 lib/lua/limathlib.c lua_pushnumber(L, luaL_checknumber(L, 1) - FIXED2INT(fint(INT2FIXED(luaL_checknumber(L, 1))))); L 196 lib/lua/limathlib.c static int imath_ceil (lua_State *L) { L 197 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INT(fceil(INT2FIXED(luaL_checknumber(L, 1))))); L 201 lib/lua/limathlib.c static int imath_floor (lua_State *L) { L 202 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INT(ffloor(INT2FIXED(luaL_checknumber(L, 1))))); L 206 lib/lua/limathlib.c static int imath_round (lua_State *L) { L 207 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INT(fround(INT2FIXED(luaL_checknumber(L, 1))))); L 250 lib/lua/limathlib.c LUALIB_API int luaopen_imath (lua_State *L) { L 251 lib/lua/limathlib.c luaL_register(L, LUA_IMATHLIBNAME, imathlib); L 253 lib/lua/limathlib.c lua_pushnumber(L, INT_SCALE); L 254 lib/lua/limathlib.c lua_setfield(L, -2, "scale"); L 255 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(FULL_CIRCLE[RAD])); L 256 lib/lua/limathlib.c lua_setfield(L, -2, "pi2"); L 257 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(HALF_CIRCLE[RAD])); L 258 lib/lua/limathlib.c lua_setfield(L, -2, "pi"); L 259 lib/lua/limathlib.c lua_pushnumber(L, FIXED2INTR(QUART_CIRCLE[RAD])); L 260 lib/lua/limathlib.c lua_setfield(L, -2, "pi_2"); L 32 lib/lua/linit.c LUALIB_API void luaL_openlibs (lua_State *L) { L 35 lib/lua/linit.c lua_pushcfunction(L, lib->func); L 36 lib/lua/linit.c lua_pushstring(L, lib->name); L 37 lib/lua/linit.c lua_call(L, 1, 0); L 28 lib/lua/liolib.c static int pushresult (lua_State *L, int i, const char *filename) { L 31 lib/lua/liolib.c lua_pushboolean(L, 1); L 35 lib/lua/liolib.c lua_pushnil(L); L 37 lib/lua/liolib.c lua_pushfstring(L, "%s: %s", filename, strerror(en)); L 39 lib/lua/liolib.c lua_pushfstring(L, "%s", strerror(en)); L 40 lib/lua/liolib.c lua_pushinteger(L, en); L 46 lib/lua/liolib.c static void fileerror (lua_State *L, int arg, const char *filename) { L 47 lib/lua/liolib.c lua_pushfstring(L, "%s: %s", filename, strerror(errno)); L 48 lib/lua/liolib.c luaL_argerror(L, arg, lua_tostring(L, -1)); L 52 lib/lua/liolib.c #define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) L 55 lib/lua/liolib.c static int io_type (lua_State *L) { L 57 lib/lua/liolib.c luaL_checkany(L, 1); L 58 lib/lua/liolib.c ud = lua_touserdata(L, 1); L 59 lib/lua/liolib.c lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); L 60 lib/lua/liolib.c if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) L 61 lib/lua/liolib.c lua_pushnil(L); /* not a file */ L 63 lib/lua/liolib.c lua_pushliteral(L, "closed file"); L 65 lib/lua/liolib.c lua_pushliteral(L, "file"); L 70 lib/lua/liolib.c static FILE *tofile (lua_State *L) { L 71 lib/lua/liolib.c FILE **f = tofilep(L); L 73 lib/lua/liolib.c luaL_error(L, "attempt to use a closed file"); L 84 lib/lua/liolib.c static FILE **newfile (lua_State *L) { L 85 lib/lua/liolib.c FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); L 87 lib/lua/liolib.c luaL_getmetatable(L, LUA_FILEHANDLE); L 88 lib/lua/liolib.c lua_setmetatable(L, -2); L 96 lib/lua/liolib.c static int io_noclose (lua_State *L) { L 97 lib/lua/liolib.c lua_pushnil(L); L 98 lib/lua/liolib.c lua_pushliteral(L, "cannot close standard file"); L 108 lib/lua/liolib.c static int io_pclose (lua_State *L) { L 109 lib/lua/liolib.c FILE **p = tofilep(L); L 110 lib/lua/liolib.c int ok = lua_pclose(L, *p); L 112 lib/lua/liolib.c return pushresult(L, ok, NULL); L 120 lib/lua/liolib.c static int io_fclose (lua_State *L) { L 121 lib/lua/liolib.c FILE **p = tofilep(L); L 124 lib/lua/liolib.c return pushresult(L, ok, NULL); L 128 lib/lua/liolib.c static int aux_close (lua_State *L) { L 129 lib/lua/liolib.c lua_getfenv(L, 1); L 130 lib/lua/liolib.c lua_getfield(L, -1, "__close"); L 131 lib/lua/liolib.c return (lua_tocfunction(L, -1))(L); L 135 lib/lua/liolib.c static int io_close (lua_State *L) { L 136 lib/lua/liolib.c if (lua_isnone(L, 1)) L 137 lib/lua/liolib.c lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); L 138 lib/lua/liolib.c tofile(L); /* make sure argument is a file */ L 139 lib/lua/liolib.c return aux_close(L); L 143 lib/lua/liolib.c static int io_gc (lua_State *L) { L 144 lib/lua/liolib.c FILE *f = *tofilep(L); L 147 lib/lua/liolib.c aux_close(L); L 152 lib/lua/liolib.c static int io_tostring (lua_State *L) { L 153 lib/lua/liolib.c FILE *f = *tofilep(L); L 155 lib/lua/liolib.c lua_pushliteral(L, "file (closed)"); L 157 lib/lua/liolib.c lua_pushfstring(L, "file (%p)", f); L 162 lib/lua/liolib.c static int io_open (lua_State *L) { L 163 lib/lua/liolib.c const char *filename = luaL_checkstring(L, 1); L 164 lib/lua/liolib.c const char *mode = luaL_optstring(L, 2, "r"); L 165 lib/lua/liolib.c FILE **pf = newfile(L); L 167 lib/lua/liolib.c return (*pf == NULL) ? pushresult(L, 0, filename) : 1; L 176 lib/lua/liolib.c static int io_popen (lua_State *L) { L 177 lib/lua/liolib.c const char *filename = luaL_checkstring(L, 1); L 178 lib/lua/liolib.c const char *mode = luaL_optstring(L, 2, "r"); L 179 lib/lua/liolib.c FILE **pf = newfile(L); L 180 lib/lua/liolib.c *pf = lua_popen(L, filename, mode); L 181 lib/lua/liolib.c return (*pf == NULL) ? pushresult(L, 0, filename) : 1; L 188 lib/lua/liolib.c static int io_tmpfile (lua_State *L) { L 189 lib/lua/liolib.c FILE **pf = newfile(L); L 191 lib/lua/liolib.c return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; L 196 lib/lua/liolib.c static FILE *getiofile (lua_State *L, int findex) { L 198 lib/lua/liolib.c lua_rawgeti(L, LUA_ENVIRONINDEX, findex); L 199 lib/lua/liolib.c f = *(FILE **)lua_touserdata(L, -1); L 201 lib/lua/liolib.c luaL_error(L, "standard %s file is closed", fnames[findex - 1]); L 206 lib/lua/liolib.c static int g_iofile (lua_State *L, int f, const char *mode) { L 207 lib/lua/liolib.c if (!lua_isnoneornil(L, 1)) { L 208 lib/lua/liolib.c const char *filename = lua_tostring(L, 1); L 210 lib/lua/liolib.c FILE **pf = newfile(L); L 213 lib/lua/liolib.c fileerror(L, 1, filename); L 216 lib/lua/liolib.c tofile(L); /* check that it's a valid file handle */ L 217 lib/lua/liolib.c lua_pushvalue(L, 1); L 219 lib/lua/liolib.c lua_rawseti(L, LUA_ENVIRONINDEX, f); L 222 lib/lua/liolib.c lua_rawgeti(L, LUA_ENVIRONINDEX, f); L 227 lib/lua/liolib.c static int io_input (lua_State *L) { L 228 lib/lua/liolib.c return g_iofile(L, IO_INPUT, "r"); L 232 lib/lua/liolib.c static int io_output (lua_State *L) { L 233 lib/lua/liolib.c return g_iofile(L, IO_OUTPUT, "w"); L 237 lib/lua/liolib.c static int io_readline (lua_State *L); L 240 lib/lua/liolib.c static void aux_lines (lua_State *L, int idx, int toclose) { L 241 lib/lua/liolib.c lua_pushvalue(L, idx); L 242 lib/lua/liolib.c lua_pushboolean(L, toclose); /* close/not close file when finished */ L 243 lib/lua/liolib.c lua_pushcclosure(L, io_readline, 2); L 247 lib/lua/liolib.c static int f_lines (lua_State *L) { L 248 lib/lua/liolib.c tofile(L); /* check that it's a valid file handle */ L 249 lib/lua/liolib.c aux_lines(L, 1, 0); L 254 lib/lua/liolib.c static int io_lines (lua_State *L) { L 255 lib/lua/liolib.c if (lua_isnoneornil(L, 1)) { /* no arguments? */ L 257 lib/lua/liolib.c lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); L 258 lib/lua/liolib.c return f_lines(L); L 261 lib/lua/liolib.c const char *filename = luaL_checkstring(L, 1); L 262 lib/lua/liolib.c FILE **pf = newfile(L); L 265 lib/lua/liolib.c fileerror(L, 1, filename); L 266 lib/lua/liolib.c aux_lines(L, lua_gettop(L), 1); L 315 lib/lua/liolib.c static int read_number (lua_State *L, FILE *f) { L 323 lib/lua/liolib.c lua_pushnumber(L, d); L 327 lib/lua/liolib.c lua_pushnil(L); /* "result" to be removed */ L 334 lib/lua/liolib.c static int test_eof (lua_State *L, FILE *f) { L 337 lib/lua/liolib.c lua_pushlstring(L, NULL, 0); L 341 lib/lua/liolib.c static int test_eof (lua_State *L, FILE *f) { L 342 lib/lua/liolib.c lua_pushlstring(L, NULL, 0); L 349 lib/lua/liolib.c static int read_line (lua_State *L, FILE *f) { L 351 lib/lua/liolib.c luaL_buffinit(L, &b); L 357 lib/lua/liolib.c return (lua_objlen(L, -1) > 0); /* check whether read something */ L 371 lib/lua/liolib.c static int read_chars (lua_State *L, FILE *f, size_t n) { L 375 lib/lua/liolib.c luaL_buffinit(L, &b); L 385 lib/lua/liolib.c return (n == 0 || lua_objlen(L, -1) > 0); L 389 lib/lua/liolib.c static int g_read (lua_State *L, FILE *f, int first) { L 390 lib/lua/liolib.c int nargs = lua_gettop(L) - 1; L 398 lib/lua/liolib.c success = read_line(L, f); L 402 lib/lua/liolib.c luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); L 405 lib/lua/liolib.c if (lua_type(L, n) == LUA_TNUMBER) { L 406 lib/lua/liolib.c size_t l = (size_t)lua_tointeger(L, n); L 407 lib/lua/liolib.c success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); L 410 lib/lua/liolib.c const char *p = lua_tostring(L, n); L 411 lib/lua/liolib.c luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); L 414 lib/lua/liolib.c success = read_number(L, f); L 417 lib/lua/liolib.c success = read_line(L, f); L 420 lib/lua/liolib.c read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ L 424 lib/lua/liolib.c return luaL_argerror(L, n, "invalid format"); L 432 lib/lua/liolib.c return pushresult(L, 0, NULL); L 435 lib/lua/liolib.c lua_pop(L, 1); /* remove last result */ L 436 lib/lua/liolib.c lua_pushnil(L); /* push nil instead */ L 442 lib/lua/liolib.c static int io_read (lua_State *L) { L 443 lib/lua/liolib.c return g_read(L, getiofile(L, IO_INPUT), 1); L 447 lib/lua/liolib.c static int f_read (lua_State *L) { L 448 lib/lua/liolib.c return g_read(L, tofile(L), 2); L 452 lib/lua/liolib.c static int io_readline (lua_State *L) { L 453 lib/lua/liolib.c FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); L 456 lib/lua/liolib.c luaL_error(L, "file is already closed"); L 457 lib/lua/liolib.c sucess = read_line(L, f); L 461 lib/lua/liolib.c return luaL_error(L, "%s", strerror(errno)); L 465 lib/lua/liolib.c if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ L 466 lib/lua/liolib.c lua_settop(L, 0); L 467 lib/lua/liolib.c lua_pushvalue(L, lua_upvalueindex(1)); L 468 lib/lua/liolib.c aux_close(L); /* close it */ L 477 lib/lua/liolib.c static int g_write (lua_State *L, FILE *f, int arg) { L 478 lib/lua/liolib.c int nargs = lua_gettop(L) - 1; L 481 lib/lua/liolib.c if (lua_type(L, arg) == LUA_TNUMBER) { L 483 lib/lua/liolib.c sprintf(s,LUA_NUMBER_FMT,lua_tonumber(L,arg)); L 487 lib/lua/liolib.c fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; L 494 lib/lua/liolib.c const char *s = luaL_checklstring(L, arg, &l); L 498 lib/lua/liolib.c return pushresult(L, status, NULL); L 502 lib/lua/liolib.c static int io_write (lua_State *L) { L 503 lib/lua/liolib.c return g_write(L, getiofile(L, IO_OUTPUT), 1); L 507 lib/lua/liolib.c static int f_write (lua_State *L) { L 508 lib/lua/liolib.c return g_write(L, tofile(L), 2); L 512 lib/lua/liolib.c static int f_seek (lua_State *L) { L 515 lib/lua/liolib.c FILE *f = tofile(L); L 516 lib/lua/liolib.c int op = luaL_checkoption(L, 2, "cur", modenames); L 517 lib/lua/liolib.c long offset = luaL_optlong(L, 3, 0); L 520 lib/lua/liolib.c return pushresult(L, 0, NULL); /* error */ L 522 lib/lua/liolib.c lua_pushinteger(L, ftell(f)); L 529 lib/lua/liolib.c static int f_setvbuf (lua_State *L) { L 532 lib/lua/liolib.c FILE *f = tofile(L); L 533 lib/lua/liolib.c int op = luaL_checkoption(L, 2, NULL, modenames); L 534 lib/lua/liolib.c lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); L 536 lib/lua/liolib.c return pushresult(L, res == 0, NULL); L 542 lib/lua/liolib.c static int io_flush (lua_State *L) { L 543 lib/lua/liolib.c return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); L 547 lib/lua/liolib.c static int f_flush (lua_State *L) { L 548 lib/lua/liolib.c return pushresult(L, fflush(tofile(L)) == 0, NULL); L 551 lib/lua/liolib.c static int f_getfptr(lua_State *L) { L 552 lib/lua/liolib.c FILE *f = tofile(L); L 553 lib/lua/liolib.c lua_pushinteger(L, (int)f); L 595 lib/lua/liolib.c static void createmeta (lua_State *L) { L 596 lib/lua/liolib.c luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ L 597 lib/lua/liolib.c lua_pushvalue(L, -1); /* push metatable */ L 598 lib/lua/liolib.c lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ L 599 lib/lua/liolib.c luaL_register(L, NULL, flib); /* file methods */ L 603 lib/lua/liolib.c static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { L 604 lib/lua/liolib.c *newfile(L) = f; L 606 lib/lua/liolib.c lua_pushvalue(L, -1); L 607 lib/lua/liolib.c lua_rawseti(L, LUA_ENVIRONINDEX, k); L 609 lib/lua/liolib.c lua_pushvalue(L, -2); /* copy environment */ L 610 lib/lua/liolib.c lua_setfenv(L, -2); /* set it */ L 611 lib/lua/liolib.c lua_setfield(L, -3, fname); L 615 lib/lua/liolib.c static void newfenv (lua_State *L, lua_CFunction cls) { L 616 lib/lua/liolib.c lua_createtable(L, 0, 1); L 617 lib/lua/liolib.c lua_pushcfunction(L, cls); L 618 lib/lua/liolib.c lua_setfield(L, -2, "__close"); L 622 lib/lua/liolib.c LUALIB_API int luaopen_io (lua_State *L) { L 623 lib/lua/liolib.c createmeta(L); L 625 lib/lua/liolib.c newfenv(L, io_fclose); L 626 lib/lua/liolib.c lua_replace(L, LUA_ENVIRONINDEX); L 628 lib/lua/liolib.c luaL_register(L, LUA_IOLIBNAME, iolib); L 630 lib/lua/liolib.c newfenv(L, io_noclose); /* close function for default files */ L 632 lib/lua/liolib.c createstdfile(L, stdin, IO_INPUT, "stdin"); L 633 lib/lua/liolib.c createstdfile(L, stdout, IO_OUTPUT, "stdout"); L 634 lib/lua/liolib.c createstdfile(L, stderr, 0, "stderr"); L 638 lib/lua/liolib.c createstdfile(L, NULL, IO_INPUT, "stdin"); L 639 lib/lua/liolib.c createstdfile(L, NULL, IO_OUTPUT, "stdout"); L 640 lib/lua/liolib.c createstdfile(L, NULL, 0, "stderr"); L 642 lib/lua/liolib.c lua_pop(L, 1); /* pop environment for default files */ L 645 lib/lua/liolib.c lua_getfield(L, -1, "popen"); L 646 lib/lua/liolib.c newfenv(L, io_pclose); /* create environment for 'popen' */ L 647 lib/lua/liolib.c lua_setfenv(L, -2); /* set fenv for 'popen' */ L 648 lib/lua/liolib.c lua_pop(L, 1); /* pop 'popen' */ L 58 lib/lua/llex.c luaZ_resizebuffer(ls->L, b, newsize); L 64 lib/lua/llex.c LUAI_FUNC void luaX_init (lua_State *L) { L 67 lib/lua/llex.c TString *ts = luaS_new(L, luaX_tokens[i]); L 81 lib/lua/llex.c return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : L 82 lib/lua/llex.c luaO_pushfstring(ls->L, "%c", token); L 105 lib/lua/llex.c msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); L 107 lib/lua/llex.c luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); L 108 lib/lua/llex.c luaD_throw(ls->L, LUA_ERRSYNTAX); L 118 lib/lua/llex.c lua_State *L = ls->L; L 119 lib/lua/llex.c TString *ts = luaS_newlstr(L, str, l); L 120 lib/lua/llex.c TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ L 123 lib/lua/llex.c luaC_checkGC(L); L 140 lib/lua/llex.c LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { L 142 lib/lua/llex.c ls->L = L; L 149 lib/lua/llex.c luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ L 62 lib/lua/llex.h struct lua_State *L; L 70 lib/lua/llex.h LUAI_FUNC void luaX_init (lua_State *L); L 71 lib/lua/llex.h LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, L 110 lib/lua/llimits.h #define lua_lock(L) ((void) 0) L 111 lib/lua/llimits.h #define lua_unlock(L) ((void) 0) L 115 lib/lua/llimits.h #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} L 26 lib/lua/lmathlib.c static int math_abs (lua_State *L) { L 28 lib/lua/lmathlib.c lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); L 30 lib/lua/lmathlib.c lua_pushnumber(L, abs(luaL_checknumber(L, 1))); L 36 lib/lua/lmathlib.c static int math_sin (lua_State *L) { L 37 lib/lua/lmathlib.c lua_pushnumber(L, sin(luaL_checknumber(L, 1))); L 41 lib/lua/lmathlib.c static int math_sinh (lua_State *L) { L 42 lib/lua/lmathlib.c lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); L 46 lib/lua/lmathlib.c static int math_cos (lua_State *L) { L 47 lib/lua/lmathlib.c lua_pushnumber(L, cos(luaL_checknumber(L, 1))); L 51 lib/lua/lmathlib.c static int math_cosh (lua_State *L) { L 52 lib/lua/lmathlib.c lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); L 56 lib/lua/lmathlib.c static int math_tan (lua_State *L) { L 57 lib/lua/lmathlib.c lua_pushnumber(L, tan(luaL_checknumber(L, 1))); L 61 lib/lua/lmathlib.c static int math_tanh (lua_State *L) { L 62 lib/lua/lmathlib.c lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); L 66 lib/lua/lmathlib.c static int math_asin (lua_State *L) { L 67 lib/lua/lmathlib.c lua_pushnumber(L, asin(luaL_checknumber(L, 1))); L 71 lib/lua/lmathlib.c static int math_acos (lua_State *L) { L 72 lib/lua/lmathlib.c lua_pushnumber(L, acos(luaL_checknumber(L, 1))); L 76 lib/lua/lmathlib.c static int math_atan (lua_State *L) { L 77 lib/lua/lmathlib.c lua_pushnumber(L, atan(luaL_checknumber(L, 1))); L 81 lib/lua/lmathlib.c static int math_atan2 (lua_State *L) { L 82 lib/lua/lmathlib.c lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); L 86 lib/lua/lmathlib.c static int math_ceil (lua_State *L) { L 87 lib/lua/lmathlib.c lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); L 91 lib/lua/lmathlib.c static int math_floor (lua_State *L) { L 92 lib/lua/lmathlib.c lua_pushnumber(L, floor(luaL_checknumber(L, 1))); L 96 lib/lua/lmathlib.c static int math_fmod (lua_State *L) { L 97 lib/lua/lmathlib.c lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); L 101 lib/lua/lmathlib.c static int math_modf (lua_State *L) { L 103 lib/lua/lmathlib.c double fp = modf(luaL_checknumber(L, 1), &ip); L 104 lib/lua/lmathlib.c lua_pushnumber(L, ip); L 105 lib/lua/lmathlib.c lua_pushnumber(L, fp); L 109 lib/lua/lmathlib.c static int math_sqrt (lua_State *L) { L 110 lib/lua/lmathlib.c lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); L 114 lib/lua/lmathlib.c static int math_pow (lua_State *L) { L 116 lib/lua/lmathlib.c lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); L 118 lib/lua/lmathlib.c lua_pushnumber(L, luai_ipow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); L 123 lib/lua/lmathlib.c static int math_log (lua_State *L) { L 124 lib/lua/lmathlib.c lua_pushnumber(L, log(luaL_checknumber(L, 1))); L 128 lib/lua/lmathlib.c static int math_log10 (lua_State *L) { L 129 lib/lua/lmathlib.c lua_pushnumber(L, log10(luaL_checknumber(L, 1))); L 133 lib/lua/lmathlib.c static int math_exp (lua_State *L) { L 134 lib/lua/lmathlib.c lua_pushnumber(L, exp(luaL_checknumber(L, 1))); L 138 lib/lua/lmathlib.c static int math_deg (lua_State *L) { L 139 lib/lua/lmathlib.c lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); L 143 lib/lua/lmathlib.c static int math_rad (lua_State *L) { L 144 lib/lua/lmathlib.c lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); L 148 lib/lua/lmathlib.c static int math_frexp (lua_State *L) { L 150 lib/lua/lmathlib.c lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); L 151 lib/lua/lmathlib.c lua_pushinteger(L, e); L 155 lib/lua/lmathlib.c static int math_ldexp (lua_State *L) { L 156 lib/lua/lmathlib.c lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); L 162 lib/lua/lmathlib.c static int math_min (lua_State *L) { L 163 lib/lua/lmathlib.c int n = lua_gettop(L); /* number of arguments */ L 164 lib/lua/lmathlib.c lua_Number dmin = luaL_checknumber(L, 1); L 167 lib/lua/lmathlib.c lua_Number d = luaL_checknumber(L, i); L 171 lib/lua/lmathlib.c lua_pushnumber(L, dmin); L 176 lib/lua/lmathlib.c static int math_max (lua_State *L) { L 177 lib/lua/lmathlib.c int n = lua_gettop(L); /* number of arguments */ L 178 lib/lua/lmathlib.c lua_Number dmax = luaL_checknumber(L, 1); L 181 lib/lua/lmathlib.c lua_Number d = luaL_checknumber(L, i); L 185 lib/lua/lmathlib.c lua_pushnumber(L, dmax); L 190 lib/lua/lmathlib.c static int math_random (lua_State *L) { L 196 lib/lua/lmathlib.c switch (lua_gettop(L)) { /* check number of arguments */ L 199 lib/lua/lmathlib.c lua_pushnumber(L, r); /* Number between 0 and 1 */ L 204 lib/lua/lmathlib.c int u = luaL_checkint(L, 1); L 205 lib/lua/lmathlib.c luaL_argcheck(L, 1<=u, 1, "interval is empty"); L 207 lib/lua/lmathlib.c lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ L 209 lib/lua/lmathlib.c lua_pushnumber(L, rand()%u+1); L 214 lib/lua/lmathlib.c int l = luaL_checkint(L, 1); L 215 lib/lua/lmathlib.c int u = luaL_checkint(L, 2); L 216 lib/lua/lmathlib.c luaL_argcheck(L, l<=u, 2, "interval is empty"); L 218 lib/lua/lmathlib.c lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ L 220 lib/lua/lmathlib.c lua_pushnumber(L, rand()%(u-l+1)+l); L 224 lib/lua/lmathlib.c default: return luaL_error(L, "wrong number of arguments"); L 230 lib/lua/lmathlib.c static int math_randomseed (lua_State *L) { L 231 lib/lua/lmathlib.c srand(luaL_checkint(L, 1)); L 272 lib/lua/lmathlib.c LUALIB_API int luaopen_math (lua_State *L) { L 273 lib/lua/lmathlib.c luaL_register(L, LUA_MATHLIBNAME, mathlib); L 275 lib/lua/lmathlib.c lua_pushnumber(L, PI); L 276 lib/lua/lmathlib.c lua_setfield(L, -2, "pi"); L 277 lib/lua/lmathlib.c lua_pushnumber(L, HUGE_VAL); L 278 lib/lua/lmathlib.c lua_setfield(L, -2, "huge"); L 281 lib/lua/lmathlib.c lua_getfield(L, -1, "fmod"); L 282 lib/lua/lmathlib.c lua_setfield(L, -2, "mod"); L 46 lib/lua/lmem.c LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, L 52 lib/lua/lmem.c luaG_runerror(L, errormsg); L 60 lib/lua/lmem.c newblock = luaM_reallocv(L, block, *size, newsize, size_elems); L 66 lib/lua/lmem.c LUAI_FUNC void *luaM_toobig (lua_State *L) { L 67 lib/lua/lmem.c luaG_runerror(L, "memory allocation error: block too big"); L 76 lib/lua/lmem.c LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { L 77 lib/lua/lmem.c global_State *g = G(L); L 81 lib/lua/lmem.c luaD_throw(L, LUA_ERRMEM); L 19 lib/lua/lmem.h #define luaM_reallocv(L,b,on,n,e) \ L 21 lib/lua/lmem.h luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ L 22 lib/lua/lmem.h luaM_toobig(L)) L 24 lib/lua/lmem.h #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) L 25 lib/lua/lmem.h #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) L 26 lib/lua/lmem.h #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) L 28 lib/lua/lmem.h #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) L 29 lib/lua/lmem.h #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) L 30 lib/lua/lmem.h #define luaM_newvector(L,n,t) \ L 31 lib/lua/lmem.h cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) L 33 lib/lua/lmem.h #define luaM_growvector(L,v,nelems,size,t,limit,e) \ L 35 lib/lua/lmem.h ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) L 37 lib/lua/lmem.h #define luaM_reallocvector(L, v,oldn,n,t) \ L 38 lib/lua/lmem.h ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) L 41 lib/lua/lmem.h LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, L 43 lib/lua/lmem.h LUAI_FUNC void *luaM_toobig (lua_State *L); L 44 lib/lua/lmem.h LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, L 42 lib/lua/loadlib.c #define setprogdir(L) ((void)0) L 47 lib/lua/loadlib.c static void *ll_load (lua_State *L, const char *path); L 48 lib/lua/loadlib.c static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); L 69 lib/lua/loadlib.c static void *ll_load (lua_State *L, const char *path) { L 71 lib/lua/loadlib.c if (lib == NULL) lua_pushstring(L, dlerror()); L 76 lib/lua/loadlib.c static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { L 78 lib/lua/loadlib.c if (f == NULL) lua_pushstring(L, dlerror()); L 98 lib/lua/loadlib.c static void setprogdir (lua_State *L) { L 104 lib/lua/loadlib.c luaL_error(L, "unable to get ModuleFileName"); L 107 lib/lua/loadlib.c luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); L 108 lib/lua/loadlib.c lua_remove(L, -2); /* remove original string */ L 113 lib/lua/loadlib.c static void pusherror (lua_State *L) { L 118 lib/lua/loadlib.c lua_pushstring(L, buffer); L 120 lib/lua/loadlib.c lua_pushfstring(L, "system error %d\n", error); L 128 lib/lua/loadlib.c static void *ll_load (lua_State *L, const char *path) { L 130 lib/lua/loadlib.c if (lib == NULL) pusherror(L); L 135 lib/lua/loadlib.c static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { L 137 lib/lua/loadlib.c if (f == NULL) pusherror(L); L 160 lib/lua/loadlib.c static void pusherror (lua_State *L) { L 166 lib/lua/loadlib.c lua_pushstring(L, err_str); L 192 lib/lua/loadlib.c static void *ll_load (lua_State *L, const char *path) { L 197 lib/lua/loadlib.c lua_pushliteral(L, "dyld not present"); L 205 lib/lua/loadlib.c if (mod == NULL) pusherror(L); L 208 lib/lua/loadlib.c lua_pushstring(L, errorfromcode(ret)); L 213 lib/lua/loadlib.c static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { L 216 lib/lua/loadlib.c lua_pushfstring(L, "symbol " LUA_QS " not found", sym); L 246 lib/lua/loadlib.c static void *ll_load (lua_State *L, const char *path) { L 248 lib/lua/loadlib.c lua_pushliteral(L, DLMSG); L 253 lib/lua/loadlib.c static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { L 255 lib/lua/loadlib.c lua_pushliteral(L, DLMSG); L 265 lib/lua/loadlib.c static void **ll_register (lua_State *L, const char *path) { L 267 lib/lua/loadlib.c lua_pushfstring(L, "%s%s", LIBPREFIX, path); L 268 lib/lua/loadlib.c lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ L 269 lib/lua/loadlib.c if (!lua_isnil(L, -1)) /* is there an entry? */ L 270 lib/lua/loadlib.c plib = (void **)lua_touserdata(L, -1); L 272 lib/lua/loadlib.c lua_pop(L, 1); L 273 lib/lua/loadlib.c plib = (void **)lua_newuserdata(L, sizeof(const void *)); L 275 lib/lua/loadlib.c luaL_getmetatable(L, "_LOADLIB"); L 276 lib/lua/loadlib.c lua_setmetatable(L, -2); L 277 lib/lua/loadlib.c lua_pushfstring(L, "%s%s", LIBPREFIX, path); L 278 lib/lua/loadlib.c lua_pushvalue(L, -2); L 279 lib/lua/loadlib.c lua_settable(L, LUA_REGISTRYINDEX); L 289 lib/lua/loadlib.c static int gctm (lua_State *L) { L 290 lib/lua/loadlib.c void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); L 297 lib/lua/loadlib.c static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { L 298 lib/lua/loadlib.c void **reg = ll_register(L, path); L 299 lib/lua/loadlib.c if (*reg == NULL) *reg = ll_load(L, path); L 303 lib/lua/loadlib.c lua_CFunction f = ll_sym(L, *reg, sym); L 306 lib/lua/loadlib.c lua_pushcfunction(L, f); L 312 lib/lua/loadlib.c static int ll_loadlib (lua_State *L) { L 313 lib/lua/loadlib.c const char *path = luaL_checkstring(L, 1); L 314 lib/lua/loadlib.c const char *init = luaL_checkstring(L, 2); L 315 lib/lua/loadlib.c int stat = ll_loadfunc(L, path, init); L 319 lib/lua/loadlib.c lua_pushnil(L); L 320 lib/lua/loadlib.c lua_insert(L, -2); L 321 lib/lua/loadlib.c lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); L 348 lib/lua/loadlib.c static const char *pushnexttemplate (lua_State *L, const char *path) { L 354 lib/lua/loadlib.c lua_pushlstring(L, path, l - path); /* template */ L 359 lib/lua/loadlib.c static const char *findfile (lua_State *L, const char *name, L 362 lib/lua/loadlib.c name = luaL_gsub(L, name, ".", LUA_DIRSEP); L 363 lib/lua/loadlib.c lua_getfield(L, LUA_ENVIRONINDEX, pname); L 364 lib/lua/loadlib.c path = lua_tostring(L, -1); L 366 lib/lua/loadlib.c luaL_error(L, LUA_QL("package.%s") " must be a string", pname); L 367 lib/lua/loadlib.c lua_pushliteral(L, ""); /* error accumulator */ L 368 lib/lua/loadlib.c while ((path = pushnexttemplate(L, path)) != NULL) { L 370 lib/lua/loadlib.c filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); L 371 lib/lua/loadlib.c lua_remove(L, -2); /* remove path template */ L 374 lib/lua/loadlib.c lua_pushfstring(L, "\n\tno file " LUA_QS, filename); L 375 lib/lua/loadlib.c lua_remove(L, -2); /* remove file name */ L 376 lib/lua/loadlib.c lua_concat(L, 2); /* add entry to possible error message */ L 381 lib/lua/loadlib.c static void loaderror (lua_State *L, const char *filename) { L 382 lib/lua/loadlib.c luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", L 383 lib/lua/loadlib.c lua_tostring(L, 1), filename, lua_tostring(L, -1)); L 387 lib/lua/loadlib.c static int loader_Lua (lua_State *L) { L 389 lib/lua/loadlib.c const char *name = luaL_checkstring(L, 1); L 390 lib/lua/loadlib.c filename = findfile(L, name, "path"); L 392 lib/lua/loadlib.c if (luaL_loadfile(L, filename) != 0) L 393 lib/lua/loadlib.c loaderror(L, filename); L 398 lib/lua/loadlib.c static const char *mkfuncname (lua_State *L, const char *modname) { L 402 lib/lua/loadlib.c funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); L 403 lib/lua/loadlib.c funcname = lua_pushfstring(L, POF"%s", funcname); L 404 lib/lua/loadlib.c lua_remove(L, -2); /* remove 'gsub' result */ L 409 lib/lua/loadlib.c static int loader_C (lua_State *L) { L 411 lib/lua/loadlib.c const char *name = luaL_checkstring(L, 1); L 412 lib/lua/loadlib.c const char *filename = findfile(L, name, "cpath"); L 414 lib/lua/loadlib.c funcname = mkfuncname(L, name); L 415 lib/lua/loadlib.c if (ll_loadfunc(L, filename, funcname) != 0) L 416 lib/lua/loadlib.c loaderror(L, filename); L 421 lib/lua/loadlib.c static int loader_Croot (lua_State *L) { L 424 lib/lua/loadlib.c const char *name = luaL_checkstring(L, 1); L 428 lib/lua/loadlib.c lua_pushlstring(L, name, p - name); L 429 lib/lua/loadlib.c filename = findfile(L, lua_tostring(L, -1), "cpath"); L 431 lib/lua/loadlib.c funcname = mkfuncname(L, name); L 432 lib/lua/loadlib.c if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { L 433 lib/lua/loadlib.c if (stat != ERRFUNC) loaderror(L, filename); /* real error */ L 434 lib/lua/loadlib.c lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, L 442 lib/lua/loadlib.c static int loader_preload (lua_State *L) { L 443 lib/lua/loadlib.c const char *name = luaL_checkstring(L, 1); L 444 lib/lua/loadlib.c lua_getfield(L, LUA_ENVIRONINDEX, "preload"); L 445 lib/lua/loadlib.c if (!lua_istable(L, -1)) L 446 lib/lua/loadlib.c luaL_error(L, LUA_QL("package.preload") " must be a table"); L 447 lib/lua/loadlib.c lua_getfield(L, -1, name); L 448 lib/lua/loadlib.c if (lua_isnil(L, -1)) /* not found? */ L 449 lib/lua/loadlib.c lua_pushfstring(L, "\n\tno field package.preload['%s']", name); L 458 lib/lua/loadlib.c static int ll_require (lua_State *L) { L 459 lib/lua/loadlib.c const char *name = luaL_checkstring(L, 1); L 461 lib/lua/loadlib.c lua_settop(L, 1); /* _LOADED table will be at index 2 */ L 462 lib/lua/loadlib.c lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); L 463 lib/lua/loadlib.c lua_getfield(L, 2, name); L 464 lib/lua/loadlib.c if (lua_toboolean(L, -1)) { /* is it there? */ L 465 lib/lua/loadlib.c if (lua_touserdata(L, -1) == sentinel) /* check loops */ L 466 lib/lua/loadlib.c luaL_error(L, "loop or previous error loading module " LUA_QS, name); L 470 lib/lua/loadlib.c lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); L 471 lib/lua/loadlib.c if (!lua_istable(L, -1)) L 472 lib/lua/loadlib.c luaL_error(L, LUA_QL("package.loaders") " must be a table"); L 473 lib/lua/loadlib.c lua_pushliteral(L, ""); /* error message accumulator */ L 475 lib/lua/loadlib.c lua_rawgeti(L, -2, i); /* get a loader */ L 476 lib/lua/loadlib.c if (lua_isnil(L, -1)) L 477 lib/lua/loadlib.c luaL_error(L, "module " LUA_QS " not found:%s", L 478 lib/lua/loadlib.c name, lua_tostring(L, -2)); L 479 lib/lua/loadlib.c lua_pushstring(L, name); L 480 lib/lua/loadlib.c lua_call(L, 1, 1); /* call it */ L 481 lib/lua/loadlib.c if (lua_isfunction(L, -1)) /* did it find module? */ L 483 lib/lua/loadlib.c else if (lua_isstring(L, -1)) /* loader returned error message? */ L 484 lib/lua/loadlib.c lua_concat(L, 2); /* accumulate it */ L 486 lib/lua/loadlib.c lua_pop(L, 1); L 488 lib/lua/loadlib.c lua_pushlightuserdata(L, sentinel); L 489 lib/lua/loadlib.c lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ L 490 lib/lua/loadlib.c lua_pushstring(L, name); /* pass name as argument to module */ L 491 lib/lua/loadlib.c lua_call(L, 1, 1); /* run loaded module */ L 492 lib/lua/loadlib.c if (!lua_isnil(L, -1)) /* non-nil return? */ L 493 lib/lua/loadlib.c lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ L 494 lib/lua/loadlib.c lua_getfield(L, 2, name); L 495 lib/lua/loadlib.c if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ L 496 lib/lua/loadlib.c lua_pushboolean(L, 1); /* use true as result */ L 497 lib/lua/loadlib.c lua_pushvalue(L, -1); /* extra copy to be returned */ L 498 lib/lua/loadlib.c lua_setfield(L, 2, name); /* _LOADED[name] = true */ L 514 lib/lua/loadlib.c static void setfenv (lua_State *L) { L 516 lib/lua/loadlib.c if (lua_getstack(L, 1, &ar) == 0 || L 517 lib/lua/loadlib.c lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ L 518 lib/lua/loadlib.c lua_iscfunction(L, -1)) L 519 lib/lua/loadlib.c luaL_error(L, LUA_QL("module") " not called from a Lua function"); L 520 lib/lua/loadlib.c lua_pushvalue(L, -2); L 521 lib/lua/loadlib.c lua_setfenv(L, -2); L 522 lib/lua/loadlib.c lua_pop(L, 1); L 526 lib/lua/loadlib.c static void dooptions (lua_State *L, int n) { L 529 lib/lua/loadlib.c lua_pushvalue(L, i); /* get option (a function) */ L 530 lib/lua/loadlib.c lua_pushvalue(L, -2); /* module */ L 531 lib/lua/loadlib.c lua_call(L, 1, 0); L 536 lib/lua/loadlib.c static void modinit (lua_State *L, const char *modname) { L 538 lib/lua/loadlib.c lua_pushvalue(L, -1); L 539 lib/lua/loadlib.c lua_setfield(L, -2, "_M"); /* module._M = module */ L 540 lib/lua/loadlib.c lua_pushstring(L, modname); L 541 lib/lua/loadlib.c lua_setfield(L, -2, "_NAME"); L 546 lib/lua/loadlib.c lua_pushlstring(L, modname, dot - modname); L 547 lib/lua/loadlib.c lua_setfield(L, -2, "_PACKAGE"); L 551 lib/lua/loadlib.c static int ll_module (lua_State *L) { L 552 lib/lua/loadlib.c const char *modname = luaL_checkstring(L, 1); L 553 lib/lua/loadlib.c int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ L 554 lib/lua/loadlib.c lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); L 555 lib/lua/loadlib.c lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ L 556 lib/lua/loadlib.c if (!lua_istable(L, -1)) { /* not found? */ L 557 lib/lua/loadlib.c lua_pop(L, 1); /* remove previous result */ L 559 lib/lua/loadlib.c if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) L 560 lib/lua/loadlib.c return luaL_error(L, "name conflict for module " LUA_QS, modname); L 561 lib/lua/loadlib.c lua_pushvalue(L, -1); L 562 lib/lua/loadlib.c lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ L 565 lib/lua/loadlib.c lua_getfield(L, -1, "_NAME"); L 566 lib/lua/loadlib.c if (!lua_isnil(L, -1)) /* is table an initialized module? */ L 567 lib/lua/loadlib.c lua_pop(L, 1); L 569 lib/lua/loadlib.c lua_pop(L, 1); L 570 lib/lua/loadlib.c modinit(L, modname); L 572 lib/lua/loadlib.c lua_pushvalue(L, -1); L 573 lib/lua/loadlib.c setfenv(L); L 574 lib/lua/loadlib.c dooptions(L, loaded - 1); L 579 lib/lua/loadlib.c static int ll_seeall (lua_State *L) { L 580 lib/lua/loadlib.c luaL_checktype(L, 1, LUA_TTABLE); L 581 lib/lua/loadlib.c if (!lua_getmetatable(L, 1)) { L 582 lib/lua/loadlib.c lua_createtable(L, 0, 1); /* create new metatable */ L 583 lib/lua/loadlib.c lua_pushvalue(L, -1); L 584 lib/lua/loadlib.c lua_setmetatable(L, 1); L 586 lib/lua/loadlib.c lua_pushvalue(L, LUA_GLOBALSINDEX); L 587 lib/lua/loadlib.c lua_setfield(L, -2, "__index"); /* mt.__index = _G */ L 598 lib/lua/loadlib.c static void setpath (lua_State *L, const char *fieldname, __attribute__ ((unused))const char *envname, L 602 lib/lua/loadlib.c lua_pushstring(L, def); /* use default */ L 606 lib/lua/loadlib.c lua_pushstring(L, def); /* use default */ L 609 lib/lua/loadlib.c path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, L 611 lib/lua/loadlib.c luaL_gsub(L, path, AUXMARK, def); L 612 lib/lua/loadlib.c lua_remove(L, -2); L 615 lib/lua/loadlib.c setprogdir(L); L 616 lib/lua/loadlib.c lua_setfield(L, -2, fieldname); L 637 lib/lua/loadlib.c LUALIB_API int luaopen_package (lua_State *L) { L 641 lib/lua/loadlib.c luaL_newmetatable(L, "_LOADLIB"); L 642 lib/lua/loadlib.c lua_pushcfunction(L, gctm); L 643 lib/lua/loadlib.c lua_setfield(L, -2, "__gc"); L 646 lib/lua/loadlib.c luaL_register(L, LUA_LOADLIBNAME, pk_funcs); L 649 lib/lua/loadlib.c lua_getfield(L, -1, "loadlib"); L 650 lib/lua/loadlib.c lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); L 653 lib/lua/loadlib.c lua_pushvalue(L, -1); L 654 lib/lua/loadlib.c lua_replace(L, LUA_ENVIRONINDEX); L 656 lib/lua/loadlib.c lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0); L 659 lib/lua/loadlib.c lua_pushcfunction(L, loaders[i]); L 660 lib/lua/loadlib.c lua_rawseti(L, -2, i+1); L 662 lib/lua/loadlib.c lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ L 663 lib/lua/loadlib.c setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ L 664 lib/lua/loadlib.c setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ L 666 lib/lua/loadlib.c lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" L 668 lib/lua/loadlib.c lua_setfield(L, -2, "config"); L 670 lib/lua/loadlib.c luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); L 671 lib/lua/loadlib.c lua_setfield(L, -2, "loaded"); L 673 lib/lua/loadlib.c lua_newtable(L); L 674 lib/lua/loadlib.c lua_setfield(L, -2, "preload"); L 675 lib/lua/loadlib.c lua_pushvalue(L, LUA_GLOBALSINDEX); L 676 lib/lua/loadlib.c luaL_register(L, NULL, ll_funcs); /* open lib into global table */ L 677 lib/lua/loadlib.c lua_pop(L, 1); L 104 lib/lua/lobject.c static void pushstr (lua_State *L, const char *str) { L 105 lib/lua/lobject.c setsvalue2s(L, L->top, luaS_new(L, str)); L 106 lib/lua/lobject.c incr_top(L); L 111 lib/lua/lobject.c LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { L 113 lib/lua/lobject.c pushstr(L, ""); L 117 lib/lua/lobject.c setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); L 118 lib/lua/lobject.c incr_top(L); L 123 lib/lua/lobject.c pushstr(L, s); L 130 lib/lua/lobject.c pushstr(L, buff); L 134 lib/lua/lobject.c setnvalue(L->top, cast_num(va_arg(argp, int))); L 135 lib/lua/lobject.c incr_top(L); L 139 lib/lua/lobject.c setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); L 140 lib/lua/lobject.c incr_top(L); L 146 lib/lua/lobject.c pushstr(L, buff); L 150 lib/lua/lobject.c pushstr(L, "%"); L 158 lib/lua/lobject.c pushstr(L, buff); L 165 lib/lua/lobject.c pushstr(L, fmt); L 166 lib/lua/lobject.c luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); L 167 lib/lua/lobject.c L->top -= n; L 168 lib/lua/lobject.c return svalue(L->top - 1); L 172 lib/lua/lobject.c LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { L 176 lib/lua/lobject.c msg = luaO_pushvfstring(L, fmt, argp); L 128 lib/lua/lobject.h #define setsvalue(L,obj,x) \ L 131 lib/lua/lobject.h checkliveness(G(L),i_o); } L 133 lib/lua/lobject.h #define setuvalue(L,obj,x) \ L 136 lib/lua/lobject.h checkliveness(G(L),i_o); } L 138 lib/lua/lobject.h #define setthvalue(L,obj,x) \ L 141 lib/lua/lobject.h checkliveness(G(L),i_o); } L 143 lib/lua/lobject.h #define setclvalue(L,obj,x) \ L 146 lib/lua/lobject.h checkliveness(G(L),i_o); } L 148 lib/lua/lobject.h #define sethvalue(L,obj,x) \ L 151 lib/lua/lobject.h checkliveness(G(L),i_o); } L 153 lib/lua/lobject.h #define setptvalue(L,obj,x) \ L 156 lib/lua/lobject.h checkliveness(G(L),i_o); } L 161 lib/lua/lobject.h #define setobj(L,obj1,obj2) \ L 164 lib/lua/lobject.h checkliveness(G(L),o1); } L 374 lib/lua/lobject.h LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, L 376 lib/lua/lobject.h LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); L 27 lib/lua/loslib.c static int os_pushresult (lua_State *L, int i, const char *filename) { L 30 lib/lua/loslib.c lua_pushboolean(L, 1); L 34 lib/lua/loslib.c lua_pushnil(L); L 35 lib/lua/loslib.c lua_pushfstring(L, "%s: %s", filename, strerror(en)); L 36 lib/lua/loslib.c lua_pushinteger(L, en); L 43 lib/lua/loslib.c static int os_execute (lua_State *L) { L 44 lib/lua/loslib.c lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); L 50 lib/lua/loslib.c static int os_remove (lua_State *L) { L 51 lib/lua/loslib.c const char *filename = luaL_checkstring(L, 1); L 52 lib/lua/loslib.c return os_pushresult(L, remove(filename) == 0, filename); L 56 lib/lua/loslib.c static int os_rename (lua_State *L) { L 57 lib/lua/loslib.c const char *fromname = luaL_checkstring(L, 1); L 58 lib/lua/loslib.c const char *toname = luaL_checkstring(L, 2); L 59 lib/lua/loslib.c return os_pushresult(L, rename(fromname, toname) == 0, fromname); L 65 lib/lua/loslib.c static int os_tmpname (lua_State *L) { L 70 lib/lua/loslib.c return luaL_error(L, "unable to generate a unique filename"); L 71 lib/lua/loslib.c lua_pushstring(L, buff); L 77 lib/lua/loslib.c static int os_getenv (lua_State *L) { L 78 lib/lua/loslib.c lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ L 84 lib/lua/loslib.c static int os_clock (lua_State *L) { L 85 lib/lua/loslib.c lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); L 99 lib/lua/loslib.c static void setfield (lua_State *L, const char *key, int value) { L 100 lib/lua/loslib.c lua_pushinteger(L, value); L 101 lib/lua/loslib.c lua_setfield(L, -2, key); L 104 lib/lua/loslib.c static void setboolfield (lua_State *L, const char *key, int value) { L 107 lib/lua/loslib.c lua_pushboolean(L, value); L 108 lib/lua/loslib.c lua_setfield(L, -2, key); L 111 lib/lua/loslib.c static int getboolfield (lua_State *L, const char *key) { L 113 lib/lua/loslib.c lua_getfield(L, -1, key); L 114 lib/lua/loslib.c res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); L 115 lib/lua/loslib.c lua_pop(L, 1); L 120 lib/lua/loslib.c static int getfield (lua_State *L, const char *key, int d) { L 122 lib/lua/loslib.c lua_getfield(L, -1, key); L 123 lib/lua/loslib.c if (lua_isnumber(L, -1)) L 124 lib/lua/loslib.c res = (int)lua_tointeger(L, -1); L 127 lib/lua/loslib.c return luaL_error(L, "field " LUA_QS " missing in date table", key); L 130 lib/lua/loslib.c lua_pop(L, 1); L 135 lib/lua/loslib.c static int os_date (lua_State *L) { L 136 lib/lua/loslib.c const char *s = luaL_optstring(L, 1, "%c"); L 137 lib/lua/loslib.c time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); L 152 lib/lua/loslib.c lua_pushnil(L); L 154 lib/lua/loslib.c lua_createtable(L, 0, 9); /* 9 = number of fields */ L 155 lib/lua/loslib.c setfield(L, "sec", stm->tm_sec); L 156 lib/lua/loslib.c setfield(L, "min", stm->tm_min); L 157 lib/lua/loslib.c setfield(L, "hour", stm->tm_hour); L 158 lib/lua/loslib.c setfield(L, "day", stm->tm_mday); L 159 lib/lua/loslib.c setfield(L, "month", stm->tm_mon+1); L 160 lib/lua/loslib.c setfield(L, "year", stm->tm_year+1900); L 161 lib/lua/loslib.c setfield(L, "wday", stm->tm_wday+1); L 162 lib/lua/loslib.c setfield(L, "yday", stm->tm_yday+1); L 163 lib/lua/loslib.c setboolfield(L, "isdst", stm->tm_isdst); L 169 lib/lua/loslib.c luaL_buffinit(L, &b); L 187 lib/lua/loslib.c static int os_time (lua_State *L) { L 189 lib/lua/loslib.c if (lua_isnoneornil(L, 1)) /* called without args? */ L 193 lib/lua/loslib.c luaL_checktype(L, 1, LUA_TTABLE); L 194 lib/lua/loslib.c lua_settop(L, 1); /* make sure table is at the top */ L 195 lib/lua/loslib.c ts.tm_sec = getfield(L, "sec", 0); L 196 lib/lua/loslib.c ts.tm_min = getfield(L, "min", 0); L 197 lib/lua/loslib.c ts.tm_hour = getfield(L, "hour", 12); L 198 lib/lua/loslib.c ts.tm_mday = getfield(L, "day", -1); L 199 lib/lua/loslib.c ts.tm_mon = getfield(L, "month", -1) - 1; L 200 lib/lua/loslib.c ts.tm_year = getfield(L, "year", -1) - 1900; L 201 lib/lua/loslib.c ts.tm_isdst = getboolfield(L, "isdst"); L 205 lib/lua/loslib.c lua_pushnil(L); L 207 lib/lua/loslib.c lua_pushnumber(L, (lua_Number)t); L 213 lib/lua/loslib.c static int os_difftime (lua_State *L) { L 214 lib/lua/loslib.c lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), L 215 lib/lua/loslib.c (time_t)(luaL_optnumber(L, 2, 0)))); L 219 lib/lua/loslib.c static int os_difftime (lua_State *L) { L 220 lib/lua/loslib.c lua_pushnumber(L, (time_t)(luaL_checknumber(L, 1) - (time_t)(luaL_optnumber(L, 2, 0)))); L 228 lib/lua/loslib.c static int os_setlocale (lua_State *L) { L 233 lib/lua/loslib.c const char *l = luaL_optstring(L, 1, NULL); L 234 lib/lua/loslib.c int op = luaL_checkoption(L, 2, "all", catnames); L 235 lib/lua/loslib.c lua_pushstring(L, setlocale(cat[op], l)); L 241 lib/lua/loslib.c static int os_exit (lua_State *L) { L 242 lib/lua/loslib.c exit(luaL_optint(L, 1, EXIT_SUCCESS)); L 247 lib/lua/loslib.c static int os_mkdir (lua_State *L) { L 248 lib/lua/loslib.c const char *dirname = luaL_checkstring(L, 1); L 250 lib/lua/loslib.c return os_pushresult(L, mkdir(dirname,0777) == 0, dirname); L 252 lib/lua/loslib.c return os_pushresult(L, mkdir(dirname) == 0, dirname); L 257 lib/lua/loslib.c static int get_table_optbool(lua_State *L, int narg, const char *fname, int d) L 260 lib/lua/loslib.c lua_getfield(L, narg, fname); L 262 lib/lua/loslib.c if(lua_isnil(L,-1)) { L 265 lib/lua/loslib.c r=lua_toboolean(L,-1); L 267 lib/lua/loslib.c lua_pop(L,1); L 278 lib/lua/loslib.c static int os_listdir (lua_State *L) { L 281 lib/lua/loslib.c (void)L; L 286 lib/lua/loslib.c const char *dirname = luaL_checkstring(L, 1); L 288 lib/lua/loslib.c if(lua_istable(L,2)) { L 289 lib/lua/loslib.c all=get_table_optbool(L,2,"showall",0); L 290 lib/lua/loslib.c od_flags=(get_table_optbool(L,2,"chdklfn",1))?OPENDIR_FL_CHDK_LFN:OPENDIR_FL_NONE; L 292 lib/lua/loslib.c all=lua_toboolean(L, 2); L 297 lib/lua/loslib.c return os_pushresult(L, 0 , dirname); L 298 lib/lua/loslib.c lua_newtable(L); L 302 lib/lua/loslib.c lua_pushinteger(L, i); L 303 lib/lua/loslib.c lua_pushstring(L, de->d_name); L 304 lib/lua/loslib.c lua_settable(L,-3); L 319 lib/lua/loslib.c static int idir_iter(lua_State *L) { L 321 lib/lua/loslib.c idir_udata_t *ud = (idir_udata_t *)luaL_checkudata(L,1,IDIR_META); L 328 lib/lua/loslib.c if(lua_type(L, 2) == LUA_TBOOLEAN && lua_toboolean(L,2) == 0) { L 341 lib/lua/loslib.c lua_pushstring(L, de->d_name); L 350 lib/lua/loslib.c static int idir_gc(lua_State *L) { L 351 lib/lua/loslib.c idir_udata_t *ud = (idir_udata_t *)luaL_checkudata(L,1,IDIR_META); L 387 lib/lua/loslib.c static int os_idir (lua_State *L) { L 390 lib/lua/loslib.c (void)L; L 393 lib/lua/loslib.c const char *dirname = luaL_checkstring(L, 1); L 395 lib/lua/loslib.c if(lua_istable(L,2)) { L 396 lib/lua/loslib.c all=get_table_optbool(L,2,"showall",0); L 397 lib/lua/loslib.c od_flags=(get_table_optbool(L,2,"chdklfn",1))?OPENDIR_FL_CHDK_LFN:OPENDIR_FL_NONE; L 399 lib/lua/loslib.c all=lua_toboolean(L, 2); L 402 lib/lua/loslib.c lua_pushcfunction(L, idir_iter); L 404 lib/lua/loslib.c idir_udata_t *ud = lua_newuserdata(L,sizeof(idir_udata_t)); L 409 lib/lua/loslib.c luaL_getmetatable(L, IDIR_META); L 410 lib/lua/loslib.c lua_setmetatable(L, -2); L 419 lib/lua/loslib.c static void idir_register(lua_State *L) { L 420 lib/lua/loslib.c luaL_newmetatable(L,IDIR_META); L 421 lib/lua/loslib.c luaL_register(L, NULL, idir_meta_methods); L 426 lib/lua/loslib.c static int os_stat (lua_State *L) { L 428 lib/lua/loslib.c const char *name = luaL_checkstring(L, 1); L 431 lib/lua/loslib.c lua_createtable(L, 0, 6); /* = number of fields */ L 446 lib/lua/loslib.c setfield(L,"size",st.st_size); /* size of file, in bytes */ L 450 lib/lua/loslib.c setfield(L,"mtime",st.st_mtime); /* time of last modification */ L 451 lib/lua/loslib.c setfield(L,"ctime",st.st_ctime); /* time of last change of file status */ L 457 lib/lua/loslib.c setfield(L,"blksize",512); L 458 lib/lua/loslib.c setfield(L,"blocks",(st.st_size/512) + (st.st_size%512)?1:0); L 461 lib/lua/loslib.c setfield(L,"attrib",DOS_ATTR_DIRECTORY); L 462 lib/lua/loslib.c setboolfield(L,"is_dir",1); L 463 lib/lua/loslib.c setboolfield(L,"is_file",0); L 466 lib/lua/loslib.c setboolfield(L,"is_dir",0); L 467 lib/lua/loslib.c setfield(L,"attrib",0); L 469 lib/lua/loslib.c setboolfield(L,"is_file",1); L 477 lib/lua/loslib.c setfield(L,"attrib",st.st_attrib); /* file attribute byte (dosFs only) */ L 480 lib/lua/loslib.c setboolfield(L,"is_dir",st.st_attrib & DOS_ATTR_DIRECTORY); L 481 lib/lua/loslib.c setboolfield(L,"is_file",!(st.st_attrib & (DOS_ATTR_DIRECTORY | DOS_ATTR_VOL_LABEL))); L 484 lib/lua/loslib.c setfield(L,"reserved1",st.reserved1); L 485 lib/lua/loslib.c setfield(L,"reserved2",st.reserved2); L 486 lib/lua/loslib.c setfield(L,"reserved3",st.reserved3); L 487 lib/lua/loslib.c setfield(L,"reserved4",st.reserved4); L 488 lib/lua/loslib.c setfield(L,"reserved5",st.reserved5); L 489 lib/lua/loslib.c setfield(L,"reserved6",st.reserved6); L 495 lib/lua/loslib.c lua_pushnil(L); L 496 lib/lua/loslib.c lua_pushfstring(L, "%s: %s", name, strerror(en)); L 497 lib/lua/loslib.c lua_pushinteger(L, en); L 505 lib/lua/loslib.c static int os_utime (lua_State *L) { L 506 lib/lua/loslib.c const char *name = luaL_checkstring(L, 1); L 508 lib/lua/loslib.c t.modtime = luaL_optnumber(L, 2, time(NULL)); L 509 lib/lua/loslib.c t.actime = luaL_optnumber(L, 3, time(NULL)); L 510 lib/lua/loslib.c return os_pushresult(L, utime(name,&t) == 0, name); L 545 lib/lua/loslib.c LUALIB_API int luaopen_os (lua_State *L) { L 546 lib/lua/loslib.c idir_register(L); L 547 lib/lua/loslib.c luaL_register(L, LUA_OSLIBNAME, syslib); L 67 lib/lua/lparser.c luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); L 73 lib/lua/lparser.c luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : L 74 lib/lua/lparser.c luaO_pushfstring(fs->L, "function at line %d has more than %d %s", L 109 lib/lua/lparser.c luaX_syntaxerror(ls, luaO_pushfstring(ls->L, L 147 lib/lua/lparser.c luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, L 151 lib/lua/lparser.c luaC_objbarrier(ls->L, f, varname); L 195 lib/lua/lparser.c luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, L 199 lib/lua/lparser.c luaC_objbarrier(fs->L, f, name); L 277 lib/lua/lparser.c if (++ls->L->nCcalls > LUAI_MAXCCALLS) L 282 lib/lua/lparser.c #define leavelevel(ls) ((ls)->L->nCcalls--) L 315 lib/lua/lparser.c luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, L 319 lib/lua/lparser.c luaC_objbarrier(ls->L, f, func->f); L 329 lib/lua/lparser.c lua_State *L = ls->L; L 330 lib/lua/lparser.c Proto *f = luaF_newproto(L); L 334 lib/lua/lparser.c fs->L = L; L 347 lib/lua/lparser.c fs->h = luaH_new(L, 0, 0); L 349 lib/lua/lparser.c sethvalue2s(L, L->top, fs->h); L 350 lib/lua/lparser.c incr_top(L); L 351 lib/lua/lparser.c setptvalue2s(L, L->top, f); L 352 lib/lua/lparser.c incr_top(L); L 357 lib/lua/lparser.c lua_State *L = ls->L; L 362 lib/lua/lparser.c luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); L 364 lib/lua/lparser.c luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); L 366 lib/lua/lparser.c luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); L 368 lib/lua/lparser.c luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); L 370 lib/lua/lparser.c luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); L 372 lib/lua/lparser.c luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); L 379 lib/lua/lparser.c L->top -= 2; /* remove table and prototype from the stack */ L 383 lib/lua/lparser.c LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { L 387 lib/lua/lparser.c luaX_setinput(L, &lexstate, z, luaS_new(L, name)); L 941 lib/lua/lparser.c luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, L 63 lib/lua/lparser.h struct lua_State *L; /* copy of the Lua state */ L 78 lib/lua/lparser.h LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, L 42 lib/lua/lstate.c static void stack_init (lua_State *L1, lua_State *L) { L 44 lib/lua/lstate.c L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); L 49 lib/lua/lstate.c L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); L 61 lib/lua/lstate.c static void freestack (lua_State *L, lua_State *L1) { L 62 lib/lua/lstate.c luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); L 63 lib/lua/lstate.c luaM_freearray(L, L1->stack, L1->stacksize, TValue); L 70 lib/lua/lstate.c static void f_luaopen (lua_State *L, void *ud) { L 71 lib/lua/lstate.c global_State *g = G(L); L 73 lib/lua/lstate.c stack_init(L, L); /* init stack */ L 74 lib/lua/lstate.c sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ L 75 lib/lua/lstate.c sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ L 76 lib/lua/lstate.c luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ L 77 lib/lua/lstate.c luaT_init(L); L 78 lib/lua/lstate.c luaX_init(L); L 79 lib/lua/lstate.c luaS_fix(luaS_newliteral(L, MEMERRMSG)); L 84 lib/lua/lstate.c static void preinit_state (lua_State *L, global_State *g) { L 85 lib/lua/lstate.c G(L) = g; L 86 lib/lua/lstate.c L->stack = NULL; L 87 lib/lua/lstate.c L->stacksize = 0; L 88 lib/lua/lstate.c L->errorJmp = NULL; L 89 lib/lua/lstate.c L->hook = NULL; L 90 lib/lua/lstate.c L->hookmask = 0; L 91 lib/lua/lstate.c L->basehookcount = 0; L 92 lib/lua/lstate.c L->allowhook = 1; L 93 lib/lua/lstate.c resethookcount(L); L 94 lib/lua/lstate.c L->openupval = NULL; L 95 lib/lua/lstate.c L->size_ci = 0; L 96 lib/lua/lstate.c L->nCcalls = L->baseCcalls = 0; L 97 lib/lua/lstate.c L->status = 0; L 98 lib/lua/lstate.c L->base_ci = L->ci = NULL; L 99 lib/lua/lstate.c L->savedpc = NULL; L 100 lib/lua/lstate.c L->errfunc = 0; L 101 lib/lua/lstate.c setnilvalue(gt(L)); L 105 lib/lua/lstate.c static void close_state (lua_State *L) { L 106 lib/lua/lstate.c global_State *g = G(L); L 107 lib/lua/lstate.c luaF_close(L, L->stack); /* close all upvalues for this thread */ L 108 lib/lua/lstate.c luaC_freeall(L); /* collect all objects */ L 109 lib/lua/lstate.c lua_assert(g->rootgc == obj2gco(L)); L 111 lib/lua/lstate.c luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); L 112 lib/lua/lstate.c luaZ_freebuffer(L, &g->buff); L 113 lib/lua/lstate.c freestack(L, L); L 115 lib/lua/lstate.c (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); L 119 lib/lua/lstate.c LUAI_FUNC lua_State *luaE_newthread (lua_State *L) { L 120 lib/lua/lstate.c lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); L 121 lib/lua/lstate.c luaC_link(L, obj2gco(L1), LUA_TTHREAD); L 122 lib/lua/lstate.c preinit_state(L1, G(L)); L 123 lib/lua/lstate.c stack_init(L1, L); /* init stack */ L 124 lib/lua/lstate.c setobj2n(L, gt(L1), gt(L)); /* share table of globals */ L 125 lib/lua/lstate.c L1->hookmask = L->hookmask; L 126 lib/lua/lstate.c L1->basehookcount = L->basehookcount; L 127 lib/lua/lstate.c L1->hook = L->hook; L 134 lib/lua/lstate.c LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1) { L 138 lib/lua/lstate.c freestack(L, L1); L 139 lib/lua/lstate.c luaM_freemem(L, fromstate(L1), state_size(lua_State)); L 145 lib/lua/lstate.c lua_State *L; L 149 lib/lua/lstate.c L = tostate(l); L 150 lib/lua/lstate.c g = &((LG *)L)->g; L 151 lib/lua/lstate.c L->next = NULL; L 152 lib/lua/lstate.c L->tt = LUA_TTHREAD; L 154 lib/lua/lstate.c L->marked = luaC_white(g); L 155 lib/lua/lstate.c set2bits(L->marked, FIXEDBIT, SFIXEDBIT); L 156 lib/lua/lstate.c preinit_state(L, g); L 159 lib/lua/lstate.c g->mainthread = L; L 166 lib/lua/lstate.c setnilvalue(registry(L)); L 167 lib/lua/lstate.c luaZ_initbuffer(L, &g->buff); L 170 lib/lua/lstate.c g->rootgc = obj2gco(L); L 182 lib/lua/lstate.c if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { L 184 lib/lua/lstate.c close_state(L); L 185 lib/lua/lstate.c L = NULL; L 188 lib/lua/lstate.c luai_userstateopen(L); L 189 lib/lua/lstate.c return L; L 193 lib/lua/lstate.c static void callallgcTM (lua_State *L, void *ud) { L 195 lib/lua/lstate.c luaC_callGCTM(L); /* call GC metamethods for all udata */ L 199 lib/lua/lstate.c LUA_API void lua_close (lua_State *L) { L 200 lib/lua/lstate.c L = G(L)->mainthread; /* only the main thread can be closed */ L 201 lib/lua/lstate.c lua_lock(L); L 202 lib/lua/lstate.c luaF_close(L, L->stack); /* close all upvalues for this thread */ L 203 lib/lua/lstate.c luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ L 204 lib/lua/lstate.c L->errfunc = 0; /* no error function during GC metamethods */ L 206 lib/lua/lstate.c L->ci = L->base_ci; L 207 lib/lua/lstate.c L->base = L->top = L->ci->base; L 208 lib/lua/lstate.c L->nCcalls = L->baseCcalls = 0; L 209 lib/lua/lstate.c } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); L 210 lib/lua/lstate.c lua_assert(G(L)->tmudata == NULL); L 211 lib/lua/lstate.c luai_userstateclose(L); L 212 lib/lua/lstate.c close_state(L); L 22 lib/lua/lstate.h #define gt(L) (&L->l_gt) L 25 lib/lua/lstate.h #define registry(L) (&G(L)->l_registry) L 59 lib/lua/lstate.h #define curr_func(L) (clvalue(L->ci->func)) L 130 lib/lua/lstate.h #define G(L) (L->l_G) L 165 lib/lua/lstate.h LUAI_FUNC lua_State *luaE_newthread (lua_State *L); L 166 lib/lua/lstate.h LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); L 22 lib/lua/lstring.c LUAI_FUNC void luaS_resize (lua_State *L, int newsize) { L 26 lib/lua/lstring.c if (G(L)->gcstate == GCSsweepstring) L 28 lib/lua/lstring.c newhash = luaM_newvector(L, newsize, GCObject *); L 29 lib/lua/lstring.c tb = &G(L)->strt; L 44 lib/lua/lstring.c luaM_freearray(L, tb->hash, tb->size, TString *); L 50 lib/lua/lstring.c static TString *newlstr (lua_State *L, const char *str, size_t l, L 55 lib/lua/lstring.c luaM_toobig(L); L 56 lib/lua/lstring.c ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); L 59 lib/lua/lstring.c ts->tsv.marked = luaC_white(G(L)); L 64 lib/lua/lstring.c tb = &G(L)->strt; L 70 lib/lua/lstring.c luaS_resize(L, tb->size*2); /* too crowded */ L 75 lib/lua/lstring.c LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { L 82 lib/lua/lstring.c for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; L 88 lib/lua/lstring.c if (isdead(G(L), o)) changewhite(o); L 92 lib/lua/lstring.c return newlstr(L, str, l, h); /* not found */ L 96 lib/lua/lstring.c LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { L 99 lib/lua/lstring.c luaM_toobig(L); L 100 lib/lua/lstring.c u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); L 101 lib/lua/lstring.c u->uv.marked = luaC_white(G(L)); /* is not finalized */ L 107 lib/lua/lstring.c u->uv.next = G(L)->mainthread->next; L 108 lib/lua/lstring.c G(L)->mainthread->next = obj2gco(u); L 20 lib/lua/lstring.h #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) L 21 lib/lua/lstring.h #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ L 26 lib/lua/lstring.h LUAI_FUNC void luaS_resize (lua_State *L, int newsize); L 27 lib/lua/lstring.h LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); L 28 lib/lua/lstring.h LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); L 28 lib/lua/lstrlib.c static int str_len (lua_State *L) { L 30 lib/lua/lstrlib.c luaL_checklstring(L, 1, &l); L 31 lib/lua/lstrlib.c lua_pushinteger(L, l); L 43 lib/lua/lstrlib.c static int str_sub (lua_State *L) { L 45 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 46 lib/lua/lstrlib.c ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); L 47 lib/lua/lstrlib.c ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); L 51 lib/lua/lstrlib.c lua_pushlstring(L, s+start-1, end-start+1); L 52 lib/lua/lstrlib.c else lua_pushliteral(L, ""); L 57 lib/lua/lstrlib.c static int str_reverse (lua_State *L) { L 60 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 61 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 68 lib/lua/lstrlib.c static int str_lower (lua_State *L) { L 72 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 73 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 81 lib/lua/lstrlib.c static int str_upper (lua_State *L) { L 85 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 86 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 93 lib/lua/lstrlib.c static int str_rep (lua_State *L) { L 96 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 97 lib/lua/lstrlib.c int n = luaL_checkint(L, 2); L 98 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 106 lib/lua/lstrlib.c static int str_byte (lua_State *L) { L 108 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l); L 109 lib/lua/lstrlib.c ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); L 110 lib/lua/lstrlib.c ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); L 117 lib/lua/lstrlib.c luaL_error(L, "string slice too long"); L 118 lib/lua/lstrlib.c luaL_checkstack(L, n, "string slice too long"); L 120 lib/lua/lstrlib.c lua_pushinteger(L, uchar(s[posi+i-1])); L 125 lib/lua/lstrlib.c static int str_char (lua_State *L) { L 126 lib/lua/lstrlib.c int n = lua_gettop(L); /* number of arguments */ L 129 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 131 lib/lua/lstrlib.c int c = luaL_checkint(L, i); L 132 lib/lua/lstrlib.c luaL_argcheck(L, uchar(c) == c, i, "invalid value"); L 140 lib/lua/lstrlib.c static int writer (lua_State *L, const void* b, size_t size, void* B) { L 141 lib/lua/lstrlib.c (void)L; L 147 lib/lua/lstrlib.c static int str_dump (lua_State *L) { L 149 lib/lua/lstrlib.c luaL_checktype(L, 1, LUA_TFUNCTION); L 150 lib/lua/lstrlib.c lua_settop(L, 1); L 151 lib/lua/lstrlib.c luaL_buffinit(L,&b); L 152 lib/lua/lstrlib.c if (lua_dump(L, writer, &b) != 0) L 153 lib/lua/lstrlib.c luaL_error(L, "unable to dump given function"); L 173 lib/lua/lstrlib.c lua_State *L; L 189 lib/lua/lstrlib.c return luaL_error(ms->L, "invalid capture index"); L 198 lib/lua/lstrlib.c return luaL_error(ms->L, "invalid pattern capture"); L 206 lib/lua/lstrlib.c luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); L 213 lib/lua/lstrlib.c luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); L 284 lib/lua/lstrlib.c luaL_error(ms->L, "unbalanced pattern"); L 333 lib/lua/lstrlib.c if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); L 388 lib/lua/lstrlib.c luaL_error(ms->L, "missing " LUA_QL("[") " after " L 470 lib/lua/lstrlib.c lua_pushlstring(ms->L, s, e - s); /* add whole match */ L 472 lib/lua/lstrlib.c luaL_error(ms->L, "invalid capture index"); L 476 lib/lua/lstrlib.c if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); L 478 lib/lua/lstrlib.c lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); L 480 lib/lua/lstrlib.c lua_pushlstring(ms->L, ms->capture[i].init, l); L 488 lib/lua/lstrlib.c luaL_checkstack(ms->L, nlevels, "too many captures"); L 495 lib/lua/lstrlib.c static int str_find_aux (lua_State *L, int find) { L 497 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, 1, &l1); L 498 lib/lua/lstrlib.c const char *p = luaL_checklstring(L, 2, &l2); L 499 lib/lua/lstrlib.c ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; L 502 lib/lua/lstrlib.c if (find && (lua_toboolean(L, 4) || /* explicit request? */ L 507 lib/lua/lstrlib.c lua_pushinteger(L, s2-s+1); L 508 lib/lua/lstrlib.c lua_pushinteger(L, s2-s+l2); L 516 lib/lua/lstrlib.c ms.L = L; L 524 lib/lua/lstrlib.c lua_pushinteger(L, s1-s+1); /* start */ L 525 lib/lua/lstrlib.c lua_pushinteger(L, res-s); /* end */ L 533 lib/lua/lstrlib.c lua_pushnil(L); /* not found */ L 538 lib/lua/lstrlib.c static int str_find (lua_State *L) { L 539 lib/lua/lstrlib.c return str_find_aux(L, 1); L 543 lib/lua/lstrlib.c static int str_match (lua_State *L) { L 544 lib/lua/lstrlib.c return str_find_aux(L, 0); L 548 lib/lua/lstrlib.c static int gmatch_aux (lua_State *L) { L 551 lib/lua/lstrlib.c const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); L 552 lib/lua/lstrlib.c const char *p = lua_tostring(L, lua_upvalueindex(2)); L 554 lib/lua/lstrlib.c ms.L = L; L 557 lib/lua/lstrlib.c for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); L 565 lib/lua/lstrlib.c lua_pushinteger(L, newstart); L 566 lib/lua/lstrlib.c lua_replace(L, lua_upvalueindex(3)); L 574 lib/lua/lstrlib.c static int gmatch (lua_State *L) { L 575 lib/lua/lstrlib.c luaL_checkstring(L, 1); L 576 lib/lua/lstrlib.c luaL_checkstring(L, 2); L 577 lib/lua/lstrlib.c lua_settop(L, 2); L 578 lib/lua/lstrlib.c lua_pushinteger(L, 0); L 579 lib/lua/lstrlib.c lua_pushcclosure(L, gmatch_aux, 3); L 584 lib/lua/lstrlib.c static int gfind_nodef (lua_State *L) { L 585 lib/lua/lstrlib.c return luaL_error(L, LUA_QL("string.gfind") " was renamed to " L 593 lib/lua/lstrlib.c const char *news = lua_tolstring(ms->L, 3, &l); L 614 lib/lua/lstrlib.c lua_State *L = ms->L; L 615 lib/lua/lstrlib.c switch (lua_type(L, 3)) { L 623 lib/lua/lstrlib.c lua_pushvalue(L, 3); L 625 lib/lua/lstrlib.c lua_call(L, n, 1); L 630 lib/lua/lstrlib.c lua_gettable(L, 3); L 634 lib/lua/lstrlib.c if (!lua_toboolean(L, -1)) { /* nil or false? */ L 635 lib/lua/lstrlib.c lua_pop(L, 1); L 636 lib/lua/lstrlib.c lua_pushlstring(L, s, e - s); /* keep original text */ L 638 lib/lua/lstrlib.c else if (!lua_isstring(L, -1)) L 639 lib/lua/lstrlib.c luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); L 644 lib/lua/lstrlib.c static int str_gsub (lua_State *L) { L 646 lib/lua/lstrlib.c const char *src = luaL_checklstring(L, 1, &srcl); L 647 lib/lua/lstrlib.c const char *p = luaL_checkstring(L, 2); L 648 lib/lua/lstrlib.c int tr = lua_type(L, 3); L 649 lib/lua/lstrlib.c int max_s = luaL_optint(L, 4, srcl+1); L 654 lib/lua/lstrlib.c luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || L 657 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 658 lib/lua/lstrlib.c ms.L = L; L 678 lib/lua/lstrlib.c lua_pushinteger(L, n); /* number of substitutions */ L 696 lib/lua/lstrlib.c static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { L 698 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, arg, &l); L 725 lib/lua/lstrlib.c static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { L 729 lib/lua/lstrlib.c luaL_error(L, "invalid format (repeated flags)"); L 738 lib/lua/lstrlib.c luaL_error(L, "invalid format (width or precision too long)"); L 756 lib/lua/lstrlib.c static int str_format (lua_State *L) { L 757 lib/lua/lstrlib.c int top = lua_gettop(L); L 760 lib/lua/lstrlib.c const char *strfrmt = luaL_checklstring(L, arg, &sfl); L 763 lib/lua/lstrlib.c luaL_buffinit(L, &b); L 773 lib/lua/lstrlib.c luaL_argerror(L, arg, "no value"); L 774 lib/lua/lstrlib.c strfrmt = scanformat(L, strfrmt, form); L 777 lib/lua/lstrlib.c sprintf(buff, form, (int)luaL_checknumber(L, arg)); L 782 lib/lua/lstrlib.c sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); L 787 lib/lua/lstrlib.c sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); L 792 lib/lua/lstrlib.c sprintf(buff, form, (double)luaL_checknumber(L, arg)); L 796 lib/lua/lstrlib.c addquoted(L, &b, arg); L 801 lib/lua/lstrlib.c const char *s = luaL_checklstring(L, arg, &l); L 805 lib/lua/lstrlib.c lua_pushvalue(L, arg); L 815 lib/lua/lstrlib.c return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " L 847 lib/lua/lstrlib.c static void createmetatable (lua_State *L) { L 848 lib/lua/lstrlib.c lua_createtable(L, 0, 1); /* create metatable for strings */ L 849 lib/lua/lstrlib.c lua_pushliteral(L, ""); /* dummy string */ L 850 lib/lua/lstrlib.c lua_pushvalue(L, -2); L 851 lib/lua/lstrlib.c lua_setmetatable(L, -2); /* set string metatable */ L 852 lib/lua/lstrlib.c lua_pop(L, 1); /* pop dummy string */ L 853 lib/lua/lstrlib.c lua_pushvalue(L, -2); /* string library... */ L 854 lib/lua/lstrlib.c lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ L 855 lib/lua/lstrlib.c lua_pop(L, 1); /* pop metatable */ L 862 lib/lua/lstrlib.c LUALIB_API int luaopen_string (lua_State *L) { L 863 lib/lua/lstrlib.c luaL_register(L, LUA_STRLIBNAME, strlib); L 865 lib/lua/lstrlib.c lua_getfield(L, -1, "gmatch"); L 866 lib/lua/lstrlib.c lua_setfield(L, -2, "gfind"); L 868 lib/lua/lstrlib.c createmetatable(L); L 137 lib/lua/ltable.c static int findindex (lua_State *L, Table *t, StkId key) { L 156 lib/lua/ltable.c luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ L 162 lib/lua/ltable.c LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key) { L 163 lib/lua/ltable.c int i = findindex(L, t, key); /* find original element */ L 167 lib/lua/ltable.c setobj2s(L, key+1, &t->array[i]); L 173 lib/lua/ltable.c setobj2s(L, key, key2tval(gnode(t, i))); L 174 lib/lua/ltable.c setobj2s(L, key+1, gval(gnode(t, i))); L 263 lib/lua/ltable.c static void setarrayvector (lua_State *L, Table *t, int size) { L 265 lib/lua/ltable.c luaM_reallocvector(L, t->array, t->sizearray, size, TValue); L 272 lib/lua/ltable.c static void setnodevector (lua_State *L, Table *t, int size) { L 282 lib/lua/ltable.c luaG_runerror(L, "table overflow"); L 284 lib/lua/ltable.c t->node = luaM_newvector(L, size, Node); L 297 lib/lua/ltable.c static void resize (lua_State *L, Table *t, int nasize, int nhsize) { L 303 lib/lua/ltable.c setarrayvector(L, t, nasize); L 305 lib/lua/ltable.c setnodevector(L, t, nhsize); L 311 lib/lua/ltable.c setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); L 314 lib/lua/ltable.c luaM_reallocvector(L, t->array, oldasize, nasize, TValue); L 320 lib/lua/ltable.c setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); L 323 lib/lua/ltable.c luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ L 327 lib/lua/ltable.c LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize) { L 329 lib/lua/ltable.c resize(L, t, nasize, nsize); L 333 lib/lua/ltable.c static void rehash (lua_State *L, Table *t, const TValue *ek) { L 348 lib/lua/ltable.c resize(L, t, nasize, totaluse - na); L 358 lib/lua/ltable.c LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int nhash) { L 359 lib/lua/ltable.c Table *t = luaM_new(L, Table); L 360 lib/lua/ltable.c luaC_link(L, obj2gco(t), LUA_TTABLE); L 368 lib/lua/ltable.c setarrayvector(L, t, narray); L 369 lib/lua/ltable.c setnodevector(L, t, nhash); L 374 lib/lua/ltable.c LUAI_FUNC void luaH_free (lua_State *L, Table *t) { L 376 lib/lua/ltable.c luaM_freearray(L, t->node, sizenode(t), Node); L 377 lib/lua/ltable.c luaM_freearray(L, t->array, t->sizearray, TValue); L 378 lib/lua/ltable.c luaM_free(L, t); L 399 lib/lua/ltable.c static TValue *newkey (lua_State *L, Table *t, const TValue *key) { L 405 lib/lua/ltable.c rehash(L, t, key); /* grow table */ L 406 lib/lua/ltable.c return luaH_set(L, t, key); /* re-insert key into grown table */ L 426 lib/lua/ltable.c luaC_barriert(L, t, key); L 494 lib/lua/ltable.c LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { L 500 lib/lua/ltable.c if (ttisnil(key)) luaG_runerror(L, "table index is nil"); L 502 lib/lua/ltable.c luaG_runerror(L, "table index is NaN"); L 503 lib/lua/ltable.c return newkey(L, t, key); L 508 lib/lua/ltable.c LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key) { L 515 lib/lua/ltable.c return newkey(L, t, &k); L 520 lib/lua/ltable.c LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { L 526 lib/lua/ltable.c setsvalue(L, &k, key); L 527 lib/lua/ltable.c return newkey(L, t, &k); L 22 lib/lua/ltable.h LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); L 24 lib/lua/ltable.h LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); L 26 lib/lua/ltable.h LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); L 27 lib/lua/ltable.h LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); L 28 lib/lua/ltable.h LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); L 29 lib/lua/ltable.h LUAI_FUNC void luaH_free (lua_State *L, Table *t); L 30 lib/lua/ltable.h LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); L 19 lib/lua/ltablib.c #define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) L 22 lib/lua/ltablib.c static int foreachi (lua_State *L) { L 24 lib/lua/ltablib.c int n = aux_getn(L, 1); L 25 lib/lua/ltablib.c luaL_checktype(L, 2, LUA_TFUNCTION); L 27 lib/lua/ltablib.c lua_pushvalue(L, 2); /* function */ L 28 lib/lua/ltablib.c lua_pushinteger(L, i); /* 1st argument */ L 29 lib/lua/ltablib.c lua_rawgeti(L, 1, i); /* 2nd argument */ L 30 lib/lua/ltablib.c lua_call(L, 2, 1); L 31 lib/lua/ltablib.c if (!lua_isnil(L, -1)) L 33 lib/lua/ltablib.c lua_pop(L, 1); /* remove nil result */ L 39 lib/lua/ltablib.c static int foreach (lua_State *L) { L 40 lib/lua/ltablib.c luaL_checktype(L, 1, LUA_TTABLE); L 41 lib/lua/ltablib.c luaL_checktype(L, 2, LUA_TFUNCTION); L 42 lib/lua/ltablib.c lua_pushnil(L); /* first key */ L 43 lib/lua/ltablib.c while (lua_next(L, 1)) { L 44 lib/lua/ltablib.c lua_pushvalue(L, 2); /* function */ L 45 lib/lua/ltablib.c lua_pushvalue(L, -3); /* key */ L 46 lib/lua/ltablib.c lua_pushvalue(L, -3); /* value */ L 47 lib/lua/ltablib.c lua_call(L, 2, 1); L 48 lib/lua/ltablib.c if (!lua_isnil(L, -1)) L 50 lib/lua/ltablib.c lua_pop(L, 2); /* remove value and result */ L 56 lib/lua/ltablib.c static int maxn (lua_State *L) { L 58 lib/lua/ltablib.c luaL_checktype(L, 1, LUA_TTABLE); L 59 lib/lua/ltablib.c lua_pushnil(L); /* first key */ L 60 lib/lua/ltablib.c while (lua_next(L, 1)) { L 61 lib/lua/ltablib.c lua_pop(L, 1); /* remove value */ L 62 lib/lua/ltablib.c if (lua_type(L, -1) == LUA_TNUMBER) { L 63 lib/lua/ltablib.c lua_Number v = lua_tonumber(L, -1); L 67 lib/lua/ltablib.c lua_pushnumber(L, max); L 72 lib/lua/ltablib.c static int getn (lua_State *L) { L 73 lib/lua/ltablib.c lua_pushinteger(L, aux_getn(L, 1)); L 78 lib/lua/ltablib.c static int setn (lua_State *L) { L 79 lib/lua/ltablib.c luaL_checktype(L, 1, LUA_TTABLE); L 81 lib/lua/ltablib.c luaL_setn(L, 1, luaL_checkint(L, 2)); L 83 lib/lua/ltablib.c luaL_error(L, LUA_QL("setn") " is obsolete"); L 85 lib/lua/ltablib.c lua_pushvalue(L, 1); L 90 lib/lua/ltablib.c static int tinsert (lua_State *L) { L 91 lib/lua/ltablib.c int e = aux_getn(L, 1) + 1; /* first empty element */ L 93 lib/lua/ltablib.c switch (lua_gettop(L)) { L 100 lib/lua/ltablib.c pos = luaL_checkint(L, 2); /* 2nd argument is the position */ L 103 lib/lua/ltablib.c lua_rawgeti(L, 1, i-1); L 104 lib/lua/ltablib.c lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ L 109 lib/lua/ltablib.c return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); L 112 lib/lua/ltablib.c luaL_setn(L, 1, e); /* new size */ L 113 lib/lua/ltablib.c lua_rawseti(L, 1, pos); /* t[pos] = v */ L 118 lib/lua/ltablib.c static int tremove (lua_State *L) { L 119 lib/lua/ltablib.c int e = aux_getn(L, 1); L 120 lib/lua/ltablib.c int pos = luaL_optint(L, 2, e); L 123 lib/lua/ltablib.c luaL_setn(L, 1, e - 1); /* t.n = n-1 */ L 124 lib/lua/ltablib.c lua_rawgeti(L, 1, pos); /* result = t[pos] */ L 126 lib/lua/ltablib.c lua_rawgeti(L, 1, pos+1); L 127 lib/lua/ltablib.c lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */ L 129 lib/lua/ltablib.c lua_pushnil(L); L 130 lib/lua/ltablib.c lua_rawseti(L, 1, e); /* t[e] = nil */ L 135 lib/lua/ltablib.c static void addfield (lua_State *L, luaL_Buffer *b, int i) { L 136 lib/lua/ltablib.c lua_rawgeti(L, 1, i); L 137 lib/lua/ltablib.c if (!lua_isstring(L, -1)) L 138 lib/lua/ltablib.c luaL_error(L, "invalid value (%s) at index %d in table for " L 139 lib/lua/ltablib.c LUA_QL("concat"), luaL_typename(L, -1), i); L 144 lib/lua/ltablib.c static int tconcat (lua_State *L) { L 148 lib/lua/ltablib.c const char *sep = luaL_optlstring(L, 2, "", &lsep); L 149 lib/lua/ltablib.c luaL_checktype(L, 1, LUA_TTABLE); L 150 lib/lua/ltablib.c i = luaL_optint(L, 3, 1); L 151 lib/lua/ltablib.c last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1)); L 152 lib/lua/ltablib.c luaL_buffinit(L, &b); L 154 lib/lua/ltablib.c addfield(L, &b, i); L 158 lib/lua/ltablib.c addfield(L, &b, i); L 173 lib/lua/ltablib.c static void set2 (lua_State *L, int i, int j) { L 174 lib/lua/ltablib.c lua_rawseti(L, 1, i); L 175 lib/lua/ltablib.c lua_rawseti(L, 1, j); L 178 lib/lua/ltablib.c static int sort_comp (lua_State *L, int a, int b) { L 179 lib/lua/ltablib.c if (!lua_isnil(L, 2)) { /* function? */ L 181 lib/lua/ltablib.c lua_pushvalue(L, 2); L 182 lib/lua/ltablib.c lua_pushvalue(L, a-1); /* -1 to compensate function */ L 183 lib/lua/ltablib.c lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ L 184 lib/lua/ltablib.c lua_call(L, 2, 1); L 185 lib/lua/ltablib.c res = lua_toboolean(L, -1); L 186 lib/lua/ltablib.c lua_pop(L, 1); L 190 lib/lua/ltablib.c return lua_lessthan(L, a, b); L 193 lib/lua/ltablib.c static void auxsort (lua_State *L, int l, int u) { L 197 lib/lua/ltablib.c lua_rawgeti(L, 1, l); L 198 lib/lua/ltablib.c lua_rawgeti(L, 1, u); L 199 lib/lua/ltablib.c if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ L 200 lib/lua/ltablib.c set2(L, l, u); /* swap a[l] - a[u] */ L 202 lib/lua/ltablib.c lua_pop(L, 2); L 205 lib/lua/ltablib.c lua_rawgeti(L, 1, i); L 206 lib/lua/ltablib.c lua_rawgeti(L, 1, l); L 207 lib/lua/ltablib.c if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */ L 208 lib/lua/ltablib.c set2(L, i, l); L 210 lib/lua/ltablib.c lua_pop(L, 1); /* remove a[l] */ L 211 lib/lua/ltablib.c lua_rawgeti(L, 1, u); L 212 lib/lua/ltablib.c if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */ L 213 lib/lua/ltablib.c set2(L, i, u); L 215 lib/lua/ltablib.c lua_pop(L, 2); L 218 lib/lua/ltablib.c lua_rawgeti(L, 1, i); /* Pivot */ L 219 lib/lua/ltablib.c lua_pushvalue(L, -1); L 220 lib/lua/ltablib.c lua_rawgeti(L, 1, u-1); L 221 lib/lua/ltablib.c set2(L, i, u-1); L 226 lib/lua/ltablib.c while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { L 227 lib/lua/ltablib.c if (i>u) luaL_error(L, "invalid order function for sorting"); L 228 lib/lua/ltablib.c lua_pop(L, 1); /* remove a[i] */ L 231 lib/lua/ltablib.c while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { L 232 lib/lua/ltablib.c if (j<l) luaL_error(L, "invalid order function for sorting"); L 233 lib/lua/ltablib.c lua_pop(L, 1); /* remove a[j] */ L 236 lib/lua/ltablib.c lua_pop(L, 3); /* pop pivot, a[i], a[j] */ L 239 lib/lua/ltablib.c set2(L, i, j); L 241 lib/lua/ltablib.c lua_rawgeti(L, 1, u-1); L 242 lib/lua/ltablib.c lua_rawgeti(L, 1, i); L 243 lib/lua/ltablib.c set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */ L 252 lib/lua/ltablib.c auxsort(L, j, i); /* call recursively the smaller one */ L 256 lib/lua/ltablib.c static int sort (lua_State *L) { L 257 lib/lua/ltablib.c int n = aux_getn(L, 1); L 258 lib/lua/ltablib.c luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */ L 259 lib/lua/ltablib.c if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ L 260 lib/lua/ltablib.c luaL_checktype(L, 2, LUA_TFUNCTION); L 261 lib/lua/ltablib.c lua_settop(L, 2); /* make sure there is two arguments */ L 262 lib/lua/ltablib.c auxsort(L, 1, n); L 283 lib/lua/ltablib.c LUALIB_API int luaopen_table (lua_State *L) { L 284 lib/lua/ltablib.c luaL_register(L, LUA_TABLIBNAME, tab_funcs); L 30 lib/lua/ltm.c LUAI_FUNC void luaT_init (lua_State *L) { L 40 lib/lua/ltm.c G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]); L 41 lib/lua/ltm.c luaS_fix(G(L)->tmname[i]); /* never collect these names */ L 61 lib/lua/ltm.c LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { L 71 lib/lua/ltm.c mt = G(L)->mt[ttype(o)]; L 73 lib/lua/ltm.c return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); L 50 lib/lua/ltm.h LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, L 52 lib/lua/ltm.h LUAI_FUNC void luaT_init (lua_State *L); L 28 lib/lua/lua.c static void lstop (lua_State *L, lua_Debug *ar) { L 30 lib/lua/lua.c lua_sethook(L, NULL, 0, 0); L 31 lib/lua/lua.c luaL_error(L, "interrupted!"); L 65 lib/lua/lua.c static int report (lua_State *L, int status) { L 66 lib/lua/lua.c if (status && !lua_isnil(L, -1)) { L 67 lib/lua/lua.c const char *msg = lua_tostring(L, -1); L 70 lib/lua/lua.c lua_pop(L, 1); L 76 lib/lua/lua.c static int traceback (lua_State *L) { L 77 lib/lua/lua.c if (!lua_isstring(L, 1)) /* 'message' not a string? */ L 79 lib/lua/lua.c lua_getfield(L, LUA_GLOBALSINDEX, "debug"); L 80 lib/lua/lua.c if (!lua_istable(L, -1)) { L 81 lib/lua/lua.c lua_pop(L, 1); L 84 lib/lua/lua.c lua_getfield(L, -1, "traceback"); L 85 lib/lua/lua.c if (!lua_isfunction(L, -1)) { L 86 lib/lua/lua.c lua_pop(L, 2); L 89 lib/lua/lua.c lua_pushvalue(L, 1); /* pass error message */ L 90 lib/lua/lua.c lua_pushinteger(L, 2); /* skip this function and traceback */ L 91 lib/lua/lua.c lua_call(L, 2, 1); /* call debug.traceback */ L 96 lib/lua/lua.c static int docall (lua_State *L, int narg, int clear) { L 98 lib/lua/lua.c int base = lua_gettop(L) - narg; /* function index */ L 99 lib/lua/lua.c lua_pushcfunction(L, traceback); /* push traceback function */ L 100 lib/lua/lua.c lua_insert(L, base); /* put it under chunk and args */ L 102 lib/lua/lua.c status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); L 104 lib/lua/lua.c lua_remove(L, base); /* remove traceback function */ L 106 lib/lua/lua.c if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); L 116 lib/lua/lua.c static int getargs (lua_State *L, char **argv, int n) { L 122 lib/lua/lua.c luaL_checkstack(L, narg + 3, "too many arguments to script"); L 124 lib/lua/lua.c lua_pushstring(L, argv[i]); L 125 lib/lua/lua.c lua_createtable(L, narg, n + 1); L 127 lib/lua/lua.c lua_pushstring(L, argv[i]); L 128 lib/lua/lua.c lua_rawseti(L, -2, i - n); L 134 lib/lua/lua.c static int dofile (lua_State *L, const char *name) { L 135 lib/lua/lua.c int status = luaL_loadfile(L, name) || docall(L, 0, 1); L 136 lib/lua/lua.c return report(L, status); L 140 lib/lua/lua.c static int dostring (lua_State *L, const char *s, const char *name) { L 141 lib/lua/lua.c int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); L 142 lib/lua/lua.c return report(L, status); L 146 lib/lua/lua.c static int dolibrary (lua_State *L, const char *name) { L 147 lib/lua/lua.c lua_getglobal(L, "require"); L 148 lib/lua/lua.c lua_pushstring(L, name); L 149 lib/lua/lua.c return report(L, docall(L, 1, 1)); L 153 lib/lua/lua.c static const char *get_prompt (lua_State *L, int firstline) { L 155 lib/lua/lua.c lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); L 156 lib/lua/lua.c p = lua_tostring(L, -1); L 158 lib/lua/lua.c lua_pop(L, 1); /* remove global */ L 163 lib/lua/lua.c static int incomplete (lua_State *L, int status) { L 166 lib/lua/lua.c const char *msg = lua_tolstring(L, -1, &lmsg); L 169 lib/lua/lua.c lua_pop(L, 1); L 177 lib/lua/lua.c static int pushline (lua_State *L, int firstline) { L 181 lib/lua/lua.c const char *prmt = get_prompt(L, firstline); L 182 lib/lua/lua.c if (lua_readline(L, b, prmt) == 0) L 188 lib/lua/lua.c lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ L 190 lib/lua/lua.c lua_pushstring(L, b); L 191 lib/lua/lua.c lua_freeline(L, b); L 196 lib/lua/lua.c static int loadline (lua_State *L) { L 198 lib/lua/lua.c lua_settop(L, 0); L 199 lib/lua/lua.c if (!pushline(L, 1)) L 202 lib/lua/lua.c status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); L 203 lib/lua/lua.c if (!incomplete(L, status)) break; /* cannot try to add lines? */ L 204 lib/lua/lua.c if (!pushline(L, 0)) /* no more input? */ L 206 lib/lua/lua.c lua_pushliteral(L, "\n"); /* add a new line... */ L 207 lib/lua/lua.c lua_insert(L, -2); /* ...between the two lines */ L 208 lib/lua/lua.c lua_concat(L, 3); /* join them */ L 210 lib/lua/lua.c lua_saveline(L, 1); L 211 lib/lua/lua.c lua_remove(L, 1); /* remove line */ L 216 lib/lua/lua.c static void dotty (lua_State *L) { L 220 lib/lua/lua.c while ((status = loadline(L)) != -1) { L 221 lib/lua/lua.c if (status == 0) status = docall(L, 0, 0); L 222 lib/lua/lua.c report(L, status); L 223 lib/lua/lua.c if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ L 224 lib/lua/lua.c lua_getglobal(L, "print"); L 225 lib/lua/lua.c lua_insert(L, 1); L 226 lib/lua/lua.c if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) L 227 lib/lua/lua.c l_message(progname, lua_pushfstring(L, L 229 lib/lua/lua.c lua_tostring(L, -1))); L 232 lib/lua/lua.c lua_settop(L, 0); /* clear stack */ L 239 lib/lua/lua.c static int handle_script (lua_State *L, char **argv, int n) { L 242 lib/lua/lua.c int narg = getargs(L, argv, n); /* collect arguments */ L 243 lib/lua/lua.c lua_setglobal(L, "arg"); L 247 lib/lua/lua.c status = luaL_loadfile(L, fname); L 248 lib/lua/lua.c lua_insert(L, -(narg+1)); L 250 lib/lua/lua.c status = docall(L, narg, 0); L 252 lib/lua/lua.c lua_pop(L, narg); L 253 lib/lua/lua.c return report(L, status); L 294 lib/lua/lua.c static int runargs (lua_State *L, char **argv, int n) { L 304 lib/lua/lua.c if (dostring(L, chunk, "=(command line)") != 0) L 312 lib/lua/lua.c if (dolibrary(L, filename)) L 323 lib/lua/lua.c static int handle_luainit (lua_State *L) { L 327 lib/lua/lua.c return dofile(L, init+1); L 329 lib/lua/lua.c return dostring(L, init, "=" LUA_INIT); L 340 lib/lua/lua.c static int pmain (lua_State *L) { L 341 lib/lua/lua.c struct Smain *s = (struct Smain *)lua_touserdata(L, 1); L 345 lib/lua/lua.c globalL = L; L 347 lib/lua/lua.c lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ L 348 lib/lua/lua.c luaL_openlibs(L); /* open libraries */ L 349 lib/lua/lua.c lua_gc(L, LUA_GCRESTART, 0); L 350 lib/lua/lua.c s->status = handle_luainit(L); L 359 lib/lua/lua.c s->status = runargs(L, argv, (script > 0) ? script : s->argc); L 362 lib/lua/lua.c s->status = handle_script(L, argv, script); L 365 lib/lua/lua.c dotty(L); L 369 lib/lua/lua.c dotty(L); L 371 lib/lua/lua.c else dofile(L, NULL); /* executes stdin as a file */ L 380 lib/lua/lua.c lua_State *L = lua_open(); /* create state */ L 381 lib/lua/lua.c if (L == NULL) { L 387 lib/lua/lua.c status = lua_cpcall(L, &pmain, &s); L 388 lib/lua/lua.c report(L, status); L 389 lib/lua/lua.c lua_close(L); L 52 lib/lua/lua.h typedef int (*lua_CFunction) (lua_State *L); L 58 lib/lua/lua.h typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); L 60 lib/lua/lua.h typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); L 111 lib/lua/lua.h LUA_API void (lua_close) (lua_State *L); L 112 lib/lua/lua.h LUA_API lua_State *(lua_newthread) (lua_State *L); L 114 lib/lua/lua.h LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); L 120 lib/lua/lua.h LUA_API int (lua_gettop) (lua_State *L); L 121 lib/lua/lua.h LUA_API void (lua_settop) (lua_State *L, int idx); L 122 lib/lua/lua.h LUA_API void (lua_pushvalue) (lua_State *L, int idx); L 123 lib/lua/lua.h LUA_API void (lua_remove) (lua_State *L, int idx); L 124 lib/lua/lua.h LUA_API void (lua_insert) (lua_State *L, int idx); L 125 lib/lua/lua.h LUA_API void (lua_replace) (lua_State *L, int idx); L 126 lib/lua/lua.h LUA_API int (lua_checkstack) (lua_State *L, int sz); L 135 lib/lua/lua.h LUA_API int (lua_isnumber) (lua_State *L, int idx); L 136 lib/lua/lua.h LUA_API int (lua_isstring) (lua_State *L, int idx); L 137 lib/lua/lua.h LUA_API int (lua_iscfunction) (lua_State *L, int idx); L 138 lib/lua/lua.h LUA_API int (lua_isuserdata) (lua_State *L, int idx); L 139 lib/lua/lua.h LUA_API int (lua_type) (lua_State *L, int idx); L 140 lib/lua/lua.h LUA_API const char *(lua_typename) (lua_State *L, int tp); L 142 lib/lua/lua.h LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); L 143 lib/lua/lua.h LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); L 144 lib/lua/lua.h LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); L 146 lib/lua/lua.h LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); L 147 lib/lua/lua.h LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); L 148 lib/lua/lua.h LUA_API int (lua_toboolean) (lua_State *L, int idx); L 149 lib/lua/lua.h LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); L 150 lib/lua/lua.h LUA_API size_t (lua_objlen) (lua_State *L, int idx); L 151 lib/lua/lua.h LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); L 152 lib/lua/lua.h LUA_API void *(lua_touserdata) (lua_State *L, int idx); L 153 lib/lua/lua.h LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); L 154 lib/lua/lua.h LUA_API const void *(lua_topointer) (lua_State *L, int idx); L 160 lib/lua/lua.h LUA_API void (lua_pushnil) (lua_State *L); L 161 lib/lua/lua.h LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); L 162 lib/lua/lua.h LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); L 163 lib/lua/lua.h LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); L 164 lib/lua/lua.h LUA_API void (lua_pushstring) (lua_State *L, const char *s); L 165 lib/lua/lua.h LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, L 167 lib/lua/lua.h LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); L 168 lib/lua/lua.h LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); L 169 lib/lua/lua.h LUA_API void (lua_pushboolean) (lua_State *L, int b); L 170 lib/lua/lua.h LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); L 171 lib/lua/lua.h LUA_API int (lua_pushthread) (lua_State *L); L 177 lib/lua/lua.h LUA_API void (lua_gettable) (lua_State *L, int idx); L 178 lib/lua/lua.h LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); L 179 lib/lua/lua.h LUA_API void (lua_rawget) (lua_State *L, int idx); L 180 lib/lua/lua.h LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); L 181 lib/lua/lua.h LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); L 182 lib/lua/lua.h LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); L 183 lib/lua/lua.h LUA_API int (lua_getmetatable) (lua_State *L, int objindex); L 184 lib/lua/lua.h LUA_API void (lua_getfenv) (lua_State *L, int idx); L 190 lib/lua/lua.h LUA_API void (lua_settable) (lua_State *L, int idx); L 191 lib/lua/lua.h LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); L 192 lib/lua/lua.h LUA_API void (lua_rawset) (lua_State *L, int idx); L 193 lib/lua/lua.h LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); L 194 lib/lua/lua.h LUA_API int (lua_setmetatable) (lua_State *L, int objindex); L 195 lib/lua/lua.h LUA_API int (lua_setfenv) (lua_State *L, int idx); L 201 lib/lua/lua.h LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); L 202 lib/lua/lua.h LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); L 203 lib/lua/lua.h LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); L 204 lib/lua/lua.h LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, L 207 lib/lua/lua.h LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); L 213 lib/lua/lua.h LUA_API int (lua_yield) (lua_State *L, int nresults); L 214 lib/lua/lua.h LUA_API int (lua_resume) (lua_State *L, int narg); L 215 lib/lua/lua.h LUA_API int (lua_status) (lua_State *L); L 230 lib/lua/lua.h LUA_API int (lua_gc) (lua_State *L, int what, int data); L 237 lib/lua/lua.h LUA_API int (lua_error) (lua_State *L); L 239 lib/lua/lua.h LUA_API int (lua_next) (lua_State *L, int idx); L 241 lib/lua/lua.h LUA_API void (lua_concat) (lua_State *L, int n); L 243 lib/lua/lua.h LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); L 244 lib/lua/lua.h LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); L 254 lib/lua/lua.h #define lua_pop(L,n) lua_settop(L, -(n)-1) L 256 lib/lua/lua.h #define lua_newtable(L) lua_createtable(L, 0, 0) L 258 lib/lua/lua.h #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) L 260 lib/lua/lua.h #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) L 262 lib/lua/lua.h #define lua_strlen(L,i) lua_objlen(L, (i)) L 264 lib/lua/lua.h #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) L 265 lib/lua/lua.h #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) L 266 lib/lua/lua.h #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) L 267 lib/lua/lua.h #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) L 268 lib/lua/lua.h #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) L 269 lib/lua/lua.h #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) L 270 lib/lua/lua.h #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) L 271 lib/lua/lua.h #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) L 273 lib/lua/lua.h #define lua_pushliteral(L, s) \ L 274 lib/lua/lua.h lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) L 276 lib/lua/lua.h #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) L 277 lib/lua/lua.h #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) L 279 lib/lua/lua.h #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) L 289 lib/lua/lua.h #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) L 291 lib/lua/lua.h #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) L 330 lib/lua/lua.h typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); L 333 lib/lua/lua.h LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); L 334 lib/lua/lua.h LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); L 335 lib/lua/lua.h LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); L 336 lib/lua/lua.h LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); L 337 lib/lua/lua.h LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); L 338 lib/lua/lua.h LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); L 340 lib/lua/lua.h LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); L 341 lib/lua/lua.h LUA_API lua_Hook lua_gethook (lua_State *L); L 342 lib/lua/lua.h LUA_API int lua_gethookmask (lua_State *L); L 343 lib/lua/lua.h LUA_API int lua_gethookcount (lua_State *L); L 117 lib/lua/luac.c #define toproto(L,i) (clvalue(L->top+(i))->l.p) L 119 lib/lua/luac.c static const Proto* combine(lua_State* L, int n) L 122 lib/lua/luac.c return toproto(L,-1); L 126 lib/lua/luac.c Proto* f=luaF_newproto(L); L 127 lib/lua/luac.c setptvalue2s(L,L->top,f); incr_top(L); L 128 lib/lua/luac.c f->source=luaS_newliteral(L,"=(" PROGNAME ")"); L 131 lib/lua/luac.c f->code=luaM_newvector(L,pc,Instruction); L 133 lib/lua/luac.c f->p=luaM_newvector(L,n,Proto*); L 138 lib/lua/luac.c f->p[i]=toproto(L,i-n-1); L 147 lib/lua/luac.c static int writer(lua_State* L, const void* p, size_t size, void* u) L 149 lib/lua/luac.c UNUSED(L); L 158 lib/lua/luac.c static int pmain(lua_State* L) L 160 lib/lua/luac.c struct Smain* s = (struct Smain*)lua_touserdata(L, 1); L 165 lib/lua/luac.c if (!lua_checkstack(L,argc)) fatal("too many input files"); L 169 lib/lua/luac.c if (luaL_loadfile(L,filename)!=0) fatal(lua_tostring(L,-1)); L 171 lib/lua/luac.c f=combine(L,argc); L 177 lib/lua/luac.c lua_lock(L); L 178 lib/lua/luac.c luaU_dump(L,f,writer,D,stripping); L 179 lib/lua/luac.c lua_unlock(L); L 188 lib/lua/luac.c lua_State* L; L 193 lib/lua/luac.c L=lua_open(); L 194 lib/lua/luac.c if (L==NULL) fatal("not enough memory for state"); L 197 lib/lua/luac.c if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); L 198 lib/lua/luac.c lua_close(L); L 301 lib/lua/luaconf.h #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) L 302 lib/lua/luaconf.h #define lua_saveline(L,idx) \ L 303 lib/lua/luaconf.h if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ L 304 lib/lua/luaconf.h add_history(lua_tostring(L, idx)); /* add it to history */ L 305 lib/lua/luaconf.h #define lua_freeline(L,b) ((void)L, free(b)) L 307 lib/lua/luaconf.h #define lua_readline(L,b,p) \ L 308 lib/lua/luaconf.h ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ L 310 lib/lua/luaconf.h #define lua_saveline(L,idx) { (void)L; (void)idx; } L 311 lib/lua/luaconf.h #define lua_freeline(L,b) { (void)L; (void)b; } L 403 lib/lua/luaconf.h #define luai_apicheck(L,o) { (void)L; assert(o); } L 405 lib/lua/luaconf.h #define luai_apicheck(L,o) { (void)L; } L 643 lib/lua/luaconf.h #define LUAI_THROW(L,c) throw(c) L 644 lib/lua/luaconf.h #define LUAI_TRY(L,c,a) try { a } catch(...) \ L 650 lib/lua/luaconf.h #define LUAI_THROW(L,c) _longjmp((c)->b, 1) L 651 lib/lua/luaconf.h #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } L 656 lib/lua/luaconf.h #define LUAI_THROW(L,c) longjmp((c)->b, 1) L 657 lib/lua/luaconf.h #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } L 705 lib/lua/luaconf.h #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) L 706 lib/lua/luaconf.h #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) L 710 lib/lua/luaconf.h #define lua_popen(L,c,m) ((void)L, _popen(c,m)) L 711 lib/lua/luaconf.h #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) L 715 lib/lua/luaconf.h #define lua_popen(L,c,m) ((void)((void)c, m), \ L 716 lib/lua/luaconf.h luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) L 717 lib/lua/luaconf.h #define lua_pclose(L,file) ((void)((void)L, file), 0) L 758 lib/lua/luaconf.h #define luai_userstateopen(L) ((void)L) L 759 lib/lua/luaconf.h #define luai_userstateclose(L) ((void)L) L 760 lib/lua/luaconf.h #define luai_userstatethread(L,L1) ((void)L) L 761 lib/lua/luaconf.h #define luai_userstatefree(L) ((void)L) L 762 lib/lua/luaconf.h #define luai_userstateresume(L,n) ((void)L) L 763 lib/lua/luaconf.h #define luai_userstateyield(L,n) ((void)L) L 19 lib/lua/lualib.h LUALIB_API int (luaopen_base) (lua_State *L); L 22 lib/lua/lualib.h LUALIB_API int (luaopen_table) (lua_State *L); L 25 lib/lua/lualib.h LUALIB_API int (luaopen_io) (lua_State *L); L 28 lib/lua/lualib.h LUALIB_API int (luaopen_os) (lua_State *L); L 31 lib/lua/lualib.h LUALIB_API int (luaopen_string) (lua_State *L); L 34 lib/lua/lualib.h LUALIB_API int (luaopen_math) (lua_State *L); L 37 lib/lua/lualib.h LUALIB_API int (luaopen_imath) (lua_State *L); L 40 lib/lua/lualib.h LUALIB_API int (luaopen_fmath) (lua_State *L); L 43 lib/lua/lualib.h LUALIB_API int (luaopen_debug) (lua_State *L); L 46 lib/lua/lualib.h LUALIB_API int (luaopen_package) (lua_State *L); L 50 lib/lua/lualib.h LUALIB_API void (luaL_openlibs) (lua_State *L); L 24 lib/lua/lundump.c lua_State* L; L 38 lib/lua/lundump.c luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); L 39 lib/lua/lundump.c luaD_throw(S->L,LUA_ERRSYNTAX); L 84 lib/lua/lundump.c char* s=luaZ_openspace(S->L,S->b,size); L 86 lib/lua/lundump.c return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ L 93 lib/lua/lundump.c f->code=luaM_newvector(S->L,n,Instruction); L 104 lib/lua/lundump.c f->k=luaM_newvector(S->L,n,TValue); L 123 lib/lua/lundump.c setsvalue2n(S->L,o,LoadString(S)); L 131 lib/lua/lundump.c f->p=luaM_newvector(S->L,n,Proto*); L 141 lib/lua/lundump.c f->lineinfo=luaM_newvector(S->L,n,int); L 145 lib/lua/lundump.c f->locvars=luaM_newvector(S->L,n,LocVar); L 155 lib/lua/lundump.c f->upvalues=luaM_newvector(S->L,n,TString*); L 164 lib/lua/lundump.c if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); L 165 lib/lua/lundump.c f=luaF_newproto(S->L); L 166 lib/lua/lundump.c setptvalue2s(S->L,S->L->top,f); incr_top(S->L); L 178 lib/lua/lundump.c S->L->top--; L 179 lib/lua/lundump.c S->L->nCcalls--; L 195 lib/lua/lundump.c LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) L 204 lib/lua/lundump.c S.L=L; L 208 lib/lua/lundump.c return LoadFunction(&S,luaS_newliteral(L,"=?")); L 14 lib/lua/lundump.h LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); L 20 lib/lua/lundump.h LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); L 63 lib/lua/lvm.c LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj) { L 70 lib/lua/lvm.c setsvalue2s(L, obj, luaS_new(L, s)); L 76 lib/lua/lvm.c static void traceexec (lua_State *L, const Instruction *pc) { L 77 lib/lua/lvm.c lu_byte mask = L->hookmask; L 78 lib/lua/lvm.c const Instruction *oldpc = L->savedpc; L 79 lib/lua/lvm.c L->savedpc = pc; L 80 lib/lua/lvm.c if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { L 81 lib/lua/lvm.c resethookcount(L); L 82 lib/lua/lvm.c luaD_callhook(L, LUA_HOOKCOUNT, -1); L 85 lib/lua/lvm.c Proto *p = ci_func(L->ci)->l.p; L 91 lib/lua/lvm.c luaD_callhook(L, LUA_HOOKLINE, newline); L 96 lib/lua/lvm.c static void callTMres (lua_State *L, StkId res, const TValue *f, L 98 lib/lua/lvm.c ptrdiff_t result = savestack(L, res); L 99 lib/lua/lvm.c setobj2s(L, L->top, f); /* push function */ L 100 lib/lua/lvm.c setobj2s(L, L->top+1, p1); /* 1st argument */ L 101 lib/lua/lvm.c setobj2s(L, L->top+2, p2); /* 2nd argument */ L 102 lib/lua/lvm.c luaD_checkstack(L, 3); L 103 lib/lua/lvm.c L->top += 3; L 104 lib/lua/lvm.c luaD_call(L, L->top - 3, 1); L 105 lib/lua/lvm.c res = restorestack(L, result); L 106 lib/lua/lvm.c L->top--; L 107 lib/lua/lvm.c setobjs2s(L, res, L->top); L 112 lib/lua/lvm.c static void callTM (lua_State *L, const TValue *f, const TValue *p1, L 114 lib/lua/lvm.c setobj2s(L, L->top, f); /* push function */ L 115 lib/lua/lvm.c setobj2s(L, L->top+1, p1); /* 1st argument */ L 116 lib/lua/lvm.c setobj2s(L, L->top+2, p2); /* 2nd argument */ L 117 lib/lua/lvm.c setobj2s(L, L->top+3, p3); /* 3th argument */ L 118 lib/lua/lvm.c luaD_checkstack(L, 4); L 119 lib/lua/lvm.c L->top += 4; L 120 lib/lua/lvm.c luaD_call(L, L->top - 4, 0); L 124 lib/lua/lvm.c LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { L 132 lib/lua/lvm.c (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ L 133 lib/lua/lvm.c setobj2s(L, val, res); L 138 lib/lua/lvm.c else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) L 139 lib/lua/lvm.c luaG_typeerror(L, t, "index"); L 141 lib/lua/lvm.c callTMres(L, val, tm, t, key); L 146 lib/lua/lvm.c luaG_runerror(L, "loop in gettable"); L 150 lib/lua/lvm.c LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { L 157 lib/lua/lvm.c TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ L 159 lib/lua/lvm.c (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ L 160 lib/lua/lvm.c setobj2t(L, oldval, val); L 162 lib/lua/lvm.c luaC_barriert(L, h, val); L 167 lib/lua/lvm.c else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) L 168 lib/lua/lvm.c luaG_typeerror(L, t, "index"); L 170 lib/lua/lvm.c callTM(L, tm, t, key, val); L 174 lib/lua/lvm.c setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */ L 177 lib/lua/lvm.c luaG_runerror(L, "loop in settable"); L 181 lib/lua/lvm.c static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, L 183 lib/lua/lvm.c const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ L 185 lib/lua/lvm.c tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ L 187 lib/lua/lvm.c callTMres(L, res, tm, p1, p2); L 192 lib/lua/lvm.c static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, L 194 lib/lua/lvm.c const TValue *tm1 = fasttm(L, mt1, event); L 198 lib/lua/lvm.c tm2 = fasttm(L, mt2, event); L 206 lib/lua/lvm.c static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, L 208 lib/lua/lvm.c const TValue *tm1 = luaT_gettmbyobj(L, p1, event); L 211 lib/lua/lvm.c tm2 = luaT_gettmbyobj(L, p2, event); L 214 lib/lua/lvm.c callTMres(L, L->top, tm1, p1, p2); L 215 lib/lua/lvm.c return !l_isfalse(L->top); L 241 lib/lua/lvm.c LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { L 244 lib/lua/lvm.c return luaG_ordererror(L, l, r); L 249 lib/lua/lvm.c else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) L 251 lib/lua/lvm.c return luaG_ordererror(L, l, r); L 255 lib/lua/lvm.c static int lessequal (lua_State *L, const TValue *l, const TValue *r) { L 258 lib/lua/lvm.c return luaG_ordererror(L, l, r); L 263 lib/lua/lvm.c else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ L 265 lib/lua/lvm.c else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ L 267 lib/lua/lvm.c return luaG_ordererror(L, l, r); L 271 lib/lua/lvm.c LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { L 281 lib/lua/lvm.c tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, L 287 lib/lua/lvm.c tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); L 293 lib/lua/lvm.c callTMres(L, L->top, tm, t1, t2); /* call TM */ L 294 lib/lua/lvm.c return !l_isfalse(L->top); L 298 lib/lua/lvm.c LUAI_FUNC void luaV_concat (lua_State *L, int total, int last) { L 300 lib/lua/lvm.c StkId top = L->base + last + 1; L 302 lib/lua/lvm.c if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { L 303 lib/lua/lvm.c if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) L 304 lib/lua/lvm.c luaG_concaterror(L, top-2, top-1); L 306 lib/lua/lvm.c (void)tostring(L, top - 2); /* result is first op (as string) */ L 313 lib/lua/lvm.c for (n = 1; n < total && tostring(L, top-n-1); n++) { L 315 lib/lua/lvm.c if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); L 318 lib/lua/lvm.c buffer = luaZ_openspace(L, &G(L)->buff, tl); L 325 lib/lua/lvm.c setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); L 333 lib/lua/lvm.c static void Arith (lua_State *L, StkId ra, const TValue *rb, L 351 lib/lua/lvm.c else if (!call_binTM(L, rb, rc, ra, op)) L 352 lib/lua/lvm.c luaG_aritherror(L, rb, rc); L 361 lib/lua/lvm.c #define runtime_check(L, c) { if (!(c)) break; } L 374 lib/lua/lvm.c #define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} L 377 lib/lua/lvm.c #define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } L 388 lib/lua/lvm.c Protect(Arith(L, ra, rb, rc, tm)); \ L 393 lib/lua/lvm.c LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls) { L 399 lib/lua/lvm.c lua_assert(isLua(L->ci)); L 400 lib/lua/lvm.c pc = L->savedpc; L 401 lib/lua/lvm.c cl = &clvalue(L->ci->func)->l; L 402 lib/lua/lvm.c base = L->base; L 408 lib/lua/lvm.c if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && L 409 lib/lua/lvm.c (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { L 410 lib/lua/lvm.c traceexec(L, pc); L 411 lib/lua/lvm.c if (L->status == LUA_YIELD) { /* did hook yield? */ L 412 lib/lua/lvm.c L->savedpc = pc - 1; L 415 lib/lua/lvm.c base = L->base; L 419 lib/lua/lvm.c lua_assert(base == L->base && L->base == L->ci->base); L 420 lib/lua/lvm.c lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); L 421 lib/lua/lvm.c lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); L 424 lib/lua/lvm.c setobjs2s(L, ra, RB(i)); L 428 lib/lua/lvm.c setobj2s(L, ra, KBx(i)); L 445 lib/lua/lvm.c setobj2s(L, ra, cl->upvals[b]->v); L 451 lib/lua/lvm.c sethvalue(L, &g, cl->env); L 453 lib/lua/lvm.c Protect(luaV_gettable(L, &g, rb, ra)); L 457 lib/lua/lvm.c Protect(luaV_gettable(L, RB(i), RKC(i), ra)); L 462 lib/lua/lvm.c sethvalue(L, &g, cl->env); L 464 lib/lua/lvm.c Protect(luaV_settable(L, &g, KBx(i), ra)); L 469 lib/lua/lvm.c setobj(L, uv->v, ra); L 470 lib/lua/lvm.c luaC_barrier(L, uv, ra); L 474 lib/lua/lvm.c Protect(luaV_settable(L, ra, RKB(i), RKC(i))); L 480 lib/lua/lvm.c sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); L 481 lib/lua/lvm.c Protect(luaC_checkGC(L)); L 486 lib/lua/lvm.c setobjs2s(L, ra+1, rb); L 487 lib/lua/lvm.c Protect(luaV_gettable(L, rb, RKC(i), ra)); L 521 lib/lua/lvm.c Protect(Arith(L, ra, rb, rb, TM_UNM)); L 543 lib/lua/lvm.c if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) L 544 lib/lua/lvm.c luaG_typeerror(L, rb, "get length of"); L 553 lib/lua/lvm.c Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); L 554 lib/lua/lvm.c setobjs2s(L, RA(i), base+b); L 558 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(i)); L 565 lib/lua/lvm.c if (equalobj(L, rb, rc) == GETARG_A(i)) L 566 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); L 573 lib/lua/lvm.c if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) L 574 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); L 581 lib/lua/lvm.c if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) L 582 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); L 589 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); L 596 lib/lua/lvm.c setobjs2s(L, ra, rb); L 597 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); L 605 lib/lua/lvm.c if (b != 0) L->top = ra+b; /* else previous instruction set top */ L 606 lib/lua/lvm.c L->savedpc = pc; L 607 lib/lua/lvm.c switch (luaD_precall(L, ra, nresults)) { L 614 lib/lua/lvm.c if (nresults >= 0) L->top = L->ci->top; L 615 lib/lua/lvm.c base = L->base; L 625 lib/lua/lvm.c if (b != 0) L->top = ra+b; /* else previous instruction set top */ L 626 lib/lua/lvm.c L->savedpc = pc; L 628 lib/lua/lvm.c switch (luaD_precall(L, ra, LUA_MULTRET)) { L 631 lib/lua/lvm.c CallInfo *ci = L->ci - 1; /* previous frame */ L 635 lib/lua/lvm.c if (L->openupval) luaF_close(L, ci->base); L 636 lib/lua/lvm.c L->base = ci->base = ci->func + ((ci+1)->base - pfunc); L 637 lib/lua/lvm.c for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ L 638 lib/lua/lvm.c setobjs2s(L, func+aux, pfunc+aux); L 639 lib/lua/lvm.c ci->top = L->top = func+aux; /* correct top */ L 640 lib/lua/lvm.c lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); L 641 lib/lua/lvm.c ci->savedpc = L->savedpc; L 643 lib/lua/lvm.c L->ci--; /* remove new frame */ L 647 lib/lua/lvm.c base = L->base; L 657 lib/lua/lvm.c if (b != 0) L->top = ra+b-1; L 658 lib/lua/lvm.c if (L->openupval) luaF_close(L, base); L 659 lib/lua/lvm.c L->savedpc = pc; L 660 lib/lua/lvm.c b = luaD_poscall(L, ra); L 664 lib/lua/lvm.c if (b) L->top = L->ci->top; L 665 lib/lua/lvm.c lua_assert(isLua(L->ci)); L 666 lib/lua/lvm.c lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); L 676 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(i)); /* jump back */ L 686 lib/lua/lvm.c L->savedpc = pc; /* next steps may throw errors */ L 688 lib/lua/lvm.c luaG_runerror(L, LUA_QL("for") " initial value must be a number"); L 690 lib/lua/lvm.c luaG_runerror(L, LUA_QL("for") " limit must be a number"); L 692 lib/lua/lvm.c luaG_runerror(L, LUA_QL("for") " step must be a number"); L 694 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(i)); L 699 lib/lua/lvm.c setobjs2s(L, cb+2, ra+2); L 700 lib/lua/lvm.c setobjs2s(L, cb+1, ra+1); L 701 lib/lua/lvm.c setobjs2s(L, cb, ra); L 702 lib/lua/lvm.c L->top = cb+3; /* func. + 2 args (state and index) */ L 703 lib/lua/lvm.c Protect(luaD_call(L, cb, GETARG_C(i))); L 704 lib/lua/lvm.c L->top = L->ci->top; L 707 lib/lua/lvm.c setobjs2s(L, cb-1, cb); /* save control variable */ L 708 lib/lua/lvm.c dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ L 719 lib/lua/lvm.c n = cast_int(L->top - ra) - 1; L 720 lib/lua/lvm.c L->top = L->ci->top; L 723 lib/lua/lvm.c runtime_check(L, ttistable(ra)); L 727 lib/lua/lvm.c luaH_resizearray(L, h, last); /* pre-alloc it at once */ L 730 lib/lua/lvm.c setobj2t(L, luaH_setnum(L, h, last--), val); L 731 lib/lua/lvm.c luaC_barriert(L, h, val); L 736 lib/lua/lvm.c luaF_close(L, ra); L 745 lib/lua/lvm.c ncl = luaF_newLclosure(L, nup, cl->env); L 752 lib/lua/lvm.c ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); L 755 lib/lua/lvm.c setclvalue(L, ra, ncl); L 756 lib/lua/lvm.c Protect(luaC_checkGC(L)); L 762 lib/lua/lvm.c CallInfo *ci = L->ci; L 765 lib/lua/lvm.c Protect(luaD_checkstack(L, n)); L 768 lib/lua/lvm.c L->top = ra + n; L 772 lib/lua/lvm.c setobjs2s(L, ra + j, ci->base - n + j); L 16 lib/lua/lvm.h #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) L 21 lib/lua/lvm.h #define equalobj(L,o1,o2) \ L 22 lib/lua/lvm.h (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) L 25 lib/lua/lvm.h LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); L 26 lib/lua/lvm.h LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); L 28 lib/lua/lvm.h LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); L 29 lib/lua/lvm.h LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, L 31 lib/lua/lvm.h LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, L 33 lib/lua/lvm.h LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); L 34 lib/lua/lvm.h LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); L 23 lib/lua/lzio.c lua_State *L = z->L; L 26 lib/lua/lzio.c lua_unlock(L); L 27 lib/lua/lzio.c buff = z->reader(L, z->data, &size); L 28 lib/lua/lzio.c lua_lock(L); L 52 lib/lua/lzio.c LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { L 53 lib/lua/lzio.c z->L = L; L 79 lib/lua/lzio.c LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { L 82 lib/lua/lzio.c luaZ_resizebuffer(L, buff, n); L 30 lib/lua/lzio.h #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) L 39 lib/lua/lzio.h #define luaZ_resizebuffer(L, buff, size) \ L 40 lib/lua/lzio.h (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ L 43 lib/lua/lzio.h #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) L 46 lib/lua/lzio.h LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); L 47 lib/lua/lzio.h LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, L 61 lib/lua/lzio.h lua_State *L; /* Lua state (for reader) */ L 76 modules/luascript.c lua_State* L; L 79 modules/luascript.c extern void register_lua_funcs( lua_State* L ); L 102 modules/luascript.c static ptp_script_msg *lua_create_usb_msg( lua_State* L, int index, unsigned msgtype) { L 107 modules/luascript.c int ltype = lua_type(L,index); L 117 modules/luascript.c ivalue = lua_toboolean(L,index); L 121 modules/luascript.c ivalue = lua_tonumber(L,index); L 125 modules/luascript.c data = (char *)lua_tolstring(L,index,&datasize); L 134 modules/luascript.c lua_getglobal(L, "usb_msg_table_to_string"); // push function L 135 modules/luascript.c lua_pushvalue(L, index); // copy specified index to top of stack L 136 modules/luascript.c result = lua_pcall(L,1,1,0); // this will leave an error message as a string on the stack if call fails L 141 modules/luascript.c luaL_error(L,lua_tostring(L,-1)); L 146 modules/luascript.c data = (char *)lua_tolstring(L,-1,&datasize); L 152 modules/luascript.c if ( !lua_isstring(L,-1) ) { L 156 modules/luascript.c data = (char *)lua_tolstring(L,-1,&datasize); L 157 modules/luascript.c lua_pop(L,1); L 162 modules/luascript.c data = (char *)lua_typename(L,ltype); // return type name as message data L 180 modules/luascript.c lua_close( L ); L 181 modules/luascript.c L = 0; L 193 modules/luascript.c static void lua_count_hook(lua_State *L, __attribute__ ((unused))lua_Debug *ar) L 196 modules/luascript.c if( L->nCcalls > L->baseCcalls || !yield_hook_enabled ) L 199 modules/luascript.c lua_yield( L, 0 ); L 248 modules/luascript.c void lua_script_finish(lua_State *L) L 252 modules/luascript.c int i,end = lua_gettop(L); L 254 modules/luascript.c ptp_script_msg *msg = lua_create_usb_msg(L,i,PTP_CHDK_S_MSGTYPE_RET); L 280 modules/luascript.c L = lua_open(); L 281 modules/luascript.c luaL_openlibs( L ); L 282 modules/luascript.c register_lua_funcs( L ); L 284 modules/luascript.c Lt = lua_newthread( L ); L 285 modules/luascript.c lua_setfield( L, LUA_REGISTRYINDEX, "Lt" ); L 361 modules/luascript.c static int lua_get_key_arg( lua_State * L, int narg ) L 363 modules/luascript.c int k = script_keyid_by_name( luaL_checkstring( L, narg ) ); L 365 modules/luascript.c luaL_error( L, "unknown key" ); L 375 modules/luascript.c static unsigned on_off_value_from_lua_arg( lua_State* L, int index) L 377 modules/luascript.c if( lua_isboolean(L,index) ) { L 378 modules/luascript.c return lua_toboolean(L,index); L 381 modules/luascript.c return luaL_checknumber(L,index); L 385 modules/luascript.c static int luaCB_set_curve_state( lua_State* L ) L 387 modules/luascript.c libcurves->curve_set_mode(luaL_checknumber( L, 1 )); L 391 modules/luascript.c static int luaCB_get_curve_state( lua_State* L ) L 393 modules/luascript.c lua_pushnumber(L,conf.curve_enable); L 397 modules/luascript.c static int luaCB_set_curve_file( lua_State* L ) L 400 modules/luascript.c const char *s = luaL_checklstring(L, 1, &l); L 405 modules/luascript.c static int luaCB_get_curve_file( lua_State* L ) L 407 modules/luascript.c lua_pushstring(L,conf.curve_file); L 411 modules/luascript.c static int luaCB_set_aelock(lua_State* L) L 413 modules/luascript.c int val = on_off_value_from_lua_arg(L, 1); L 419 modules/luascript.c static int luaCB_set_aflock(lua_State* L) L 421 modules/luascript.c int val = on_off_value_from_lua_arg(L, 1); L 427 modules/luascript.c static int luaCB_set_mf(lua_State* L) L 429 modules/luascript.c int val = on_off_value_from_lua_arg(L, 1); L 432 modules/luascript.c lua_pushnumber(L, val); L 436 modules/luascript.c static int luaCB_get_sd_over_modes( lua_State* L ) L 438 modules/luascript.c lua_pushnumber(L,sd_over_modes()); L 442 modules/luascript.c static int luaCB_shoot( lua_State* L ) L 444 modules/luascript.c action_push_shoot(luaL_optnumber( L, 1, 1 )); L 445 modules/luascript.c return lua_yield( L, 0 ); L 471 modules/luascript.c static int luaCB_sleep( lua_State* L ) L 473 modules/luascript.c int delay = sleep_delay(luaL_checknumber( L, 1 )); L 481 modules/luascript.c return lua_yield( L, 0 ); L 485 modules/luascript.c static int luaCB_keyfunc( lua_State* L ) L 487 modules/luascript.c void* func = lua_touserdata( L, lua_upvalueindex(1) ); L 488 modules/luascript.c ((void(*)(long))func)( lua_get_key_arg( L, 1 ) ); L 489 modules/luascript.c return lua_yield( L, 0 ); L 492 modules/luascript.c static int luaCB_cls( __attribute__ ((unused))lua_State* L ) L 498 modules/luascript.c static int luaCB_set_console_layout( lua_State* L ) L 500 modules/luascript.c console_set_layout(luaL_checknumber( L, 1 ),luaL_checknumber( L, 2 ),luaL_checknumber( L, 3 ),luaL_checknumber( L, 4 )); L 504 modules/luascript.c static int luaCB_set_console_autoredraw( lua_State* L ) L 506 modules/luascript.c console_set_autoredraw(luaL_checknumber( L, 1 )); L 510 modules/luascript.c static int luaCB_console_redraw( __attribute__ ((unused))lua_State* L ) L 516 modules/luascript.c static int luaCB_get_partitionInfo( lua_State* L ) L 520 modules/luascript.c lua_createtable(L, 0, 4); L 530 modules/luascript.c static int luaCB_swap_partitions( lua_State* L ) L 536 modules/luascript.c if( lua_gettop(L)==1 ) L 538 modules/luascript.c partNr = luaL_checknumber(L, 1); L 546 modules/luascript.c lua_pushboolean(L, swap_partitions(partNr)); L 552 modules/luascript.c static int luaCB_get_av96( lua_State* L ) L 554 modules/luascript.c lua_pushnumber( L, shooting_get_av96() ); L 558 modules/luascript.c static int luaCB_get_bv96( lua_State* L ) L 560 modules/luascript.c lua_pushnumber( L, shooting_get_bv96() ); L 564 modules/luascript.c static int luaCB_get_day_seconds( lua_State* L ) L 568 modules/luascript.c lua_pushnumber( L, ttm->tm_hour * 3600 + ttm->tm_min * 60 + ttm->tm_sec ); L 572 modules/luascript.c static int luaCB_get_disk_size( lua_State* L ) L 574 modules/luascript.c lua_pushnumber( L, GetTotalCardSpaceKb() ); L 578 modules/luascript.c static int luaCB_get_dofinfo( lua_State* L ) L 581 modules/luascript.c lua_createtable(L, 0, 12); L 597 modules/luascript.c static int luaCB_get_free_disk_space( lua_State* L ) L 599 modules/luascript.c lua_pushnumber( L, GetFreeCardSpaceKb() ); L 603 modules/luascript.c static int luaCB_get_focus( lua_State* L ) L 605 modules/luascript.c lua_pushnumber( L, shooting_get_subject_distance() ); L 609 modules/luascript.c static int luaCB_get_iso_market( lua_State* L ) L 611 modules/luascript.c lua_pushnumber( L, shooting_get_iso_market() ); L 615 modules/luascript.c static int luaCB_get_iso_mode( lua_State* L ) L 617 modules/luascript.c lua_pushnumber( L, shooting_get_iso_mode() ); L 621 modules/luascript.c static int luaCB_get_iso_real( lua_State* L ) L 623 modules/luascript.c lua_pushnumber( L, shooting_get_iso_real() ); L 627 modules/luascript.c static int luaCB_get_jpg_count( lua_State* L ) L 629 modules/luascript.c lua_pushnumber( L, GetJpgCount() ); L 638 modules/luascript.c static int luaCB_get_prop( lua_State* L ) L 640 modules/luascript.c lua_pushnumber( L, shooting_get_prop( luaL_checknumber( L, 1 ) ) ); L 650 modules/luascript.c static int luaCB_get_prop_str( lua_State* L ) { L 653 modules/luascript.c unsigned prop_id = luaL_checknumber( L, 1 ); L 654 modules/luascript.c size = luaL_checknumber( L, 2 ); L 657 modules/luascript.c return luaL_error( L, "malloc failed in luaCB_get_prop" ); L 660 modules/luascript.c lua_pushlstring( L, buf, size ); L 662 modules/luascript.c lua_pushboolean( L, 0); L 674 modules/luascript.c static int luaCB_get_raw_support( lua_State* L ) L 676 modules/luascript.c lua_pushboolean( L, is_raw_possible() && !camera_info.state.mode_play ); L 680 modules/luascript.c static int luaCB_get_raw_count( lua_State* L ) L 682 modules/luascript.c lua_pushnumber( L, GetRawCount() ); L 686 modules/luascript.c static int luaCB_get_sv96( lua_State* L ) L 688 modules/luascript.c lua_pushnumber( L, shooting_get_sv96_real() ); L 692 modules/luascript.c static int luaCB_get_tick_count( lua_State* L ) L 694 modules/luascript.c lua_pushnumber( L, get_tick_count() ); L 698 modules/luascript.c static int luaCB_get_exp_count( lua_State* L ) L 700 modules/luascript.c lua_pushnumber( L, get_exposure_counter() ); L 704 modules/luascript.c static int luaCB_get_image_dir( lua_State* L ) L 708 modules/luascript.c lua_pushstring( L, dir ); L 712 modules/luascript.c static int luaCB_get_tv96( lua_State* L ) L 714 modules/luascript.c lua_pushnumber( L, shooting_get_tv96() ); L 718 modules/luascript.c static int luaCB_get_user_av_id( lua_State* L ) L 720 modules/luascript.c lua_pushnumber( L, shooting_get_user_av_id() ); L 724 modules/luascript.c static int luaCB_get_user_av96( lua_State* L ) L 726 modules/luascript.c lua_pushnumber( L, shooting_get_user_av96() ); L 731 modules/luascript.c static int luaCB_get_min_av96( lua_State* L ) L 735 modules/luascript.c lua_pushnil(L); L 737 modules/luascript.c lua_pushnumber( L, av ); L 743 modules/luascript.c static int luaCB_get_max_av96( lua_State* L ) L 747 modules/luascript.c lua_pushnil(L); L 749 modules/luascript.c lua_pushnumber( L, av ); L 755 modules/luascript.c static int luaCB_get_current_av96( lua_State* L ) L 757 modules/luascript.c lua_pushnumber( L, shooting_get_current_av96() ); L 763 modules/luascript.c static int luaCB_get_current_tv96( lua_State* L ) L 767 modules/luascript.c lua_pushnil(L); L 769 modules/luascript.c lua_pushnumber( L, tv); L 775 modules/luascript.c static int luaCB_get_current_delta_sv96( lua_State* L ) L 777 modules/luascript.c lua_pushnumber( L, shooting_get_current_delta_sv96() ); L 782 modules/luascript.c static int luaCB_get_current_base_sv96( lua_State* L ) L 784 modules/luascript.c lua_pushnumber( L, shooting_get_current_base_sv96() ); L 790 modules/luascript.c static int luaCB_get_nd_value_ev96( lua_State* L ) L 792 modules/luascript.c lua_pushnumber( L, shooting_get_nd_value_ev96() ); L 797 modules/luascript.c static int luaCB_get_nd_current_ev96( lua_State* L ) L 799 modules/luascript.c lua_pushnumber( L, shooting_get_nd_current_ev96() ); L 804 modules/luascript.c static int luaCB_get_imager_active( lua_State* L ) L 806 modules/luascript.c lua_pushboolean( L, shooting_get_imager_active() ); L 811 modules/luascript.c static int luaCB_get_canon_image_format( lua_State* L ) L 813 modules/luascript.c lua_pushnumber( L, shooting_get_canon_image_format() ); L 818 modules/luascript.c static int luaCB_get_canon_raw_support( lua_State* L ) L 820 modules/luascript.c lua_pushboolean(L, camera_info.cam_canon_raw); L 824 modules/luascript.c static int luaCB_get_user_tv_id( lua_State* L ) L 826 modules/luascript.c lua_pushnumber( L, shooting_get_user_tv_id() ); L 830 modules/luascript.c static int luaCB_get_user_tv96( lua_State* L ) L 832 modules/luascript.c lua_pushnumber( L, shooting_get_user_tv96() ); L 836 modules/luascript.c static int luaCB_get_vbatt( lua_State* L ) L 838 modules/luascript.c lua_pushnumber( L, stat_get_vbatt() ); L 842 modules/luascript.c static int luaCB_get_zoom( lua_State* L ) L 844 modules/luascript.c lua_pushnumber( L, shooting_get_zoom() ); L 848 modules/luascript.c static int luaCB_get_parameter_data( lua_State* L ) L 851 modules/luascript.c unsigned id = luaL_checknumber( L, 1 ); L 862 modules/luascript.c lua_pushlstring( L, (char *)&val, size ); L 864 modules/luascript.c lua_pushnumber( L, val ); L 870 modules/luascript.c luaL_error( L, "malloc failed in luaCB_get_parameter_data" ); L 873 modules/luascript.c lua_pushlstring( L, buf, size ); L 879 modules/luascript.c static int luaCB_get_flash_params_count( lua_State* L ) L 881 modules/luascript.c lua_pushnumber( L, get_flash_params_count() ); L 885 modules/luascript.c static int luaCB_set_av96_direct( lua_State* L ) L 887 modules/luascript.c shooting_set_av96_direct( luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 891 modules/luascript.c static int luaCB_set_av96( lua_State* L ) L 893 modules/luascript.c shooting_set_av96( luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 900 modules/luascript.c static int luaCB_set_canon_image_format( lua_State* L ) L 902 modules/luascript.c lua_pushboolean( L, shooting_set_canon_image_format(luaL_checknumber( L, 1 )) ); L 906 modules/luascript.c static int luaCB_set_focus_interlock_bypass( lua_State* L ) L 908 modules/luascript.c set_focus_bypass(on_off_value_from_lua_arg( L, 1 )); L 912 modules/luascript.c static int luaCB_set_focus( lua_State* L ) L 914 modules/luascript.c int sd = luaL_checknumber( L, 1 ); L 919 modules/luascript.c lua_pushboolean(L, 0); L 935 modules/luascript.c lua_pushboolean(L, 1); L 939 modules/luascript.c static int luaCB_set_iso_mode( lua_State* L ) L 941 modules/luascript.c shooting_set_iso_mode( luaL_checknumber( L, 1 ) ); L 945 modules/luascript.c static int luaCB_set_iso_real( lua_State* L ) L 947 modules/luascript.c shooting_set_iso_real( luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 951 modules/luascript.c static int luaCB_set_led( lua_State* L ) L 954 modules/luascript.c to = luaL_checknumber( L, 1 ); L 955 modules/luascript.c to1 = luaL_checknumber( L, 2 ); L 957 modules/luascript.c if( lua_isnumber( L, 3 ) ) L 958 modules/luascript.c to2 = lua_tonumber( L, 3 ); L 963 modules/luascript.c static int luaCB_set_nd_filter( lua_State* L ) L 965 modules/luascript.c shooting_set_nd_filter_state( luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 973 modules/luascript.c static int luaCB_set_prop( lua_State* L ) L 975 modules/luascript.c shooting_set_prop(luaL_checknumber( L, 1 ), luaL_checknumber( L, 2 )); L 985 modules/luascript.c static int luaCB_set_prop_str( lua_State *L ) { L 989 modules/luascript.c prop_id = luaL_checknumber( L, 1 ); L 990 modules/luascript.c str = luaL_checklstring( L, 2, &len ); L 992 modules/luascript.c lua_pushboolean( L, (set_property_case(prop_id,(void *)str,len) == 0)); L 994 modules/luascript.c return luaL_error( L, "invalid value"); L 999 modules/luascript.c static int luaCB_set_raw_nr( lua_State* L ) L 1001 modules/luascript.c conf.raw_nr = luaL_checknumber( L, 1 ); L 1005 modules/luascript.c static int luaCB_get_raw_nr( lua_State* L ) L 1007 modules/luascript.c lua_pushnumber( L, conf.raw_nr ); L 1011 modules/luascript.c static int luaCB_set_raw( lua_State* L ) L 1013 modules/luascript.c conf.save_raw = on_off_value_from_lua_arg( L, 1 ); L 1017 modules/luascript.c static int luaCB_get_raw( lua_State* L ) L 1019 modules/luascript.c lua_pushboolean( L, conf.save_raw ); L 1023 modules/luascript.c static int luaCB_set_sv96( lua_State* L ) L 1025 modules/luascript.c shooting_set_sv96(luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 1029 modules/luascript.c static int luaCB_set_tv96_direct( lua_State* L ) L 1031 modules/luascript.c shooting_set_tv96_direct(luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 1035 modules/luascript.c static int luaCB_set_tv96( lua_State* L ) L 1037 modules/luascript.c shooting_set_tv96(luaL_checknumber( L, 1 ), shooting_in_progress()?SET_NOW:SET_LATER ); L 1041 modules/luascript.c static int luaCB_set_user_av_by_id_rel( lua_State* L ) L 1043 modules/luascript.c shooting_set_user_av_by_id_rel(luaL_checknumber( L, 1 )); L 1047 modules/luascript.c static int luaCB_set_user_av_by_id( lua_State* L ) L 1049 modules/luascript.c shooting_set_user_av_by_id(luaL_checknumber( L, 1 )); L 1053 modules/luascript.c static int luaCB_set_user_av96( lua_State* L ) L 1055 modules/luascript.c shooting_set_user_av96(luaL_checknumber( L, 1 )); L 1059 modules/luascript.c static int luaCB_set_user_tv_by_id_rel( lua_State* L ) L 1061 modules/luascript.c shooting_set_user_tv_by_id_rel(luaL_checknumber( L, 1 )); L 1065 modules/luascript.c static int luaCB_set_user_tv_by_id( lua_State* L ) L 1067 modules/luascript.c shooting_set_user_tv_by_id(luaL_checknumber( L, 1 )); L 1071 modules/luascript.c static int luaCB_set_user_tv96( lua_State* L ) L 1073 modules/luascript.c shooting_set_user_tv96(luaL_checknumber( L, 1 )); L 1077 modules/luascript.c static int luaCB_set_zoom_speed( lua_State* L ) L 1079 modules/luascript.c shooting_set_zoom_speed(luaL_checknumber( L, 1 )); L 1083 modules/luascript.c static int luaCB_set_zoom_rel( lua_State* L ) L 1085 modules/luascript.c shooting_set_zoom_rel(luaL_checknumber( L, 1 )); L 1089 modules/luascript.c static int luaCB_set_zoom( lua_State* L ) L 1091 modules/luascript.c shooting_set_zoom(luaL_checknumber( L, 1 )); L 1114 modules/luascript.c static int luaCB_wait_click( lua_State* L ) L 1116 modules/luascript.c int delay = luaL_optnumber( L, 1, 0 ); L 1133 modules/luascript.c return lua_yield( L, 0 ); L 1139 modules/luascript.c static int luaCB_is_pressed( lua_State* L ) L 1141 modules/luascript.c lua_pushboolean( L, script_key_is_pressed(lua_get_key_arg( L, 1 ))); L 1145 modules/luascript.c static int luaCB_is_key( lua_State* L ) L 1147 modules/luascript.c lua_pushboolean( L, script_key_is_clicked(lua_get_key_arg( L, 1 ))); L 1151 modules/luascript.c static int luaCB_set_exit_key( lua_State* L ) L 1154 modules/luascript.c script_set_terminate_key(lua_get_key_arg( L, 1 ),luaL_checkstring( L, 1)); L 1158 modules/luascript.c static int luaCB_wheel_right( __attribute__ ((unused))lua_State* L ) L 1164 modules/luascript.c static int luaCB_wheel_left( __attribute__ ((unused))lua_State* L ) L 1170 modules/luascript.c static int luaCB_md_af_led_control( lua_State* L ) L 1172 modules/luascript.c camera_info.perf.md_af_on_delay = luaL_checknumber( L, 1 ); L 1173 modules/luascript.c camera_info.perf.md_af_on_time = luaL_checknumber( L, 2 ); L 1185 modules/luascript.c static int luaCB_md_get_cell_diff( lua_State* L ) L 1187 modules/luascript.c lua_pushnumber( L, libmotiondetect->md_get_cell_diff(luaL_checknumber(L,1), luaL_checknumber(L,2))); L 1192 modules/luascript.c static int luaCB_md_get_cell_val( lua_State* L ) L 1194 modules/luascript.c lua_pushnumber( L, libmotiondetect->md_get_cell_val(luaL_checknumber(L,1), luaL_checknumber(L,2))); L 1198 modules/luascript.c static int luaCB_md_detect_motion( lua_State* L ) L 1200 modules/luascript.c int columns = (luaL_optnumber(L,1,6)); L 1201 modules/luascript.c int rows = (luaL_optnumber(L,2,4)); L 1202 modules/luascript.c int pixel_measure_mode = (luaL_optnumber(L,3,1)); L 1203 modules/luascript.c int detection_timeout = (luaL_optnumber(L,4,10000)); L 1204 modules/luascript.c int measure_interval = (luaL_optnumber(L,5,7)); L 1205 modules/luascript.c int threshold = (luaL_optnumber(L,6,10)); L 1206 modules/luascript.c int draw_grid = (luaL_optnumber(L,7,1)); L 1209 modules/luascript.c int clipping_region_mode = (luaL_optnumber(L,9,0)); L 1210 modules/luascript.c int clipping_region_column1 = (luaL_optnumber(L,10,0)); L 1211 modules/luascript.c int clipping_region_row1 = (luaL_optnumber(L,11,0)); L 1212 modules/luascript.c int clipping_region_column2 = (luaL_optnumber(L,12,0)); L 1213 modules/luascript.c int clipping_region_row2 = (luaL_optnumber(L,13,0)); L 1214 modules/luascript.c int parameters = (luaL_optnumber(L,14,1)); L 1215 modules/luascript.c int pixels_step = (luaL_optnumber(L,15,6)); L 1216 modules/luascript.c int msecs_before_trigger = (luaL_optnumber(L,16,0)); L 1226 modules/luascript.c return lua_yield(L, 0); L 1228 modules/luascript.c return luaL_error( L, "md_init_motion_detector failed" ); L 1253 modules/luascript.c static int luaCB_file_browser( lua_State* L ) { L 1259 modules/luascript.c libfselect->file_select(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", return_string_selected); L 1261 modules/luascript.c return lua_yield(L, 0); L 1264 modules/luascript.c static int luaCB_textbox( lua_State* L ) { L 1268 modules/luascript.c int rv = libtextbox->textbox_init((int)luaL_optstring( L, 1, "Text box" ), //title L 1269 modules/luascript.c (int)luaL_optstring( L, 2, "Enter text" ), //message L 1270 modules/luascript.c luaL_optstring( L, 3, "" ), //default string L 1271 modules/luascript.c luaL_optnumber( L, 4, 30), //max size of a text L 1282 modules/luascript.c return lua_yield(L, 0); L 1286 modules/luascript.c static int luaCB_draw_pixel( lua_State* L ) { L 1287 modules/luascript.c coord x1=luaL_checknumber(L,1); L 1288 modules/luascript.c coord y1=luaL_checknumber(L,2); L 1289 modules/luascript.c color cl=get_script_color(luaL_checknumber(L,3)); L 1294 modules/luascript.c static int luaCB_draw_line( lua_State* L ) { L 1295 modules/luascript.c coord x1=luaL_checknumber(L,1); L 1296 modules/luascript.c coord y1=luaL_checknumber(L,2); L 1297 modules/luascript.c coord x2=luaL_checknumber(L,3); L 1298 modules/luascript.c coord y2=luaL_checknumber(L,4); L 1299 modules/luascript.c color cl=get_script_color(luaL_checknumber(L,5)); L 1304 modules/luascript.c static int luaCB_draw_rect( lua_State* L ) { L 1305 modules/luascript.c coord x1=luaL_checknumber(L,1); L 1306 modules/luascript.c coord y1=luaL_checknumber(L,2); L 1307 modules/luascript.c coord x2=luaL_checknumber(L,3); L 1308 modules/luascript.c coord y2=luaL_checknumber(L,4); L 1309 modules/luascript.c color cl=get_script_color(luaL_checknumber(L,5)); L 1310 modules/luascript.c int th=luaL_optnumber(L,6,1) & RECT_BORDER_MASK; L 1315 modules/luascript.c static int luaCB_draw_rect_filled( lua_State* L ) { L 1316 modules/luascript.c coord x1 =luaL_checknumber(L,1); L 1317 modules/luascript.c coord y1 =luaL_checknumber(L,2); L 1318 modules/luascript.c coord x2 =luaL_checknumber(L,3); L 1319 modules/luascript.c coord y2 =luaL_checknumber(L,4); L 1320 modules/luascript.c color clf=get_script_color(luaL_checknumber(L,5)); L 1321 modules/luascript.c color clb=get_script_color(luaL_checknumber(L,6)); L 1322 modules/luascript.c int th =luaL_optnumber(L,7,1) & RECT_BORDER_MASK; L 1327 modules/luascript.c static int luaCB_draw_ellipse( lua_State* L ) { L 1328 modules/luascript.c coord x1=luaL_checknumber(L,1); L 1329 modules/luascript.c coord y1=luaL_checknumber(L,2); L 1330 modules/luascript.c coord a=luaL_checknumber(L,3); L 1331 modules/luascript.c coord b=luaL_checknumber(L,4); L 1332 modules/luascript.c color cl=get_script_color(luaL_checknumber(L,5)); L 1337 modules/luascript.c static int luaCB_draw_ellipse_filled( lua_State* L ) { L 1338 modules/luascript.c coord x1=luaL_checknumber(L,1); L 1339 modules/luascript.c coord y1=luaL_checknumber(L,2); L 1340 modules/luascript.c coord a=luaL_checknumber(L,3); L 1341 modules/luascript.c coord b=luaL_checknumber(L,4); L 1342 modules/luascript.c color cl=get_script_color(luaL_checknumber(L,5)); L 1347 modules/luascript.c static int luaCB_draw_string( lua_State* L ) L 1349 modules/luascript.c coord x1 = luaL_checknumber(L,1); L 1350 modules/luascript.c coord y1 = luaL_checknumber(L,2); L 1351 modules/luascript.c const char *t = luaL_checkstring( L, 3 ); L 1352 modules/luascript.c color clf = get_script_color(luaL_checknumber(L,4)); L 1353 modules/luascript.c color clb = get_script_color(luaL_checknumber(L,5)); L 1354 modules/luascript.c int xsize = luaL_optnumber(L,6,1); L 1355 modules/luascript.c int ysize = luaL_optnumber(L,7,xsize); L 1365 modules/luascript.c static int luaCB_draw_clear( __attribute__ ((unused))lua_State* L ) { L 1372 modules/luascript.c static int luaCB_get_gui_screen_width( lua_State* L ) L 1374 modules/luascript.c lua_pushnumber( L, camera_screen.width ); L 1378 modules/luascript.c static int luaCB_get_gui_screen_height( lua_State* L ) L 1380 modules/luascript.c lua_pushnumber( L, camera_screen.height ); L 1384 modules/luascript.c static int luaCB_autostarted( lua_State* L ) L 1386 modules/luascript.c lua_pushboolean( L, camera_info.state.auto_started ); L 1390 modules/luascript.c static int luaCB_get_autostart( lua_State* L ) L 1392 modules/luascript.c lua_pushnumber( L, conf.script_startup ); L 1396 modules/luascript.c static int luaCB_set_autostart( lua_State* L ) L 1399 modules/luascript.c to = luaL_checknumber( L, 1 ); L 1405 modules/luascript.c static int luaCB_get_usb_power( lua_State* L ) L 1407 modules/luascript.c lua_pushnumber( L, get_usb_power(luaL_optnumber( L, 1, 0 )) ); L 1412 modules/luascript.c static int luaCB_set_remote_timing( lua_State* L ) L 1414 modules/luascript.c int val= on_off_value_from_lua_arg(L,1); L 1416 modules/luascript.c lua_pushboolean(L,start_usb_HPtimer(val)); L 1418 modules/luascript.c lua_pushboolean(L,stop_usb_HPtimer()); L 1423 modules/luascript.c static int luaCB_usb_force_active( lua_State* L ) L 1425 modules/luascript.c lua_pushboolean(L,force_usb_state(on_off_value_from_lua_arg(L,1))); L 1430 modules/luascript.c static int luaCB_usb_sync_wait( lua_State* L ) L 1432 modules/luascript.c usb_sync_wait_flag = on_off_value_from_lua_arg(L,1); L 1436 modules/luascript.c static int luaCB_enter_alt( __attribute__ ((unused))lua_State* L ) L 1446 modules/luascript.c static int luaCB_exit_alt( __attribute__ ((unused))lua_State* L ) L 1456 modules/luascript.c static int luaCB_get_alt_mode( lua_State* L ) L 1458 modules/luascript.c lua_pushboolean(L, (camera_info.state.gui_mode != 0)); L 1463 modules/luascript.c static int luaCB_shut_down( lua_State* L ) L 1465 modules/luascript.c if ( luaL_optnumber(L,1,0) == 1 ) L 1474 modules/luascript.c static int luaCB_print_screen( lua_State* L ) L 1476 modules/luascript.c script_print_screen_statement( on_off_value_from_lua_arg( L, 1 ) ); L 1480 modules/luascript.c static int luaCB_get_movie_status( lua_State* L ) L 1482 modules/luascript.c lua_pushnumber( L, get_movie_status() ); L 1486 modules/luascript.c static int luaCB_set_movie_status( lua_State* L ) L 1488 modules/luascript.c set_movie_status( luaL_checknumber( L, 1 ) ); L 1492 modules/luascript.c static int luaCB_get_video_button( lua_State* L ) L 1494 modules/luascript.c lua_pushboolean( L, camera_info.cam_has_video_button ); L 1498 modules/luascript.c static int luaCB_get_video_recording( lua_State* L ) L 1500 modules/luascript.c lua_pushboolean( L, is_video_recording() ); L 1504 modules/luascript.c static int luaCB_get_drive_mode( lua_State* L ) L 1506 modules/luascript.c lua_pushnumber( L, shooting_get_drive_mode() ); L 1510 modules/luascript.c static int luaCB_get_focus_mode( lua_State* L ) L 1512 modules/luascript.c lua_pushnumber( L, shooting_get_real_focus_mode() ); L 1516 modules/luascript.c static int luaCB_get_focus_state( lua_State* L ) L 1518 modules/luascript.c lua_pushnumber( L, shooting_get_focus_state() ); L 1522 modules/luascript.c static int luaCB_get_focus_ok( lua_State* L ) L 1524 modules/luascript.c lua_pushboolean( L, shooting_get_focus_ok() ); L 1528 modules/luascript.c static int luaCB_get_flash_mode( lua_State* L ) L 1530 modules/luascript.c lua_pushnumber( L, shooting_get_flash_mode() ); L 1534 modules/luascript.c static int luaCB_get_shooting( lua_State* L ) L 1536 modules/luascript.c lua_pushboolean( L, shooting_in_progress() ); L 1540 modules/luascript.c static int luaCB_get_flash_ready( lua_State* L ) L 1542 modules/luascript.c lua_pushboolean( L, shooting_is_flash() ); L 1546 modules/luascript.c static int luaCB_get_IS_mode( lua_State* L ) L 1548 modules/luascript.c lua_pushnumber( L, shooting_get_is_mode() ); L 1552 modules/luascript.c static int luaCB_get_orientation_sensor( lua_State* L ) L 1554 modules/luascript.c lua_pushnumber( L, shooting_get_prop(camera_info.props.orientation_sensor) ); L 1558 modules/luascript.c static int luaCB_get_zoom_steps( lua_State* L ) L 1560 modules/luascript.c lua_pushnumber( L, zoom_points ); L 1564 modules/luascript.c static int luaCB_get_nd_present( lua_State* L ) L 1578 modules/luascript.c lua_pushnumber( L, to ); L 1582 modules/luascript.c static int luaCB_get_propset( lua_State* L ) L 1584 modules/luascript.c lua_pushnumber( L, camera_info.props.propset ); L 1588 modules/luascript.c static int luaCB_get_ev( lua_State* L ) L 1590 modules/luascript.c lua_pushnumber( L, shooting_get_ev_correction1() ); L 1594 modules/luascript.c static int luaCB_set_ev( lua_State* L ) L 1597 modules/luascript.c to = luaL_checknumber( L, 1 ); L 1603 modules/luascript.c static int luaCB_get_histo_range( lua_State* L ) L 1605 modules/luascript.c int from = (luaL_checknumber(L,1)); L 1606 modules/luascript.c int to = (luaL_checknumber(L,2)); L 1607 modules/luascript.c lua_pushnumber( L, libshothisto->shot_histogram_get_range(from, to) ); L 1611 modules/luascript.c static int luaCB_shot_histo_enable( lua_State* L ) L 1613 modules/luascript.c libshothisto->shot_histogram_set(on_off_value_from_lua_arg( L, 1 )); L 1617 modules/luascript.c static int luaCB_shot_histo_write_to_file( __attribute__ ((unused))lua_State* L ) L 1629 modules/luascript.c static int luaCB_get_live_histo( lua_State* L ) L 1633 modules/luascript.c return luaL_error(L,"malloc fail"); L 1636 modules/luascript.c lua_createtable(L, 0, 256); L 1639 modules/luascript.c lua_pushnumber(L,h[i]); L 1640 modules/luascript.c lua_rawseti(L,-2,i); L 1643 modules/luascript.c lua_pushnumber(L,total); L 1647 modules/luascript.c static int luaCB_play_sound( lua_State* L ) L 1649 modules/luascript.c play_sound(luaL_checknumber( L, 1 )); L 1653 modules/luascript.c static int luaCB_get_temperature( lua_State* L ) L 1655 modules/luascript.c int which = (luaL_checknumber( L, 1 )); L 1669 modules/luascript.c lua_pushnumber( L, temp ); L 1673 modules/luascript.c static int luaCB_get_time( lua_State* L ) L 1678 modules/luascript.c const char *t = luaL_checkstring( L, 1 ); L 1685 modules/luascript.c lua_pushnumber( L, r ); L 1698 modules/luascript.c static int luaCB_set_clock( lua_State* L ) L 1700 modules/luascript.c set_clock(luaL_checknumber(L,1), // year, like 2020 L 1701 modules/luascript.c luaL_checknumber(L,2), // month, 1-12 L 1702 modules/luascript.c luaL_checknumber(L,3), // day, 1-31 L 1703 modules/luascript.c luaL_checknumber(L,4), // hour L 1704 modules/luascript.c luaL_checknumber(L,5), // minute L 1705 modules/luascript.c luaL_checknumber(L,6)); // second L 1714 modules/luascript.c static int luaCB_peek( lua_State* L ) L 1716 modules/luascript.c unsigned addr = luaL_checknumber(L,1); L 1717 modules/luascript.c unsigned size = luaL_optnumber(L, 2, 4); L 1720 modules/luascript.c lua_pushnumber( L, *(unsigned char *)(addr) ); L 1724 modules/luascript.c lua_pushnil(L); L 1727 modules/luascript.c lua_pushnumber( L, *(unsigned short *)(addr) ); L 1732 modules/luascript.c lua_pushnil(L); L 1735 modules/luascript.c lua_pushnumber( L, *(unsigned *)(addr) ); L 1739 modules/luascript.c lua_pushnil(L); L 1751 modules/luascript.c static int luaCB_poke( lua_State* L ) L 1753 modules/luascript.c unsigned addr = luaL_checknumber(L,1); L 1754 modules/luascript.c unsigned val = luaL_checknumber(L,2); L 1755 modules/luascript.c unsigned size = luaL_optnumber(L, 3, 4); L 1776 modules/luascript.c lua_pushboolean(L,1); L 1779 modules/luascript.c lua_pushnil(L); L 1784 modules/luascript.c static int luaCB_bitand( lua_State* L ) L 1786 modules/luascript.c int v1 = (luaL_checknumber(L,1)); L 1787 modules/luascript.c int v2 = (luaL_checknumber(L,2)); L 1788 modules/luascript.c lua_pushnumber( L, v1 & v2 ); L 1792 modules/luascript.c static int luaCB_bitor( lua_State* L ) L 1794 modules/luascript.c int v1 = (luaL_checknumber(L,1)); L 1795 modules/luascript.c int v2 = (luaL_checknumber(L,2)); L 1796 modules/luascript.c lua_pushnumber( L, v1 | v2 ); L 1800 modules/luascript.c static int luaCB_bitxor( lua_State* L ) L 1802 modules/luascript.c int v1 = (luaL_checknumber(L,1)); L 1803 modules/luascript.c int v2 = (luaL_checknumber(L,2)); L 1804 modules/luascript.c lua_pushnumber( L, v1 ^ v2 ); L 1808 modules/luascript.c static int luaCB_bitshl( lua_State* L ) L 1810 modules/luascript.c int val = (luaL_checknumber(L,1)); L 1811 modules/luascript.c unsigned shift = (luaL_checknumber(L,2)); L 1812 modules/luascript.c lua_pushnumber( L, val << shift ); L 1816 modules/luascript.c static int luaCB_bitshri( lua_State* L ) L 1818 modules/luascript.c int val = (luaL_checknumber(L,1)); L 1819 modules/luascript.c unsigned shift = (luaL_checknumber(L,2)); L 1820 modules/luascript.c lua_pushnumber( L, val >> shift ); L 1824 modules/luascript.c static int luaCB_bitshru( lua_State* L ) L 1826 modules/luascript.c unsigned val = (luaL_checknumber(L,1)); L 1827 modules/luascript.c unsigned shift = (luaL_checknumber(L,2)); L 1828 modules/luascript.c lua_pushnumber( L, val >> shift ); L 1832 modules/luascript.c static int luaCB_bitnot( lua_State* L ) L 1834 modules/luascript.c unsigned val = (luaL_checknumber(L,1)); L 1835 modules/luascript.c lua_pushnumber( L, ~val ); L 1839 modules/luascript.c void set_string_field(lua_State* L, const char *key, const char *val) L 1841 modules/luascript.c lua_pushstring(L, val); L 1842 modules/luascript.c lua_setfield(L, -2, key); L 1845 modules/luascript.c void set_number_field(lua_State* L, const char *key, int val) L 1847 modules/luascript.c lua_pushnumber(L, val); L 1848 modules/luascript.c lua_setfield(L, -2, key); L 1851 modules/luascript.c static int luaCB_get_buildinfo( lua_State* L ) L 1853 modules/luascript.c lua_createtable(L, 0, 10); L 1854 modules/luascript.c set_string_field( L,"platform", camera_info.platform ); L 1855 modules/luascript.c set_string_field( L,"platsub", camera_info.platformsub ); L 1856 modules/luascript.c set_string_field( L,"version", camera_info.chdk_ver ); L 1857 modules/luascript.c set_string_field( L,"build_number", camera_info.build_number ); L 1858 modules/luascript.c set_string_field( L,"build_revision", camera_info.build_svnrev ); L 1859 modules/luascript.c set_string_field( L,"build_date", camera_info.build_date ); L 1860 modules/luascript.c set_string_field( L,"build_time", camera_info.build_time ); L 1861 modules/luascript.c set_string_field( L,"os", camera_info.os ); L 1862 modules/luascript.c set_number_field( L,"platformid", conf.platformid ); L 1863 modules/luascript.c set_number_field( L,"digic", camera_info.cam_digic ); L 1867 modules/luascript.c static int luaCB_get_mode( lua_State* L ) L 1869 modules/luascript.c lua_pushboolean( L, !camera_info.state.mode_play ); L 1870 modules/luascript.c lua_pushboolean( L, camera_info.state.mode_video ); L 1871 modules/luascript.c lua_pushnumber( L, camera_info.state.mode ); L 1876 modules/luascript.c static int luaCB_set_raw_develop( lua_State* L ) L 1878 modules/luascript.c raw_prepare_develop(luaL_optstring( L, 1, NULL ), 0); L 1882 modules/luascript.c static int luaCB_raw_merge_start( lua_State* L ) L 1884 modules/luascript.c int op = luaL_checknumber(L,1); L 1887 modules/luascript.c lua_pushboolean(L, librawop->raw_merge_start(op)); L 1891 modules/luascript.c return luaL_argerror(L,1,"invalid raw merge op"); L 1896 modules/luascript.c static int luaCB_raw_merge_add_file( lua_State* L ) L 1898 modules/luascript.c lua_pushboolean(L, librawop->raw_merge_add_file(luaL_checkstring( L, 1 ))); L 1902 modules/luascript.c static int luaCB_raw_merge_end( __attribute__ ((unused))lua_State* L ) L 1909 modules/luascript.c static int luaCB_set_backlight( lua_State* L ) L 1911 modules/luascript.c int val = on_off_value_from_lua_arg(L,1); L 1919 modules/luascript.c static int luaCB_set_lcd_display( lua_State* L ) L 1921 modules/luascript.c int val = on_off_value_from_lua_arg(L,1); L 1929 modules/luascript.c static int luaCB_set_draw_title_line( lua_State* L ) L 1931 modules/luascript.c camera_info.state.osd_title_line= on_off_value_from_lua_arg(L,1); L 1936 modules/luascript.c static int luaCB_get_draw_title_line( lua_State* L ) L 1938 modules/luascript.c lua_pushboolean( L, camera_info.state.osd_title_line ); L 1943 modules/luascript.c static unsigned levent_id_from_lua_arg( lua_State* L, int index) L 1946 modules/luascript.c if (lua_type(L, index) == LUA_TSTRING) { L 1947 modules/luascript.c const char *ev_name = lua_tostring(L, index); L 1950 modules/luascript.c return luaL_error( L, "bad event name '%s'", ev_name ); L 1955 modules/luascript.c else if (lua_type(L,index) == LUA_TNUMBER){ L 1956 modules/luascript.c event_id = lua_tonumber(L,index); L 1959 modules/luascript.c return luaL_error( L, "expected event name or id" ); L 1968 modules/luascript.c static unsigned levent_index_from_id_lua_arg( lua_State* L, int index ) L 1970 modules/luascript.c if (lua_type(L, index) == LUA_TSTRING) { L 1971 modules/luascript.c return levent_index_for_name(lua_tostring(L, index)); L 1973 modules/luascript.c else if (lua_type(L,index) == LUA_TNUMBER){ L 1974 modules/luascript.c return levent_index_for_id(lua_tonumber(L,index)); L 1977 modules/luascript.c return luaL_error( L, "expected string or number" ); L 1986 modules/luascript.c static int luaCB_get_levent_def( lua_State* L ) L 1988 modules/luascript.c unsigned event_index = levent_index_from_id_lua_arg(L,1); L 1990 modules/luascript.c lua_pushnil(L); L 1993 modules/luascript.c lua_pushstring(L, levent_table[event_index].name); L 1994 modules/luascript.c lua_pushnumber(L, levent_table[event_index].id); L 1995 modules/luascript.c lua_pushnumber(L, levent_table[event_index].param); L 2004 modules/luascript.c static int luaCB_get_levent_index( lua_State* L ) L 2006 modules/luascript.c unsigned event_index = levent_index_from_id_lua_arg(L,1); L 2008 modules/luascript.c lua_pushnil(L); L 2011 modules/luascript.c lua_pushnumber(L, event_index); L 2021 modules/luascript.c static int luaCB_get_levent_def_by_index( lua_State* L ) L 2023 modules/luascript.c unsigned i = luaL_checknumber(L,1); L 2025 modules/luascript.c lua_pushnil(L); L 2028 modules/luascript.c lua_pushstring(L, levent_table[i].name); L 2029 modules/luascript.c lua_pushnumber(L, levent_table[i].id); L 2030 modules/luascript.c lua_pushnumber(L, levent_table[i].param); L 2043 modules/luascript.c static int luaCB_post_levent_to_ui( lua_State* L ) L 2047 modules/luascript.c event_id = levent_id_from_lua_arg(L,1); L 2048 modules/luascript.c arg = luaL_optnumber(L, 2, 0); L 2053 modules/luascript.c static int luaCB_post_levent_for_npt( lua_State* L ) L 2057 modules/luascript.c event_id = levent_id_from_lua_arg(L,1); L 2058 modules/luascript.c arg = luaL_optnumber(L, 2, 0); L 2069 modules/luascript.c static int luaCB_set_levent_active( lua_State* L ) L 2074 modules/luascript.c event_id = levent_id_from_lua_arg(L,1); L 2075 modules/luascript.c state = on_off_value_from_lua_arg(L,2); L 2085 modules/luascript.c static int luaCB_set_levent_script_mode( lua_State* L ) L 2087 modules/luascript.c SetScriptMode(on_off_value_from_lua_arg(L,1)); L 2096 modules/luascript.c static int luaCB_set_capture_mode_canon( lua_State* L ) L 2098 modules/luascript.c int modenum = luaL_checknumber(L,1); L 2102 modules/luascript.c lua_pushboolean( L, shooting_set_mode_canon(modenum) ); L 2111 modules/luascript.c static int luaCB_set_capture_mode( lua_State* L ) L 2113 modules/luascript.c int modenum = luaL_checknumber(L,1); L 2114 modules/luascript.c lua_pushboolean( L, shooting_set_mode_chdk(modenum) ); L 2123 modules/luascript.c static int luaCB_is_capture_mode_valid( lua_State* L ) L 2125 modules/luascript.c int modenum = luaL_checknumber(L,1); L 2126 modules/luascript.c lua_pushboolean( L, shooting_mode_chdk2canon(modenum) != -1 ); L 2141 modules/luascript.c static int luaCB_set_record( lua_State* L ) L 2143 modules/luascript.c shooting_set_playrec_mode(on_off_value_from_lua_arg(L,1)); L 2149 modules/luascript.c static int luaCB_switch_mode_usb( lua_State* L ) L 2151 modules/luascript.c switch_mode_usb(on_off_value_from_lua_arg(L,1)); L 2165 modules/luascript.c static int luaCB_force_analog_av( lua_State* L ) L 2167 modules/luascript.c lua_pushboolean(L, kbd_force_analog_av(luaL_checknumber( L, 1 ))); L 2176 modules/luascript.c static int pack_native_args( lua_State* L, unsigned start, unsigned *argbuf) L 2179 modules/luascript.c unsigned end = lua_gettop(L); L 2182 modules/luascript.c if (lua_type(L, i) == LUA_TSTRING) { L 2183 modules/luascript.c *argbuf=(unsigned)lua_tostring( L, i); L 2185 modules/luascript.c else if (lua_type(L, i) == LUA_TNUMBER) { L 2186 modules/luascript.c *argbuf=lua_tonumber( L, i); L 2216 modules/luascript.c static int luaCB_call_func_ptr( lua_State* L) L 2221 modules/luascript.c unsigned n_args = lua_gettop(L)-1; L 2224 modules/luascript.c fptr=(void *)luaL_checknumber( L, 1 ); L 2231 modules/luascript.c return luaL_error( L, "malloc fail" ); L 2233 modules/luascript.c if(!pack_native_args(L, 2, argbuf)) L 2236 modules/luascript.c return luaL_error( L, "expected string or number" ); L 2240 modules/luascript.c lua_pushnumber( L, call_func_ptr(fptr, argbuf, n_args) ); L 2244 modules/luascript.c return luaL_error( L, "native calls disabled" ); L 2270 modules/luascript.c static int luaCB_call_event_proc( lua_State* L ) L 2276 modules/luascript.c unsigned n_args = lua_gettop(L); L 2278 modules/luascript.c evpname=luaL_checkstring( L, 1 ); L 2283 modules/luascript.c return luaL_error( L, "malloc fail" ); L 2289 modules/luascript.c if(!pack_native_args(L,2,argbuf+1)) L 2292 modules/luascript.c return luaL_error( L, "expected string or number" ); L 2295 modules/luascript.c lua_pushnumber( L, call_func_ptr(_ExecuteEventProcedure,argbuf,n_args) ); L 2299 modules/luascript.c return luaL_error( L, "native calls disabled" ); L 2307 modules/luascript.c static int luaCB_reboot( lua_State* L ) L 2309 modules/luascript.c lua_pushboolean(L, reboot(luaL_optstring( L, 1, NULL ))); L 2313 modules/luascript.c static int luaCB_get_config_value( lua_State* L ) { L 2314 modules/luascript.c unsigned int argc = lua_gettop(L); L 2320 modules/luascript.c id = luaL_checknumber(L, 1); L 2323 modules/luascript.c lua_pushnumber(L, configVal.numb); L 2326 modules/luascript.c lua_createtable(L, 0, configVal.numb); L 2328 modules/luascript.c lua_pushinteger(L, configVal.pInt[i]); L 2329 modules/luascript.c lua_rawseti(L, -2, i+1); //t[i+1]=configVal.pInt[i] L 2333 modules/luascript.c lua_pushstring(L, configVal.str); L 2336 modules/luascript.c lua_pushnumber(L, configVal.pos.x); L 2337 modules/luascript.c lua_pushnumber(L, configVal.pos.y); ret++; L 2343 modules/luascript.c lua_pushnil(L); L 2348 modules/luascript.c lua_pushnil(L); L 2353 modules/luascript.c static int luaCB_set_config_value( lua_State* L ) { L 2354 modules/luascript.c unsigned int argc = lua_gettop(L); L 2359 modules/luascript.c id = luaL_checknumber(L, 1); L 2361 modules/luascript.c switch( lua_type(L, i) ) { L 2364 modules/luascript.c configVal.numb = luaL_checknumber(L, i); L 2368 modules/luascript.c case 0: configVal.pos.x = luaL_checknumber(L, i); configVal.isPos++; break; L 2369 modules/luascript.c case 1: configVal.pos.y = luaL_checknumber(L, i); configVal.isPos++; break; L 2374 modules/luascript.c configVal.str = (char*)luaL_checkstring(L, i); L 2380 modules/luascript.c configVal.numb = lua_objlen(L, i); L 2388 modules/luascript.c lua_rawgeti(L, i, j); L 2389 modules/luascript.c configVal.pInt[j-1] = lua_tointeger(L, -1); L 2390 modules/luascript.c lua_pop(L, 1); L 2398 modules/luascript.c lua_pushboolean(L, conf_setValue(id, configVal)); L 2403 modules/luascript.c } else lua_pushboolean(L, 0); L 2407 modules/luascript.c static int luaCB_set_config_autosave( lua_State* L ) { L 2408 modules/luascript.c conf_setAutosave(on_off_value_from_lua_arg(L, 1)); L 2412 modules/luascript.c static int luaCB_save_config_file( lua_State* L ) { L 2413 modules/luascript.c lua_pushboolean(L, save_config_file(luaL_checknumber(L, 1), luaL_optstring(L, 2, NULL))); L 2417 modules/luascript.c static int luaCB_load_config_file( lua_State* L ) { L 2418 modules/luascript.c lua_pushboolean(L, load_config_file(luaL_checknumber(L, 1), luaL_optstring(L, 2, NULL))); L 2422 modules/luascript.c static int luaCB_set_file_attributes( lua_State* L ) { L 2423 modules/luascript.c lua_pushnumber(L, SetFileAttributes(luaL_checkstring(L, 1), luaL_checknumber(L, 2))); L 2468 modules/luascript.c static int luaCB_read_usb_msg( lua_State* L ) L 2470 modules/luascript.c int timeout = sleep_delay(luaL_optnumber(L,1,0)); L 2475 modules/luascript.c return lua_yield( L, 0 ); L 2480 modules/luascript.c lua_pushlstring(L,msg->data,msg->size); L 2484 modules/luascript.c lua_pushnil(L); L 2496 modules/luascript.c static int luaCB_write_usb_msg( lua_State* L ) L 2499 modules/luascript.c int timeout = sleep_delay(luaL_optnumber(L,2,0)); L 2503 modules/luascript.c if (lua_gettop(L) < 1) L 2505 modules/luascript.c return luaL_error(L,"missing argument"); L 2507 modules/luascript.c msg=lua_create_usb_msg(L,1,PTP_CHDK_S_MSGTYPE_USER); L 2512 modules/luascript.c return luaL_error(L,"unsupported type"); L 2516 modules/luascript.c return luaL_error(L,"failed to create message"); L 2523 modules/luascript.c return lua_yield( L, 0 ); L 2525 modules/luascript.c lua_pushboolean(L,ptp_script_write_msg(msg)); L 2530 modules/luascript.c static void set_meminfo_num( lua_State* L,const char *name, int val) { L 2532 modules/luascript.c set_number_field( L, name, val ); L 2563 modules/luascript.c static int luaCB_get_meminfo( lua_State* L ) { L 2564 modules/luascript.c const char *heapname = luaL_optstring( L, 1, "combined" ); L 2577 modules/luascript.c lua_pushboolean(L,0); L 2584 modules/luascript.c lua_pushboolean(L,0); L 2590 modules/luascript.c lua_pushboolean(L,0); L 2598 modules/luascript.c lua_createtable(L, 0, 13); // might not always use 13, but doesn't hurt L 2599 modules/luascript.c set_string_field( L,"name", heapname ); L 2601 modules/luascript.c lua_pushboolean( L, 1); L 2602 modules/luascript.c lua_setfield(L, -2, "chdk_malloc"); L 2603 modules/luascript.c set_number_field( L, "chdk_start", camera_info.text_start); L 2604 modules/luascript.c set_number_field( L, "chdk_size", camera_info.memisosize ); L 2605 modules/luascript.c set_meminfo_num( L, "start_address", meminfo.start_address ); L 2606 modules/luascript.c set_meminfo_num( L, "end_address", meminfo.end_address); L 2607 modules/luascript.c set_meminfo_num( L, "total_size", meminfo.total_size); L 2608 modules/luascript.c set_meminfo_num( L, "allocated_size", meminfo.allocated_size); L 2609 modules/luascript.c set_meminfo_num( L, "allocated_peak", meminfo.allocated_peak); L 2610 modules/luascript.c set_meminfo_num( L, "allocated_count", meminfo.allocated_count); L 2611 modules/luascript.c set_meminfo_num( L, "free_size", meminfo.free_size); L 2612 modules/luascript.c set_meminfo_num( L, "free_block_max_size", meminfo.free_block_max_size); L 2613 modules/luascript.c set_meminfo_num( L, "free_block_count", meminfo.free_block_count); L 2621 modules/luascript.c static int luaCB_set_yield( lua_State* L ) L 2623 modules/luascript.c lua_pushnumber(L,yield_max_count); L 2624 modules/luascript.c lua_pushnumber(L,yield_max_ms); L 2625 modules/luascript.c yield_max_count = luaL_optnumber(L,1,YIELD_MAX_COUNT_DEFAULT); L 2626 modules/luascript.c yield_max_ms = luaL_optnumber(L,2,YIELD_MAX_MS_DEFAULT); L 2638 modules/luascript.c static int luaCB_get_usb_capture_support( lua_State* L ) L 2640 modules/luascript.c lua_pushnumber(L,remotecap_get_target_support()); L 2652 modules/luascript.c static int luaCB_init_usb_capture( lua_State* L ) L 2654 modules/luascript.c int what=luaL_checknumber(L, 1); L 2655 modules/luascript.c int startline=luaL_optnumber(L, 2, 0); L 2656 modules/luascript.c int numlines=luaL_optnumber(L, 3, 0); L 2657 modules/luascript.c lua_pushboolean(L,remotecap_set_target(what,startline,numlines)); L 2665 modules/luascript.c static int luaCB_get_usb_capture_target( lua_State* L ) L 2667 modules/luascript.c lua_pushnumber(L,remotecap_get_target()); L 2683 modules/luascript.c static int luaCB_set_usb_capture_timeout( lua_State* L ) L 2685 modules/luascript.c remotecap_set_timeout(luaL_optnumber(L,1,0)); L 2692 modules/luascript.c static int luaCB_iso_to_sv96( lua_State* L ) L 2694 modules/luascript.c lua_pushnumber(L, shooting_get_sv96_from_iso(luaL_checknumber(L, 1))); L 2698 modules/luascript.c static int luaCB_sv96_to_iso( lua_State* L ) L 2700 modules/luascript.c lua_pushnumber(L, shooting_get_iso_from_sv96(luaL_checknumber(L, 1))); L 2704 modules/luascript.c static int luaCB_iso_real_to_market( lua_State* L ) L 2706 modules/luascript.c lua_pushnumber(L, shooting_iso_real_to_market(luaL_checknumber(L, 1))); L 2710 modules/luascript.c static int luaCB_iso_market_to_real( lua_State* L ) L 2712 modules/luascript.c lua_pushnumber(L, shooting_iso_market_to_real(luaL_checknumber(L, 1))); L 2716 modules/luascript.c static int luaCB_sv96_real_to_market( lua_State* L ) L 2718 modules/luascript.c lua_pushnumber(L, shooting_sv96_real_to_market(luaL_checknumber(L, 1))); L 2722 modules/luascript.c static int luaCB_sv96_market_to_real( lua_State* L ) L 2724 modules/luascript.c lua_pushnumber(L, shooting_sv96_market_to_real(luaL_checknumber(L, 1))); L 2728 modules/luascript.c static int luaCB_aperture_to_av96( lua_State* L ) L 2730 modules/luascript.c lua_pushnumber(L, shooting_get_av96_from_aperture(luaL_checknumber(L, 1))); L 2734 modules/luascript.c static int luaCB_av96_to_aperture( lua_State* L ) L 2736 modules/luascript.c lua_pushnumber(L, shooting_get_aperture_from_av96(luaL_checknumber(L, 1))); L 2740 modules/luascript.c static int luaCB_usec_to_tv96( lua_State* L ) L 2742 modules/luascript.c lua_pushnumber(L, shooting_get_tv96_from_shutter_speed((float)luaL_checknumber(L, 1)/1000000.0)); L 2746 modules/luascript.c static int luaCB_tv96_to_usec( lua_State* L ) L 2748 modules/luascript.c lua_pushnumber(L, (int)(shooting_get_shutter_speed_from_tv96(luaL_checknumber(L, 1)) * 1000000.0 + 0.5)); L 2752 modules/luascript.c static int luaCB_seconds_to_tv96( lua_State* L ) L 2754 modules/luascript.c lua_pushnumber(L, shooting_get_tv96_from_shutter_speed((float)luaL_checknumber(L, 1)/(float)luaL_checknumber(L, 2))); L 2766 modules/luascript.c static int luaCB_shoot_hook_set( lua_State* L ) L 2768 modules/luascript.c int hook = lua_tonumber( L, lua_upvalueindex(1) ); L 2769 modules/luascript.c script_shoot_hook_set(hook,luaL_checknumber(L, 1)); L 2777 modules/luascript.c static int luaCB_shoot_hook_is_ready( lua_State* L ) L 2779 modules/luascript.c int hook = lua_tonumber( L, lua_upvalueindex(1) ); L 2780 modules/luascript.c lua_pushboolean(L,script_shoot_hook_ready(hook)); L 2788 modules/luascript.c static int luaCB_shoot_hook_continue( lua_State* L ) L 2790 modules/luascript.c int hook = lua_tonumber( L, lua_upvalueindex(1) ); L 2800 modules/luascript.c static int luaCB_shoot_hook_count( lua_State* L ) L 2802 modules/luascript.c int hook = lua_tonumber( L, lua_upvalueindex(1) ); L 2803 modules/luascript.c lua_pushnumber(L,script_shoot_hook_count(hook)); L 3038 modules/luascript.c void register_shoot_hook_fn(lua_State* L, int hook, void *hook_fn, const char *name) L 3040 modules/luascript.c lua_pushnumber( L, hook ); L 3041 modules/luascript.c lua_pushcclosure( L, hook_fn, 1 ); L 3042 modules/luascript.c lua_setfield( L, -2, name); L 3045 modules/luascript.c void register_shoot_hooks( lua_State* L ) L 3049 modules/luascript.c lua_createtable(L, 0, 4); L 3050 modules/luascript.c register_shoot_hook_fn(L,i,luaCB_shoot_hook_set,"set"); L 3052 modules/luascript.c register_shoot_hook_fn(L,i,luaCB_shoot_hook_is_ready,"is_ready"); L 3053 modules/luascript.c register_shoot_hook_fn(L,i,luaCB_shoot_hook_continue,"continue"); L 3054 modules/luascript.c register_shoot_hook_fn(L,i,luaCB_shoot_hook_count,"count"); L 3055 modules/luascript.c lua_setglobal( L, shoot_hook_names[i] ); L 3059 modules/luascript.c void register_lua_funcs( lua_State* L ) L 3063 modules/luascript.c register_shoot_hooks( L ); L 3064 modules/luascript.c luaopen_rawop( L ); L 3066 modules/luascript.c lua_pushlightuserdata( L, action_push_click ); L 3067 modules/luascript.c lua_pushcclosure( L, luaCB_keyfunc, 1 ); L 3068 modules/luascript.c lua_setglobal( L, "click" ); L 3070 modules/luascript.c lua_pushlightuserdata( L, action_push_press ); L 3071 modules/luascript.c lua_pushcclosure( L, luaCB_keyfunc, 1 ); L 3072 modules/luascript.c lua_setglobal( L, "press" ); L 3074 modules/luascript.c lua_pushlightuserdata( L, action_push_release ); L 3075 modules/luascript.c lua_pushcclosure( L, luaCB_keyfunc, 1 ); L 3076 modules/luascript.c lua_setglobal( L, "release" ); L 3079 modules/luascript.c lua_pushcfunction( L, r->func ); L 3080 modules/luascript.c lua_setglobal( L, r->name ); L 3082 modules/luascript.c (void)luaL_dostring(L,"function usb_msg_table_to_string(t)" L 3114 modules/luascript.c lua_pushstring( L, name ); L 3117 modules/luascript.c lua_createtable(L, labelCount, 2); L 3121 modules/luascript.c lua_pushstring(L,labels[i]); L 3122 modules/luascript.c lua_rawseti(L,-2,i+1); L 3130 modules/luascript.c lua_pushboolean( L, value ); L 3132 modules/luascript.c lua_pushnumber( L, value ); L 3134 modules/luascript.c lua_settable( L, LUA_GLOBALSINDEX ); L 6 modules/luascript.h extern lua_State* L; L 10 modules/luascript.h lua_pushstring( L, VAL ); \ L 11 modules/luascript.h lua_setfield( L, -2, KEY ) L 14 modules/luascript.h lua_pushnumber( L, VAL ); \ L 15 modules/luascript.h lua_setfield( L, -2, KEY ) L 18 modules/luascript.h lua_pushboolean( L, VAL ); \ L 19 modules/luascript.h lua_setfield( L, -2, KEY ) L 12 modules/rawhookops.c extern void set_number_field(lua_State *L, const char *name, int value); L 44 modules/rawhookops.c static int rawop_get_cfa(lua_State *L) { L 45 modules/rawhookops.c lua_pushnumber(L,camera_sensor.cfa_pattern); L 59 modules/rawhookops.c static int rawop_get_cfa_offsets(lua_State *L) { L 60 modules/rawhookops.c lua_createtable(L, 0, 4); L 63 modules/rawhookops.c lua_createtable(L, 0, 2); L 64 modules/rawhookops.c set_number_field(L,"x",cfa_offsets[i][0]); L 65 modules/rawhookops.c set_number_field(L,"y",cfa_offsets[i][1]); L 66 modules/rawhookops.c lua_setfield(L, -2, cfa_names[i]); L 75 modules/rawhookops.c static int rawop_get_bits_per_pixel(lua_State *L) { L 76 modules/rawhookops.c lua_pushnumber(L,camera_sensor.bits_per_pixel); L 90 modules/rawhookops.c static int rawop_get_raw_neutral(lua_State *L) { L 91 modules/rawhookops.c lua_pushnumber(L,(int)raw_neutral); L 103 modules/rawhookops.c static int rawop_get_black_level(lua_State *L) { L 104 modules/rawhookops.c lua_pushnumber(L,camera_sensor.black_level); L 112 modules/rawhookops.c static int rawop_get_white_level(lua_State *L) { L 113 modules/rawhookops.c lua_pushnumber(L,camera_sensor.white_level); L 121 modules/rawhookops.c static int rawop_get_raw_width(lua_State *L) { L 122 modules/rawhookops.c lua_pushnumber(L,camera_sensor.raw_rowpix); L 130 modules/rawhookops.c static int rawop_get_raw_height(lua_State *L) { L 131 modules/rawhookops.c lua_pushnumber(L,camera_sensor.raw_rows); L 150 modules/rawhookops.c static int rawop_get_active_left(lua_State *L) { L 151 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.x1); L 159 modules/rawhookops.c static int rawop_get_active_top(lua_State *L) { L 160 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.y1); L 168 modules/rawhookops.c static int rawop_get_active_width(lua_State *L) { L 169 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.x2 - camera_sensor.active_area.x1); L 177 modules/rawhookops.c static int rawop_get_active_height(lua_State *L) { L 178 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.y2 - camera_sensor.active_area.y1); L 202 modules/rawhookops.c static int rawop_get_jpeg_left(lua_State *L) { L 203 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.x1 + camera_sensor.jpeg.x); L 211 modules/rawhookops.c static int rawop_get_jpeg_top(lua_State *L) { L 212 modules/rawhookops.c lua_pushnumber(L,camera_sensor.active_area.y1 + camera_sensor.jpeg.y); L 220 modules/rawhookops.c static int rawop_get_jpeg_width(lua_State *L) { L 221 modules/rawhookops.c lua_pushnumber(L,camera_sensor.jpeg.width); L 229 modules/rawhookops.c static int rawop_get_jpeg_height(lua_State *L) { L 230 modules/rawhookops.c lua_pushnumber(L,camera_sensor.jpeg.height); L 245 modules/rawhookops.c static int rawop_get_pixel(lua_State *L) { L 247 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 249 modules/rawhookops.c unsigned x=luaL_checknumber(L,1); L 250 modules/rawhookops.c unsigned y=luaL_checknumber(L,2); L 256 modules/rawhookops.c lua_pushnumber(L,get_raw_pixel(x,y)); L 267 modules/rawhookops.c static int rawop_set_pixel(lua_State *L) { L 269 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 271 modules/rawhookops.c unsigned int x=luaL_checknumber(L,1); L 272 modules/rawhookops.c unsigned int y=luaL_checknumber(L,2); L 273 modules/rawhookops.c unsigned short v=luaL_checknumber(L,3); L 292 modules/rawhookops.c static int rawop_get_pixels_rgbg(lua_State *L) { L 294 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 296 modules/rawhookops.c unsigned int x=luaL_checknumber(L,1); L 297 modules/rawhookops.c unsigned int y=luaL_checknumber(L,2); L 305 modules/rawhookops.c lua_pushnumber(L,get_raw_pixel(x+cfa_offsets[CFA_R][0],y+cfa_offsets[CFA_R][1])); L 306 modules/rawhookops.c lua_pushnumber(L,get_raw_pixel(x+cfa_offsets[CFA_G1][0],y+cfa_offsets[CFA_G1][1])); L 307 modules/rawhookops.c lua_pushnumber(L,get_raw_pixel(x+cfa_offsets[CFA_B][0],y+cfa_offsets[CFA_B][1])); L 308 modules/rawhookops.c lua_pushnumber(L,get_raw_pixel(x+cfa_offsets[CFA_G2][0],y+cfa_offsets[CFA_G2][1])); L 321 modules/rawhookops.c static int rawop_set_pixels_rgbg(lua_State *L) { L 323 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 325 modules/rawhookops.c unsigned int x=luaL_checknumber(L,1); L 326 modules/rawhookops.c unsigned int y=luaL_checknumber(L,2); L 327 modules/rawhookops.c unsigned short r=luaL_checknumber(L,3); L 328 modules/rawhookops.c unsigned short g1=luaL_checknumber(L,4); L 329 modules/rawhookops.c unsigned short b=luaL_checknumber(L,5); L 330 modules/rawhookops.c unsigned short g2=luaL_optnumber(L,6,g1); L 355 modules/rawhookops.c static int rawop_fill_rect(lua_State *L) { L 357 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 359 modules/rawhookops.c unsigned int xstart=luaL_checknumber(L,1); L 360 modules/rawhookops.c unsigned int ystart=luaL_checknumber(L,2); L 361 modules/rawhookops.c unsigned int width=luaL_checknumber(L,3); L 362 modules/rawhookops.c unsigned int height=luaL_checknumber(L,4); L 363 modules/rawhookops.c unsigned short val=luaL_checknumber(L,5); L 364 modules/rawhookops.c unsigned int xstep=luaL_optnumber(L,6,1); L 365 modules/rawhookops.c unsigned int ystep=luaL_optnumber(L,7,xstep); L 404 modules/rawhookops.c static int rawop_meter(lua_State *L) { L 406 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 408 modules/rawhookops.c unsigned x1=luaL_checknumber(L,1); L 409 modules/rawhookops.c unsigned y1=luaL_checknumber(L,2); L 410 modules/rawhookops.c unsigned x_count=luaL_checknumber(L,3); L 411 modules/rawhookops.c unsigned y_count=luaL_checknumber(L,4); L 412 modules/rawhookops.c unsigned x_step=luaL_checknumber(L,5); L 413 modules/rawhookops.c unsigned y_step=luaL_checknumber(L,6); L 441 modules/rawhookops.c lua_pushnumber(L,t/(x_count*y_count)); L 461 modules/rawhookops.c static int rawop_raw_to_ev(lua_State *L) { L 462 modules/rawhookops.c int v=luaL_checknumber(L,1); L 463 modules/rawhookops.c int scale=luaL_optnumber(L,2,96); L 469 modules/rawhookops.c lua_pushnumber(L,r); L 484 modules/rawhookops.c static int rawop_ev_to_raw(lua_State *L) { L 485 modules/rawhookops.c int v=luaL_checknumber(L,1); L 486 modules/rawhookops.c int scale=luaL_optnumber(L,2,96); L 488 modules/rawhookops.c lua_pushnumber(L,round_d2i(pow(2,(double)v/(double)scale+log2_raw_neutral_count)+camera_sensor.black_level)); L 506 modules/rawhookops.c static int rawop_create_histogram(lua_State *L) { L 507 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)lua_newuserdata(L,sizeof(rawop_histo_t)); L 509 modules/rawhookops.c return luaL_error(L,"failed to create userdata"); L 513 modules/rawhookops.c luaL_getmetatable(L, RAWOP_HISTO_META); L 514 modules/rawhookops.c lua_setmetatable(L, -2); L 528 modules/rawhookops.c static int rawop_histo_update(lua_State *L) { L 530 modules/rawhookops.c return luaL_error(L,"raw data not available"); L 532 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)luaL_checkudata(L,1,RAWOP_HISTO_META); L 534 modules/rawhookops.c unsigned xstart=luaL_checknumber(L,2); L 535 modules/rawhookops.c unsigned ystart=luaL_checknumber(L,3); L 536 modules/rawhookops.c unsigned width=luaL_checknumber(L,4); L 537 modules/rawhookops.c unsigned height=luaL_checknumber(L,5); L 538 modules/rawhookops.c unsigned xstep=luaL_checknumber(L,6); L 539 modules/rawhookops.c unsigned ystep=luaL_checknumber(L,7); L 540 modules/rawhookops.c int bits=luaL_optnumber(L,8,camera_sensor.bits_per_pixel); L 542 modules/rawhookops.c return luaL_error(L,"invalid bit depth"); L 552 modules/rawhookops.c luaL_error(L,"invalid update area"); L 572 modules/rawhookops.c return luaL_error(L,"insufficient memory"); L 600 modules/rawhookops.c static int rawop_histo_range(lua_State *L) { L 601 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)luaL_checkudata(L,1,RAWOP_HISTO_META); L 603 modules/rawhookops.c return luaL_error(L,"no data"); L 605 modules/rawhookops.c unsigned minval=luaL_checknumber(L,2); L 606 modules/rawhookops.c unsigned maxval=luaL_checknumber(L,3); L 608 modules/rawhookops.c if(lua_gettop(L) >= 4 && !lua_isnil(L,4)) { L 609 modules/rawhookops.c const char *s=lua_tostring(L,4); L 611 modules/rawhookops.c scale=lua_tonumber(L,4); L 614 modules/rawhookops.c return luaL_error(L,"invalid format"); L 621 modules/rawhookops.c return luaL_error(L,"invalid range"); L 625 modules/rawhookops.c return luaL_error(L,"no pixels"); L 638 modules/rawhookops.c lua_pushnumber(L,round_d2i((scale*(double)count)/(double)h->total_pixels)); L 640 modules/rawhookops.c lua_pushnumber(L,count); L 649 modules/rawhookops.c static int rawop_histo_total_pixels(lua_State *L) { L 650 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)luaL_checkudata(L,1,RAWOP_HISTO_META); L 652 modules/rawhookops.c return luaL_error(L,"no data"); L 654 modules/rawhookops.c lua_pushnumber(L,h->total_pixels); L 662 modules/rawhookops.c static int rawop_histo_bits(lua_State *L) { L 663 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)luaL_checkudata(L,1,RAWOP_HISTO_META); L 665 modules/rawhookops.c return luaL_error(L,"no data"); L 667 modules/rawhookops.c lua_pushnumber(L,h->bits); L 675 modules/rawhookops.c static int rawop_histo_free(lua_State *L) { L 676 modules/rawhookops.c rawop_histo_t *h = (rawop_histo_t *)luaL_checkudata(L,1,RAWOP_HISTO_META); L 682 modules/rawhookops.c static int rawop_histo_gc(lua_State *L) { L 683 modules/rawhookops.c rawop_histo_free(L); L 760 modules/rawhookops.c int luaopen_rawop(lua_State *L) { L 793 modules/rawhookops.c luaL_newmetatable(L,RAWOP_HISTO_META); L 794 modules/rawhookops.c luaL_register(L, NULL, rawop_histo_meta_methods); L 796 modules/rawhookops.c lua_newtable(L); L 797 modules/rawhookops.c luaL_register(L, NULL, rawop_histo_methods); L 798 modules/rawhookops.c lua_setfield(L,-2,"__index"); L 799 modules/rawhookops.c lua_pop(L,1); L 802 modules/rawhookops.c lua_newtable(L); L 803 modules/rawhookops.c luaL_register(L, "rawop", rawop_funcs); L 4 modules/rawhookops.h int luaopen_rawop(lua_State *L);