| 524 | |
| 525 | |
| 526 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { |
| 527 | lua_lock(L); |
| 528 | if (n == 0) { |
| 529 | setfvalue(L->top, fn); |
| 530 | } |
| 531 | else { |
| 532 | CClosure *cl; |
| 533 | api_checknelems(L, n); |
| 534 | api_check(n <= MAXUPVAL, "upvalue index too large"); |
| 535 | luaC_checkGC(L); |
| 536 | cl = luaF_newCclosure(L, n); |
| 537 | cl->f = fn; |
| 538 | L->top -= n; |
| 539 | while (n--) { |
| 540 | setobj2n(L, &cl->upvalue[n], L->top + n); |
| 541 | /* does not need barrier because closure is white */ |
| 542 | } |
| 543 | setclCvalue(L, L->top, cl); |
| 544 | } |
| 545 | api_incr_top(L); |
| 546 | lua_unlock(L); |
| 547 | } |
| 548 | |
| 549 | |
| 550 | LUA_API void lua_pushboolean (lua_State *L, int b) { |
no test coverage detected