From d1413ea013ff7ee92ea935ad7e3a3460dda3cf05 Mon Sep 17 00:00:00 2001 From: William Venner Date: Sun, 10 Oct 2021 19:59:54 +0100 Subject: [PATCH] Add `lua_topointer` --- gmod/src/lua/import.rs | 2 ++ gmod/src/lua/lua_state.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/gmod/src/lua/import.rs b/gmod/src/lua/import.rs index c2767e9..979f534 100644 --- a/gmod/src/lua/import.rs +++ b/gmod/src/lua/import.rs @@ -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") } } } diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 7534373..75f7544 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -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>(&self, msg: S) -> ! { self.push_string(msg.as_ref()); (LUA_SHARED.lua_error)(*self);