@@ -73,8 +73,8 @@ pub(crate) struct LuaGuard(ArcReentrantMutexGuard<RawLua>);
7373#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
7474pub enum GCMode {
7575 Incremental ,
76- #[ cfg( feature = "lua54" ) ]
77- #[ cfg_attr( docsrs, doc( cfg( feature = "lua54" ) ) ) ]
76+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
77+ #[ cfg_attr( docsrs, doc( cfg( any ( feature = "lua55" , feature = " lua54") ) ) ) ]
7878 Generational ,
7979}
8080
@@ -249,7 +249,7 @@ impl Lua {
249249 ffi:: luaL_loadstring as _ ,
250250 ffi:: luaL_openlibs as _ ,
251251 ] ) ;
252- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) ]
252+ #[ cfg( any( feature = "lua55" , feature = " lua54", feature = "lua53" , feature = "lua52" ) ) ]
253253 {
254254 _symbols. push ( ffi:: lua_getglobal as _ ) ;
255255 _symbols. push ( ffi:: lua_setglobal as _ ) ;
@@ -382,7 +382,7 @@ impl Lua {
382382 #[ cfg( not( feature = "luau" ) ) ]
383383 #[ cfg_attr( docsrs, doc( cfg( not( feature = "luau" ) ) ) ) ]
384384 pub fn preload_module ( & self , modname : & str , func : Function ) -> Result < ( ) > {
385- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) ]
385+ #[ cfg( any( feature = "lua55" , feature = " lua54", feature = "lua53" , feature = "lua52" ) ) ]
386386 let preload = unsafe {
387387 self . exec_raw :: < Option < Table > > ( ( ) , |state| {
388388 ffi:: lua_getfield ( state, ffi:: LUA_REGISTRYINDEX , ffi:: LUA_PRELOAD_TABLE ) ;
@@ -814,8 +814,8 @@ impl Lua {
814814 }
815815
816816 /// Sets the warning function to be used by Lua to emit warnings.
817- #[ cfg( feature = "lua54" ) ]
818- #[ cfg_attr( docsrs, doc( cfg( feature = "lua54" ) ) ) ]
817+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
818+ #[ cfg_attr( docsrs, doc( cfg( any ( feature = "lua55" , feature = " lua54") ) ) ) ]
819819 pub fn set_warning_function < F > ( & self , callback : F )
820820 where
821821 F : Fn ( & Lua , & str , bool ) -> Result < ( ) > + MaybeSend + ' static ,
@@ -847,8 +847,8 @@ impl Lua {
847847 /// Removes warning function previously set by `set_warning_function`.
848848 ///
849849 /// This function has no effect if a warning function was not previously set.
850- #[ cfg( feature = "lua54" ) ]
851- #[ cfg_attr( docsrs, doc( cfg( feature = "lua54" ) ) ) ]
850+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
851+ #[ cfg_attr( docsrs, doc( cfg( any ( feature = "lua55" , feature = " lua54") ) ) ) ]
852852 pub fn remove_warning_function ( & self ) {
853853 let lua = self . lock ( ) ;
854854 unsafe {
@@ -861,8 +861,8 @@ impl Lua {
861861 ///
862862 /// A message in a call with `incomplete` set to `true` should be continued in
863863 /// another call to this function.
864- #[ cfg( feature = "lua54" ) ]
865- #[ cfg_attr( docsrs, doc( cfg( feature = "lua54" ) ) ) ]
864+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
865+ #[ cfg_attr( docsrs, doc( cfg( any ( feature = "lua55" , feature = " lua54") ) ) ) ]
866866 pub fn warning ( & self , msg : impl AsRef < str > , incomplete : bool ) {
867867 let msg = msg. as_ref ( ) ;
868868 let mut bytes = vec ! [ 0 ; msg. len( ) + 1 ] ;
@@ -954,7 +954,13 @@ impl Lua {
954954 }
955955
956956 /// Returns `true` if the garbage collector is currently running automatically.
957- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" , feature = "luau" ) ) ]
957+ #[ cfg( any(
958+ feature = "lua55" ,
959+ feature = "lua54" ,
960+ feature = "lua53" ,
961+ feature = "lua52" ,
962+ feature = "luau"
963+ ) ) ]
958964 pub fn gc_is_running ( & self ) -> bool {
959965 let lua = self . lock ( ) ;
960966 unsafe { ffi:: lua_gc ( lua. main_state ( ) , ffi:: LUA_GCISRUNNING , 0 ) != 0 }
@@ -1019,8 +1025,12 @@ impl Lua {
10191025 let lua = self . lock ( ) ;
10201026 let state = lua. main_state ( ) ;
10211027 unsafe {
1022- #[ cfg( not( feature = "luau" ) ) ]
1028+ #[ cfg( feature = "lua55" ) ]
1029+ return ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPPAUSE , pause) ;
1030+
1031+ #[ cfg( not( any( feature = "lua55" , feature = "luau" ) ) ) ]
10231032 return ffi:: lua_gc ( state, ffi:: LUA_GCSETPAUSE , pause) ;
1033+
10241034 #[ cfg( feature = "luau" ) ]
10251035 return ffi:: lua_gc ( state, ffi:: LUA_GCSETGOAL , pause) ;
10261036 }
@@ -1034,7 +1044,18 @@ impl Lua {
10341044 /// [documentation]: https://www.lua.org/manual/5.4/manual.html#2.5
10351045 pub fn gc_set_step_multiplier ( & self , step_multiplier : c_int ) -> c_int {
10361046 let lua = self . lock ( ) ;
1037- unsafe { ffi:: lua_gc ( lua. main_state ( ) , ffi:: LUA_GCSETSTEPMUL , step_multiplier) }
1047+ unsafe {
1048+ #[ cfg( feature = "lua55" ) ]
1049+ return ffi:: lua_gc (
1050+ lua. main_state ( ) ,
1051+ ffi:: LUA_GCPARAM ,
1052+ ffi:: LUA_GCPSTEPMUL ,
1053+ step_multiplier,
1054+ ) ;
1055+
1056+ #[ cfg( not( feature = "lua55" ) ) ]
1057+ return ffi:: lua_gc ( lua. main_state ( ) , ffi:: LUA_GCSETSTEPMUL , step_multiplier) ;
1058+ }
10381059 }
10391060
10401061 /// Changes the collector to incremental mode with the given parameters.
@@ -1073,12 +1094,19 @@ impl Lua {
10731094 #[ cfg( not( feature = "luau" ) ) ]
10741095 let _ = step_size; // Ignored
10751096
1076- GCMode :: Incremental
1097+ return GCMode :: Incremental ;
10771098 }
10781099
1100+ #[ cfg( feature = "lua55" ) ]
1101+ let prev_mode = unsafe {
1102+ ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPPAUSE , pause) ;
1103+ ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPSTEPMUL , step_multiplier) ;
1104+ ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPSTEPSIZE , step_size) ;
1105+ ffi:: lua_gc ( state, ffi:: LUA_GCINC )
1106+ } ;
10791107 #[ cfg( feature = "lua54" ) ]
10801108 let prev_mode = unsafe { ffi:: lua_gc ( state, ffi:: LUA_GCINC , pause, step_multiplier, step_size) } ;
1081- #[ cfg( feature = "lua54" ) ]
1109+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
10821110 match prev_mode {
10831111 ffi:: LUA_GCINC => GCMode :: Incremental ,
10841112 ffi:: LUA_GCGEN => GCMode :: Generational ,
@@ -1092,11 +1120,19 @@ impl Lua {
10921120 /// can be found in the Lua 5.4 [documentation][lua_doc].
10931121 ///
10941122 /// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5.2
1095- #[ cfg( feature = "lua54" ) ]
1096- #[ cfg_attr( docsrs, doc( cfg( feature = "lua54" ) ) ) ]
1123+ #[ cfg( any ( feature = "lua55" , feature = " lua54") ) ]
1124+ #[ cfg_attr( docsrs, doc( cfg( any ( feature = "lua55" , feature = " lua54") ) ) ) ]
10971125 pub fn gc_gen ( & self , minor_multiplier : c_int , major_multiplier : c_int ) -> GCMode {
10981126 let lua = self . lock ( ) ;
10991127 let state = lua. main_state ( ) ;
1128+ #[ cfg( feature = "lua55" ) ]
1129+ let prev_mode = unsafe {
1130+ ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPMINORMUL , minor_multiplier) ;
1131+ ffi:: lua_gc ( state, ffi:: LUA_GCPARAM , ffi:: LUA_GCPMINORMAJOR , major_multiplier) ;
1132+ // TODO: LUA_GCPMAJORMINOR
1133+ ffi:: lua_gc ( state, ffi:: LUA_GCGEN )
1134+ } ;
1135+ #[ cfg( not( feature = "lua55" ) ) ]
11001136 let prev_mode = unsafe { ffi:: lua_gc ( state, ffi:: LUA_GCGEN , minor_multiplier, major_multiplier) } ;
11011137 match prev_mode {
11021138 ffi:: LUA_GCGEN => GCMode :: Generational ,
@@ -1317,7 +1353,12 @@ impl Lua {
13171353 /// This function is unsafe because provides a way to execute unsafe C function.
13181354 pub unsafe fn create_c_function ( & self , func : ffi:: lua_CFunction ) -> Result < Function > {
13191355 let lua = self . lock ( ) ;
1320- if cfg ! ( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) {
1356+ if cfg ! ( any(
1357+ feature = "lua55" ,
1358+ feature = "lua54" ,
1359+ feature = "lua53" ,
1360+ feature = "lua52"
1361+ ) ) {
13211362 ffi:: lua_pushcfunction ( lua. ref_thread ( ) , func) ;
13221363 return Ok ( Function ( lua. pop_ref_thread ( ) ) ) ;
13231364 }
@@ -1578,7 +1619,7 @@ impl Lua {
15781619 unsafe {
15791620 let _sg = StackGuard :: new ( state) ;
15801621 assert_stack ( state, 1 ) ;
1581- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) ]
1622+ #[ cfg( any( feature = "lua55" , feature = " lua54", feature = "lua53" , feature = "lua52" ) ) ]
15821623 ffi:: lua_rawgeti ( state, ffi:: LUA_REGISTRYINDEX , ffi:: LUA_RIDX_GLOBALS ) ;
15831624 #[ cfg( any( feature = "lua51" , feature = "luajit" , feature = "luau" ) ) ]
15841625 ffi:: lua_pushvalue ( state, ffi:: LUA_GLOBALSINDEX ) ;
@@ -1610,7 +1651,7 @@ impl Lua {
16101651
16111652 lua. push_ref ( & globals. 0 ) ;
16121653
1613- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) ]
1654+ #[ cfg( any( feature = "lua55" , feature = " lua54", feature = "lua53" , feature = "lua52" ) ) ]
16141655 ffi:: lua_rawseti ( state, ffi:: LUA_REGISTRYINDEX , ffi:: LUA_RIDX_GLOBALS ) ;
16151656 #[ cfg( any( feature = "lua51" , feature = "luajit" , feature = "luau" ) ) ]
16161657 ffi:: lua_replace ( state, ffi:: LUA_GLOBALSINDEX ) ;
@@ -2210,7 +2251,7 @@ impl Lua {
22102251 } ) ?,
22112252 ) ?;
22122253
2213- #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" ) ) ]
2254+ #[ cfg( any( feature = "lua55" , feature = " lua54", feature = "lua53" , feature = "lua52" ) ) ]
22142255 let searchers: Table = package. get ( "searchers" ) ?;
22152256 #[ cfg( any( feature = "lua51" , feature = "luajit" ) ) ]
22162257 let searchers: Table = package. get ( "loaders" ) ?;
0 commit comments