luaur_vm/functions/
lua_next.rs1use core::ffi::c_int;
5
6use crate::functions::index_2_addr::index2addr;
7use crate::functions::lua_concat::lua_c_threadbarrier_lapi;
8use crate::functions::lua_h_next::lua_h_next;
9use crate::macros::api_check::api_check;
10use crate::macros::api_checknelems::api_checknelems;
11use crate::macros::api_incr_top::api_incr_top;
12use crate::macros::hvalue::hvalue;
13use crate::macros::ttistable::ttistable;
14use crate::type_aliases::lua_state::lua_State;
15use crate::type_aliases::stk_id::StkId;
16
17#[allow(non_snake_case)]
18pub unsafe fn lua_next(L: *mut lua_State, idx: c_int) -> c_int {
19 api_checknelems!(L, 1);
20 lua_c_threadbarrier_lapi(L);
21 let t: StkId = index2addr(L, idx);
22 api_check!(L, ttistable!(t));
23
24 let more = lua_h_next(L, hvalue!(t), (*L).top.sub(1));
25 if more != 0 {
26 api_incr_top!(L);
27 } else {
28 (*L).top = (*L).top.sub(1);
29 }
30 more
31}