** precall for C functions */
| 640 | ** precall for C functions |
| 641 | */ |
| 642 | l_sinline int precallC (lua_State *L, StkId func, unsigned status, |
| 643 | lua_CFunction f) { |
| 644 | int n; /* number of returns */ |
| 645 | CallInfo *ci; |
| 646 | checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ |
| 647 | L->ci = ci = prepCallInfo(L, func, status | CIST_C, |
| 648 | L->top.p + LUA_MINSTACK); |
| 649 | lua_assert(ci->top.p <= L->stack_last.p); |
| 650 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { |
| 651 | int narg = cast_int(L->top.p - func) - 1; |
| 652 | luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); |
| 653 | } |
| 654 | lua_unlock(L); |
| 655 | n = (*f)(L); /* do the actual call */ |
| 656 | lua_lock(L); |
| 657 | api_checknelems(L, n); |
| 658 | luaD_poscall(L, ci, n); |
| 659 | return n; |
| 660 | } |
| 661 | |
| 662 | |
| 663 | /* |
no test coverage detected