@@ -79,12 +79,13 @@ pub type lua_Unsigned = c_uint;
7979pub type lua_CFunction = unsafe extern "C-unwind" fn ( L : * mut lua_State ) -> c_int ;
8080pub type lua_Continuation = unsafe extern "C-unwind" fn ( L : * mut lua_State , status : c_int ) -> c_int ;
8181
82- /// Type for userdata destructor functions (no unwinding).
83- pub type lua_Destructor = unsafe extern "C" fn ( L : * mut lua_State , * mut c_void ) ;
82+ /// Type for userdata destructor functions.
83+ pub type lua_Udestructor = unsafe extern "C-unwind" fn ( * mut c_void ) ;
84+ pub type lua_Destructor = unsafe extern "C-unwind" fn ( L : * mut lua_State , * mut c_void ) ;
8485
85- /// Type for memory-allocation functions (no unwinding) .
86+ /// Type for memory-allocation functions.
8687pub type lua_Alloc =
87- unsafe extern "C" fn ( ud : * mut c_void , ptr : * mut c_void , osize : usize , nsize : usize ) -> * mut c_void ;
88+ unsafe extern "C-unwind " fn ( ud : * mut c_void , ptr : * mut c_void , osize : usize , nsize : usize ) -> * mut c_void ;
8889
8990/// Returns Luau release version (eg. `0.xxx`).
9091pub const fn luau_version ( ) -> Option < & ' static str > {
@@ -185,7 +186,7 @@ extern "C-unwind" {
185186 pub fn lua_pushlightuserdatatagged ( L : * mut lua_State , p : * mut c_void , tag : c_int ) ;
186187 pub fn lua_newuserdatatagged ( L : * mut lua_State , sz : usize , tag : c_int ) -> * mut c_void ;
187188 pub fn lua_newuserdatataggedwithmetatable ( L : * mut lua_State , sz : usize , tag : c_int ) -> * mut c_void ;
188- pub fn lua_newuserdatadtor ( L : * mut lua_State , sz : usize , dtor : lua_Destructor ) -> * mut c_void ;
189+ pub fn lua_newuserdatadtor ( L : * mut lua_State , sz : usize , dtor : lua_Udestructor ) -> * mut c_void ;
189190
190191 pub fn lua_newbuffer ( L : * mut lua_State , sz : usize ) -> * mut c_void ;
191192
@@ -284,7 +285,7 @@ extern "C-unwind" {
284285 pub fn lua_setuserdatatag ( L : * mut lua_State , idx : c_int , tag : c_int ) ;
285286 pub fn lua_setuserdatadtor ( L : * mut lua_State , tag : c_int , dtor : Option < lua_Destructor > ) ;
286287 pub fn lua_getuserdatadtor ( L : * mut lua_State , tag : c_int ) -> Option < lua_Destructor > ;
287- pub fn lua_setuserdatametatable ( L : * mut lua_State , tag : c_int ) ;
288+ pub fn lua_setuserdatametatable ( L : * mut lua_State , tag : c_int , idx : c_int ) ;
288289 pub fn lua_getuserdatametatable ( L : * mut lua_State , tag : c_int ) ;
289290 pub fn lua_setlightuserdataname ( L : * mut lua_State , tag : c_int , name : * const c_char ) ;
290291 pub fn lua_getlightuserdataname ( L : * mut lua_State , tag : c_int ) -> * const c_char ;
@@ -339,14 +340,12 @@ pub unsafe fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut c_void {
339340}
340341
341342#[ inline( always) ]
342- pub unsafe fn lua_newuserdata_t < T > ( L : * mut lua_State , data : T ) -> * mut T {
343- unsafe extern "C" fn destructor < T > ( _ : * mut lua_State , ud : * mut c_void ) {
343+ pub unsafe fn lua_newuserdata_t < T > ( L : * mut lua_State ) -> * mut T {
344+ unsafe extern "C-unwind " fn destructor < T > ( ud : * mut c_void ) {
344345 ptr:: drop_in_place ( ud as * mut T ) ;
345346 }
346347
347- let ud_ptr = lua_newuserdatadtor ( L , const { mem:: size_of :: < T > ( ) } , destructor :: < T > ) as * mut T ;
348- ptr:: write ( ud_ptr, data) ;
349- ud_ptr
348+ lua_newuserdatadtor ( L , mem:: size_of :: < T > ( ) , destructor :: < T > ) as * mut T
350349}
351350
352351// TODO: lua_strlen
0 commit comments