luaur_vm/functions/
lua_rawgeti.rs1use core::ffi::c_int;
2
3use crate::functions::index_2_addr::index2addr;
4use crate::functions::lua_concat::lua_c_threadbarrier_lapi;
5use crate::functions::lua_h_getnum::lua_h_getnum;
6use crate::macros::api_check::api_check;
7use crate::macros::api_incr_top::api_incr_top;
8use crate::macros::hvalue::hvalue;
9use crate::macros::setobj_2_s::setobj2s;
10use crate::macros::ttistable::ttistable;
11use crate::macros::ttype::ttype;
12use crate::records::lua_state::lua_State;
13use crate::type_aliases::stk_id::StkId;
14
15#[allow(non_snake_case)]
16pub unsafe fn lua_rawgeti(L: *mut lua_State, idx: c_int, n: c_int) -> c_int {
17 lua_c_threadbarrier_lapi(L);
18
19 let t: StkId = index2addr(L, idx);
20 api_check!(L, ttistable!(t));
21
22 setobj2s!(L, (*L).top, lua_h_getnum(hvalue!(t), n));
23 api_incr_top!(L);
24
25 ttype!((*L).top.sub(1))
26}