Skip to main content

luaur_vm/functions/
lua_rawsetptagged.rs

1use crate::functions::index_2_addr::index2addr;
2use crate::functions::lua_g_readonlyerror::lua_g_readonlyerror;
3use crate::functions::lua_h_setp::lua_h_setp;
4use crate::macros::api_check::api_check;
5use crate::macros::api_checknelems::api_checknelems;
6use crate::macros::hvalue::hvalue;
7use crate::macros::lua_c_barriert::luaC_barriert;
8use crate::macros::setobj_2_t::setobj2t;
9use crate::macros::ttistable::ttistable;
10use crate::type_aliases::lua_state::lua_State;
11use crate::type_aliases::stk_id::StkId;
12
13#[allow(non_snake_case)]
14pub unsafe fn lua_rawsetptagged(
15    L: *mut lua_State,
16    idx: core::ffi::c_int,
17    p: *mut core::ffi::c_void,
18    tag: core::ffi::c_int,
19) {
20    api_checknelems!(L, 1);
21    let o: StkId = index2addr(L, idx);
22    api_check!(L, ttistable!(o));
23    if (*hvalue!(o)).readonly != 0 {
24        lua_g_readonlyerror(L);
25    }
26    let val = (*L).top.offset(-1);
27    setobj2t!(L, lua_h_setp(L, hvalue!(o), p, tag), val);
28    luaC_barriert!(L, hvalue!(o), val);
29    (*L).top = (*L).top.offset(-1);
30}