Add `lua_topointer`

This commit is contained in:
William Venner 2021-10-10 19:59:54 +01:00
parent eea1e4b15d
commit d1413ea013
2 changed files with 7 additions and 0 deletions

View File

@ -124,6 +124,7 @@ pub(crate) struct LuaShared {
pub lua_getinfo: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, what: LuaString, ar: *mut LuaDebug) -> i32>,
pub lua_getstack: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, level: i32, ar: *mut LuaDebug) -> i32>,
pub lua_next: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32) -> i32>,
pub lua_topointer: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32) -> *const c_void>,
}
unsafe impl Sync for LuaShared {}
impl LuaShared {
@ -188,6 +189,7 @@ impl LuaShared {
lua_getinfo: find_symbol!("lua_getinfo"),
lua_getstack: find_symbol!("lua_getstack"),
lua_next: find_symbol!("lua_next"),
lua_topointer: find_symbol!("lua_topointer")
}
}
}

View File

@ -381,6 +381,11 @@ impl LuaState {
(LUA_SHARED.lua_next)(*self, index)
}
#[inline]
pub unsafe fn to_pointer(&self, index: i32) -> *const c_void {
(LUA_SHARED.lua_topointer)(*self, index)
}
pub unsafe fn error<S: AsRef<str>>(&self, msg: S) -> ! {
self.push_string(msg.as_ref());
(LUA_SHARED.lua_error)(*self);