From 64ade67496750898eb382895ce82f651bc0c748a Mon Sep 17 00:00:00 2001 From: William Venner Date: Thu, 7 Jul 2022 18:18:50 +0100 Subject: [PATCH] Add `push_closure` --- Cargo.lock | 2 +- gmod/Cargo.toml | 2 +- gmod/src/lua/lua_state.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b8b9ff..cc02e09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "gmod" -version = "15.0.1" +version = "15.0.2" dependencies = [ "cfg_table", "cstr", diff --git a/gmod/Cargo.toml b/gmod/Cargo.toml index 01c8875..bf4d350 100644 --- a/gmod/Cargo.toml +++ b/gmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gmod" -version = "15.0.1" +version = "15.0.2" authors = ["William Venner "] edition = "2021" license = "MIT" diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 5a18173..66b83cf 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -315,6 +315,12 @@ impl LuaState { (LUA_SHARED.lua_pushcclosure)(*self, func, 0) } + #[inline(always)] + pub unsafe fn push_closure(&self, func: LuaFunction, n: i32) { + debug_assert!(n <= 255, "Can't push more than 255 arguments into a closure"); + (LUA_SHARED.lua_pushcclosure)(*self, func, n) + } + #[inline(always)] pub unsafe fn set_table(&self, index: i32) { (LUA_SHARED.lua_settable)(*self, index)