From 87d25a2205b84b48a6f1effaef07a9a33f6ec7f2 Mon Sep 17 00:00:00 2001 From: William Venner Date: Fri, 28 Jan 2022 16:08:52 +0000 Subject: [PATCH] Bind lua_equal --- Cargo.lock | 2 +- gmod/Cargo.toml | 2 +- gmod/src/lua/import.rs | 2 ++ gmod/src/lua/lua_state.rs | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52923da..de11b36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "gmod" -version = "14.0.1" +version = "14.0.2" dependencies = [ "cfg_table", "cstr", diff --git a/gmod/Cargo.toml b/gmod/Cargo.toml index d8109ef..9ce8baf 100644 --- a/gmod/Cargo.toml +++ b/gmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gmod" -version = "14.0.1" +version = "14.0.2" authors = ["William Venner "] edition = "2021" license = "MIT" diff --git a/gmod/src/lua/import.rs b/gmod/src/lua/import.rs index 18ca640..6573a35 100644 --- a/gmod/src/lua/import.rs +++ b/gmod/src/lua/import.rs @@ -173,6 +173,7 @@ pub struct LuaShared { pub lua_tothread: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32) -> LuaState>, pub lua_status: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState) -> i32>, pub lua_xmove: Symbol<'static, unsafe extern "C-unwind" fn(thread1: LuaState, thread2: LuaState, n: i32)>, + pub lua_equal: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index1: i32, index2: i32) -> i32>, } unsafe impl Sync for LuaShared {} impl LuaShared { @@ -247,6 +248,7 @@ impl LuaShared { lua_tothread: find_symbol!("lua_tothread"), lua_status: find_symbol!("lua_status"), lua_xmove: find_symbol!("lua_xmove"), + lua_equal: find_symbol!("lua_equal"), } } } diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 6befe58..0071b94 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -511,6 +511,11 @@ impl LuaState { (LUA_SHARED.lua_xmove)(*self, target_thread, n) } + #[inline(always)] + pub unsafe fn equal(&self, index1: i32, index2: i32) -> bool { + (LUA_SHARED.lua_equal)(*self, index1, index2) == 1 + } + #[inline(always)] /// See `call` pub unsafe fn coroutine_resume_call(&self, narg: i32) {