luaur_vm/functions/
lua_h_getp.rs1use crate::functions::hashpointer::hashpointer;
2use crate::functions::lua_a_toobject::luaO_nilobject;
3use crate::macros::gkey::gkey;
4use crate::macros::lightuserdatatag::lightuserdatatag;
5use crate::macros::pvalue::pvalue;
6use crate::macros::ttislightuserdata::ttislightuserdata;
7use crate::records::lua_node::LuaNode;
8use crate::records::lua_table::LuaTable;
9use crate::type_aliases::t_value::TValue;
10
11#[allow(non_snake_case)]
12pub unsafe fn lua_h_getp(t: *mut LuaTable, key: *mut core::ffi::c_void, tag: i32) -> *const TValue {
13 let mut n: *mut LuaNode = hashpointer(t as *const _, key);
14 loop {
15 let nk = gkey!(n);
16 if ttislightuserdata!(nk) && pvalue!(nk) == key && lightuserdatatag!(nk) == tag {
17 return &(*n).val;
18 }
19 let next_offset = (*n).key.next();
20 if next_offset == 0 {
21 break;
22 }
23 n = n.offset(next_offset as isize);
24 }
25 luaO_nilobject
26}
27
28pub use lua_h_getp as luaH_getp;