File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -888,16 +888,17 @@ impl AnyUserData {
888
888
self . raw_metatable ( ) . map ( UserDataMetatable )
889
889
}
890
890
891
+ /// Returns a raw metatable of this [`AnyUserData`].
891
892
fn raw_metatable ( & self ) -> Result < Table > {
892
893
let lua = self . 0 . lua . lock ( ) ;
893
- let state = lua. state ( ) ;
894
+ let ref_thread = lua. ref_thread ( ) ;
894
895
unsafe {
895
- let _sg = StackGuard :: new ( state) ;
896
- check_stack ( state, 3 ) ?;
896
+ // Check that userdata is registered and not destructed
897
+ // All registered userdata types have a non-empty metatable
898
+ let _type_id = lua. get_userdata_ref_type_id ( & self . 0 ) ?;
897
899
898
- lua. push_userdata_ref ( & self . 0 ) ?;
899
- ffi:: lua_getmetatable ( state, -1 ) ; // Checked that non-empty on the previous call
900
- Ok ( Table ( lua. pop_ref ( ) ) )
900
+ ffi:: lua_getmetatable ( ref_thread, self . 0 . index ) ;
901
+ Ok ( Table ( lua. pop_ref_thread ( ) ) )
901
902
}
902
903
}
903
904
You can’t perform that action at this time.
0 commit comments