Add missing advanced usage function
This commit is contained in:
parent
318f0e3475
commit
e6018a1898
|
@ -246,3 +246,9 @@ macro_rules! __private__gmod_rs__try_chained_open {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// You don't need to use this if you are using the `#[gmod13_open]` macro.
|
||||||
|
pub unsafe fn set_lua_state(state: *mut std::ffi::c_void) {
|
||||||
|
lua::__set_state__internal(lua::State(state));
|
||||||
|
lua::load();
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ pub struct LuaSharedInterface(pub(crate) UnsafeCell<*mut LuaShared>, #[cfg(debug
|
||||||
impl LuaSharedInterface {
|
impl LuaSharedInterface {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub(crate) fn debug_assertions(&self) {
|
pub(crate) fn debug_assertions(&self) {
|
||||||
assert!(!unsafe { *self.0.get() }.is_null(), "The Lua state has not been initialized yet. Add `#[gmod::gmod13_open]` to your module's gmod13_open function to fix this. You can also manually load the Lua state with `gmod::load_lua_state()` or `gmod::set_lua_state(*mut c_void)`");
|
assert!(!unsafe { *self.0.get() }.is_null(), "The Lua state has not been initialized yet. Add `#[gmod::gmod13_open]` to your module's gmod13_open function to fix this. You can also manually set the Lua state with `gmod::set_lua_state(*mut c_void)`");
|
||||||
|
|
||||||
let thread_id = u64::from(std::thread::current().id().as_u64()) as i64;
|
let thread_id = u64::from(std::thread::current().id().as_u64()) as i64;
|
||||||
match self.1.compare_exchange(-1, thread_id, std::sync::atomic::Ordering::SeqCst, std::sync::atomic::Ordering::SeqCst) {
|
match self.1.compare_exchange(-1, thread_id, std::sync::atomic::Ordering::SeqCst, std::sync::atomic::Ordering::SeqCst) {
|
||||||
|
|
Loading…
Reference in New Issue