luaur_vm/functions/
lua_cleartable.rs1use crate::functions::index_2_addr::index2addr;
2use crate::functions::lua_g_readonlyerror::lua_g_readonlyerror;
3use crate::functions::lua_h_clear::lua_h_clear;
4use crate::macros::api_check::api_check;
5use crate::macros::hvalue::hvalue;
6use crate::macros::ttistable::ttistable;
7use crate::type_aliases::lua_state::lua_State;
8use crate::type_aliases::stk_id::StkId;
9
10#[allow(non_snake_case)]
11pub unsafe fn lua_cleartable(L: *mut lua_State, idx: core::ffi::c_int) {
12 let t: StkId = index2addr(L, idx);
13 api_check!(L, ttistable!(t));
14 let tt = hvalue!(t);
15 if (*tt).readonly != 0 {
16 lua_g_readonlyerror(L);
17 }
18 lua_h_clear(tt);
19}