From 6fb845afbe27046d58eb6bc54e5ceb7dcd33571e Mon Sep 17 00:00:00 2001 From: William Venner Date: Sat, 18 Sep 2021 19:33:54 +0100 Subject: [PATCH] check_userdata now returns a *mut UserData C struct ptr --- gmod/src/lua/lua_state.rs | 5 ++--- gmod/src/lua/mod.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index bc08af0..ff42307 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -7,7 +7,6 @@ use crate::lua::*; pub struct LuaState(pub *mut std::ffi::c_void); unsafe impl Send for LuaState {} impl LuaState { - /// Returns the Lua string as a slice of bytes. /// /// **WARNING:** This will CHANGE the type of the value at the given index to a string. @@ -272,8 +271,8 @@ impl LuaState { } #[inline] - pub unsafe fn check_userdata(&self, arg: i32, name: LuaString) -> *mut c_void { - (LUA_SHARED.lual_checkudata)(*self, arg, name) + pub unsafe fn check_userdata(&self, arg: i32, name: LuaString) -> *mut UserData { + (LUA_SHARED.lual_checkudata)(*self, arg, name) as *mut _ } pub unsafe fn test_userdata(&self, index: i32, name: LuaString) -> bool { diff --git a/gmod/src/lua/mod.rs b/gmod/src/lua/mod.rs index 66c898e..95dfa2d 100644 --- a/gmod/src/lua/mod.rs +++ b/gmod/src/lua/mod.rs @@ -6,6 +6,14 @@ pub use import::*; mod lua_state; pub use lua_state::LuaState as State; +#[repr(C)] +#[derive(Debug)] +pub struct UserData +{ + data: *mut core::ffi::c_void, + r#type: u8 +} + #[derive(Debug, Clone)] pub enum LuaError { /// Out of memory