Skip to main content

luaur_vm/functions/
lua_rawget.rs

1use 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_get::lua_h_get;
6use crate::macros::api_check::api_check;
7use crate::macros::hvalue::hvalue;
8use crate::macros::setobj_2_s::setobj2s;
9use crate::macros::ttistable::ttistable;
10use crate::macros::ttype::ttype;
11use crate::records::lua_state::lua_State;
12use crate::type_aliases::stk_id::StkId;
13
14#[allow(non_snake_case)]
15pub unsafe fn lua_rawget(L: *mut lua_State, idx: c_int) -> c_int {
16    lua_c_threadbarrier_lapi(L);
17
18    let t: StkId = index2addr(L, idx);
19    api_check!(L, ttistable!(t));
20
21    let slot = (*L).top.sub(1);
22    setobj2s!(L, slot, lua_h_get(hvalue!(t), slot));
23
24    ttype!((*L).top.sub(1))
25}