mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Switch back to Luau userdata destructors defined in mlua-sys v0.6
This commit is contained in:
+1
-11
@@ -437,18 +437,8 @@ pub(crate) unsafe extern "C-unwind" fn collect_userdata<T>(state: *mut ffi::lua_
|
||||
|
||||
// This method is called by Luau GC when it's time to collect the userdata.
|
||||
#[cfg(feature = "luau")]
|
||||
pub(crate) unsafe extern "C" fn collect_userdata<T>(
|
||||
state: *mut ffi::lua_State,
|
||||
ud: *mut std::os::raw::c_void,
|
||||
) {
|
||||
// Almost none Lua operations are allowed when destructor is running,
|
||||
// so we need to set a flag to prevent calling any Lua functions
|
||||
let extra = (*ffi::lua_callbacks(state)).userdata as *mut crate::state::ExtraData;
|
||||
(*extra).running_userdata_gc = true;
|
||||
// Luau does not support _any_ panics in destructors (they are declared as "C", NOT as "C-unwind"),
|
||||
// so any panics will trigger `abort()`.
|
||||
pub(crate) unsafe extern "C-unwind" fn collect_userdata<T>(ud: *mut std::os::raw::c_void) {
|
||||
ptr::drop_in_place(ud as *mut T);
|
||||
(*extra).running_userdata_gc = false;
|
||||
}
|
||||
|
||||
// This method can be called by user or Lua GC to destroy the userdata.
|
||||
|
||||
Reference in New Issue
Block a user