Fix Luau documentation in docs.rs
Enable `Lua::gc_inc` for Luau Mark `debug` module as safe for Luau
This commit is contained in:
parent
70d287cf9f
commit
55fac90a74
|
@ -213,6 +213,10 @@ impl<'lua> Function<'lua> {
|
||||||
///
|
///
|
||||||
/// If `strip` is true, the binary representation may not include all debug information
|
/// If `strip` is true, the binary representation may not include all debug information
|
||||||
/// about the function, to save space.
|
/// about the function, to save space.
|
||||||
|
///
|
||||||
|
/// For Luau a [Compiler] can be used to compile Lua chunks to bytecode.
|
||||||
|
///
|
||||||
|
/// [Compiler]: crate::chunk::Compiler
|
||||||
#[cfg(not(feature = "luau"))]
|
#[cfg(not(feature = "luau"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))]
|
||||||
pub fn dump(&self, strip: bool) -> Vec<u8> {
|
pub fn dump(&self, strip: bool) -> Vec<u8> {
|
||||||
|
|
73
src/lua.rs
73
src/lua.rs
|
@ -48,7 +48,9 @@ use {
|
||||||
use crate::{hook::HookTriggers, types::HookCallback};
|
use crate::{hook::HookTriggers, types::HookCallback};
|
||||||
|
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(feature = "luau")]
|
||||||
use crate::types::{InterruptCallback, VmState};
|
use crate::types::InterruptCallback;
|
||||||
|
#[cfg(any(feature = "luau", doc))]
|
||||||
|
use crate::types::VmState;
|
||||||
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
use {
|
use {
|
||||||
|
@ -137,6 +139,7 @@ pub enum GCMode {
|
||||||
Incremental,
|
Incremental,
|
||||||
/// Requires `feature = "lua54"`
|
/// Requires `feature = "lua54"`
|
||||||
#[cfg(any(feature = "lua54"))]
|
#[cfg(any(feature = "lua54"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
Generational,
|
Generational,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,6 +314,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// [`StdLib`]: crate::StdLib
|
/// [`StdLib`]: crate::StdLib
|
||||||
pub fn new_with(libs: StdLib, options: LuaOptions) -> Result<Lua> {
|
pub fn new_with(libs: StdLib, options: LuaOptions) -> Result<Lua> {
|
||||||
|
#[cfg(not(feature = "luau"))]
|
||||||
if libs.contains(StdLib::DEBUG) {
|
if libs.contains(StdLib::DEBUG) {
|
||||||
return Err(Error::SafetyError(
|
return Err(Error::SafetyError(
|
||||||
"the unsafe `debug` module can't be loaded using safe `new_with`".to_string(),
|
"the unsafe `debug` module can't be loaded using safe `new_with`".to_string(),
|
||||||
|
@ -583,10 +587,10 @@ impl Lua {
|
||||||
// Register `DestructedUserdataMT` type
|
// Register `DestructedUserdataMT` type
|
||||||
get_destructed_userdata_metatable(main_state);
|
get_destructed_userdata_metatable(main_state);
|
||||||
let destructed_mt_ptr = ffi::lua_topointer(main_state, -1);
|
let destructed_mt_ptr = ffi::lua_topointer(main_state, -1);
|
||||||
(*extra.get()).registered_userdata_mt.insert(
|
let destructed_mt_typeid = Some(TypeId::of::<DestructedUserdataMT>());
|
||||||
destructed_mt_ptr,
|
(*extra.get())
|
||||||
Some(TypeId::of::<DestructedUserdataMT>()),
|
.registered_userdata_mt
|
||||||
);
|
.insert(destructed_mt_ptr, destructed_mt_typeid);
|
||||||
ffi::lua_pop(main_state, 1);
|
ffi::lua_pop(main_state, 1);
|
||||||
|
|
||||||
mlua_debug_assert!(
|
mlua_debug_assert!(
|
||||||
|
@ -619,6 +623,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// [`StdLib`]: crate::StdLib
|
/// [`StdLib`]: crate::StdLib
|
||||||
pub fn load_from_std_lib(&self, libs: StdLib) -> Result<()> {
|
pub fn load_from_std_lib(&self, libs: StdLib) -> Result<()> {
|
||||||
|
#[cfg(not(feature = "luau"))]
|
||||||
if self.safe && libs.contains(StdLib::DEBUG) {
|
if self.safe && libs.contains(StdLib::DEBUG) {
|
||||||
return Err(Error::SafetyError(
|
return Err(Error::SafetyError(
|
||||||
"the unsafe `debug` module can't be loaded in safe mode".to_string(),
|
"the unsafe `debug` module can't be loaded in safe mode".to_string(),
|
||||||
|
@ -805,7 +810,8 @@ impl Lua {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luau"`
|
/// Requires `feature = "luau"`
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", docsrs))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub fn sandbox(&self, enabled: bool) -> Result<()> {
|
pub fn sandbox(&self, enabled: bool) -> Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let extra = &mut *self.extra.get();
|
let extra = &mut *self.extra.get();
|
||||||
|
@ -954,7 +960,7 @@ impl Lua {
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", docsrs))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub fn set_interrupt<F>(&self, callback: F)
|
pub fn set_interrupt<F>(&self, callback: F)
|
||||||
where
|
where
|
||||||
|
@ -996,7 +1002,7 @@ impl Lua {
|
||||||
/// Removes any 'interrupt' previously set by `set_interrupt`.
|
/// Removes any 'interrupt' previously set by `set_interrupt`.
|
||||||
///
|
///
|
||||||
/// This function has no effect if an 'interrupt' was not previously set.
|
/// This function has no effect if an 'interrupt' was not previously set.
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", docsrs))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub fn remove_interrupt(&self) {
|
pub fn remove_interrupt(&self) {
|
||||||
let state = mlua_expect!(self.main_state, "Luau should always has main state");
|
let state = mlua_expect!(self.main_state, "Luau should always has main state");
|
||||||
|
@ -1010,6 +1016,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// Requires `feature = "lua54"`
|
/// Requires `feature = "lua54"`
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(feature = "lua54")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
pub fn set_warning_function<F>(&self, callback: F)
|
pub fn set_warning_function<F>(&self, callback: F)
|
||||||
where
|
where
|
||||||
F: 'static + MaybeSend + Fn(&Lua, &CStr, bool) -> Result<()>,
|
F: 'static + MaybeSend + Fn(&Lua, &CStr, bool) -> Result<()>,
|
||||||
|
@ -1044,6 +1051,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// Requires `feature = "lua54"`
|
/// Requires `feature = "lua54"`
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(feature = "lua54")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
pub fn remove_warning_function(&self) {
|
pub fn remove_warning_function(&self) {
|
||||||
let state = self.main_state.unwrap_or(self.state);
|
let state = self.main_state.unwrap_or(self.state);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1058,6 +1066,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// Requires `feature = "lua54"`
|
/// Requires `feature = "lua54"`
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(feature = "lua54")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
pub fn warning<S: Into<Vec<u8>>>(&self, msg: S, tocont: bool) -> Result<()> {
|
pub fn warning<S: Into<Vec<u8>>>(&self, msg: S, tocont: bool) -> Result<()> {
|
||||||
let msg = CString::new(msg).map_err(|err| Error::RuntimeError(err.to_string()))?;
|
let msg = CString::new(msg).map_err(|err| Error::RuntimeError(err.to_string()))?;
|
||||||
unsafe { ffi::lua_warning(self.state, msg.as_ptr(), if tocont { 1 } else { 0 }) };
|
unsafe { ffi::lua_warning(self.state, msg.as_ptr(), if tocont { 1 } else { 0 }) };
|
||||||
|
@ -1188,22 +1197,27 @@ impl Lua {
|
||||||
/// Sets the 'pause' value of the collector.
|
/// Sets the 'pause' value of the collector.
|
||||||
///
|
///
|
||||||
/// Returns the previous value of 'pause'. More information can be found in the Lua
|
/// Returns the previous value of 'pause'. More information can be found in the Lua
|
||||||
/// [documentation][lua_doc].
|
/// [documentation].
|
||||||
///
|
///
|
||||||
/// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5
|
/// For Luau this parameter sets GC goal
|
||||||
#[cfg(not(feature = "luau"))]
|
///
|
||||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))]
|
/// [documentation]: https://www.lua.org/manual/5.4/manual.html#2.5
|
||||||
pub fn gc_set_pause(&self, pause: c_int) -> c_int {
|
pub fn gc_set_pause(&self, pause: c_int) -> c_int {
|
||||||
let state = self.main_state.unwrap_or(self.state);
|
let state = self.main_state.unwrap_or(self.state);
|
||||||
unsafe { ffi::lua_gc(state, ffi::LUA_GCSETPAUSE, pause) }
|
unsafe {
|
||||||
|
#[cfg(not(feature = "luau"))]
|
||||||
|
return ffi::lua_gc(state, ffi::LUA_GCSETPAUSE, pause);
|
||||||
|
#[cfg(feature = "luau")]
|
||||||
|
return ffi::lua_gc(state, ffi::LUA_GCSETGOAL, pause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the 'step multiplier' value of the collector.
|
/// Sets the 'step multiplier' value of the collector.
|
||||||
///
|
///
|
||||||
/// Returns the previous value of the 'step multiplier'. More information can be found in the
|
/// Returns the previous value of the 'step multiplier'. More information can be found in the
|
||||||
/// Lua [documentation][lua_doc].
|
/// Lua [documentation].
|
||||||
///
|
///
|
||||||
/// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5
|
/// [documentation]: https://www.lua.org/manual/5.4/manual.html#2.5
|
||||||
pub fn gc_set_step_multiplier(&self, step_multiplier: c_int) -> c_int {
|
pub fn gc_set_step_multiplier(&self, step_multiplier: c_int) -> c_int {
|
||||||
let state = self.main_state.unwrap_or(self.state);
|
let state = self.main_state.unwrap_or(self.state);
|
||||||
unsafe { ffi::lua_gc(state, ffi::LUA_GCSETSTEPMUL, step_multiplier) }
|
unsafe { ffi::lua_gc(state, ffi::LUA_GCSETSTEPMUL, step_multiplier) }
|
||||||
|
@ -1212,11 +1226,9 @@ impl Lua {
|
||||||
/// Changes the collector to incremental mode with the given parameters.
|
/// Changes the collector to incremental mode with the given parameters.
|
||||||
///
|
///
|
||||||
/// Returns the previous mode (always `GCMode::Incremental` in Lua < 5.4).
|
/// Returns the previous mode (always `GCMode::Incremental` in Lua < 5.4).
|
||||||
/// More information can be found in the Lua [documentation][lua_doc].
|
/// More information can be found in the Lua [documentation].
|
||||||
///
|
///
|
||||||
/// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5.1
|
/// [documentation]: https://www.lua.org/manual/5.4/manual.html#2.5.1
|
||||||
#[cfg(not(feature = "luau"))]
|
|
||||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))]
|
|
||||||
pub fn gc_inc(&self, pause: c_int, step_multiplier: c_int, step_size: c_int) -> GCMode {
|
pub fn gc_inc(&self, pause: c_int, step_multiplier: c_int, step_size: c_int) -> GCMode {
|
||||||
let state = self.main_state.unwrap_or(self.state);
|
let state = self.main_state.unwrap_or(self.state);
|
||||||
|
|
||||||
|
@ -1224,16 +1236,28 @@ impl Lua {
|
||||||
feature = "lua53",
|
feature = "lua53",
|
||||||
feature = "lua52",
|
feature = "lua52",
|
||||||
feature = "lua51",
|
feature = "lua51",
|
||||||
feature = "luajit"
|
feature = "luajit",
|
||||||
|
feature = "luau"
|
||||||
))]
|
))]
|
||||||
{
|
unsafe {
|
||||||
if pause > 0 {
|
if pause > 0 {
|
||||||
unsafe { ffi::lua_gc(state, ffi::LUA_GCSETPAUSE, pause) };
|
#[cfg(not(feature = "luau"))]
|
||||||
|
ffi::lua_gc(state, ffi::LUA_GCSETPAUSE, pause);
|
||||||
|
#[cfg(feature = "luau")]
|
||||||
|
ffi::lua_gc(state, ffi::LUA_GCSETGOAL, pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
if step_multiplier > 0 {
|
if step_multiplier > 0 {
|
||||||
unsafe { ffi::lua_gc(state, ffi::LUA_GCSETSTEPMUL, step_multiplier) };
|
ffi::lua_gc(state, ffi::LUA_GCSETSTEPMUL, step_multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "luau")]
|
||||||
|
if step_size > 0 {
|
||||||
|
ffi::lua_gc(state, ffi::LUA_GCSETSTEPSIZE, step_size);
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "luau"))]
|
||||||
let _ = step_size; // Ignored
|
let _ = step_size; // Ignored
|
||||||
|
|
||||||
GCMode::Incremental
|
GCMode::Incremental
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1257,6 +1281,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5.2
|
/// [lua_doc]: https://www.lua.org/manual/5.4/manual.html#2.5.2
|
||||||
#[cfg(any(feature = "lua54"))]
|
#[cfg(any(feature = "lua54"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
pub fn gc_gen(&self, minor_multiplier: c_int, major_multiplier: c_int) -> GCMode {
|
pub fn gc_gen(&self, minor_multiplier: c_int, major_multiplier: c_int) -> GCMode {
|
||||||
let state = self.main_state.unwrap_or(self.state);
|
let state = self.main_state.unwrap_or(self.state);
|
||||||
let prev_mode =
|
let prev_mode =
|
||||||
|
@ -2972,7 +2997,7 @@ unsafe fn load_from_std_lib(state: *mut ffi::lua_State, libs: StdLib) -> Result<
|
||||||
openf: ffi::lua_CFunction,
|
openf: ffi::lua_CFunction,
|
||||||
glb: c_int,
|
glb: c_int,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let modname = mlua_expect!(CString::new(modname.as_ref()), "modname contains nil bytes");
|
let modname = mlua_expect!(CString::new(modname.as_ref()), "modname contains nil byte");
|
||||||
protect_lua!(state, 0, 1, |state| {
|
protect_lua!(state, 0, 1, |state| {
|
||||||
ffi::luaL_requiref(state, modname.as_ptr() as *const c_char, openf, glb)
|
ffi::luaL_requiref(state, modname.as_ptr() as *const c_char, openf, glb)
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,12 +46,14 @@ impl StdLib {
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luajit"`
|
/// Requires `feature = "luajit"`
|
||||||
#[cfg(any(feature = "luajit", doc))]
|
#[cfg(any(feature = "luajit", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "luajit")))]
|
||||||
pub const JIT: StdLib = StdLib(1 << 9);
|
pub const JIT: StdLib = StdLib(1 << 9);
|
||||||
|
|
||||||
/// (**unsafe**) [`ffi`](http://luajit.org/ext_ffi.html) library
|
/// (**unsafe**) [`ffi`](http://luajit.org/ext_ffi.html) library
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luajit"`
|
/// Requires `feature = "luajit"`
|
||||||
#[cfg(any(feature = "luajit", doc))]
|
#[cfg(any(feature = "luajit", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "luajit")))]
|
||||||
pub const FFI: StdLib = StdLib(1 << 30);
|
pub const FFI: StdLib = StdLib(1 << 30);
|
||||||
/// (**unsafe**) [`debug`](https://www.lua.org/manual/5.4/manual.html#6.10) library
|
/// (**unsafe**) [`debug`](https://www.lua.org/manual/5.4/manual.html#6.10) library
|
||||||
pub const DEBUG: StdLib = StdLib(1 << 31);
|
pub const DEBUG: StdLib = StdLib(1 << 31);
|
||||||
|
@ -61,7 +63,10 @@ impl StdLib {
|
||||||
/// (**unsafe**) All standard libraries
|
/// (**unsafe**) All standard libraries
|
||||||
pub const ALL: StdLib = StdLib(u32::MAX);
|
pub const ALL: StdLib = StdLib(u32::MAX);
|
||||||
/// The safe subset of the standard libraries
|
/// The safe subset of the standard libraries
|
||||||
|
#[cfg(not(feature = "luau"))]
|
||||||
pub const ALL_SAFE: StdLib = StdLib((1 << 30) - 1);
|
pub const ALL_SAFE: StdLib = StdLib((1 << 30) - 1);
|
||||||
|
#[cfg(feature = "luau")]
|
||||||
|
pub const ALL_SAFE: StdLib = StdLib(u32::MAX);
|
||||||
|
|
||||||
pub fn contains(self, lib: Self) -> bool {
|
pub fn contains(self, lib: Self) -> bool {
|
||||||
(self & lib).0 != 0
|
(self & lib).0 != 0
|
||||||
|
|
|
@ -351,7 +351,7 @@ impl<'lua> Table<'lua> {
|
||||||
/// Sets `readonly` attribute on the table.
|
/// Sets `readonly` attribute on the table.
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luau"`
|
/// Requires `feature = "luau"`
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", doc))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub fn set_readonly(&self, enabled: bool) {
|
pub fn set_readonly(&self, enabled: bool) {
|
||||||
let lua = self.0.lua;
|
let lua = self.0.lua;
|
||||||
|
@ -369,7 +369,7 @@ impl<'lua> Table<'lua> {
|
||||||
/// Returns `readonly` attribute of the table.
|
/// Returns `readonly` attribute of the table.
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luau"`
|
/// Requires `feature = "luau"`
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", doc))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub fn is_readonly(&self) -> bool {
|
pub fn is_readonly(&self) -> bool {
|
||||||
let lua = self.0.lua;
|
let lua = self.0.lua;
|
||||||
|
|
|
@ -299,9 +299,8 @@ impl<'lua> Thread<'lua> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # #[cfg(feature = "luau")]
|
/// # use mlua::{Lua, Result};
|
||||||
/// # fn main() -> mlua::Result<()> {
|
/// # fn main() -> Result<()> {
|
||||||
/// use mlua::Lua;
|
|
||||||
/// let lua = Lua::new();
|
/// let lua = Lua::new();
|
||||||
/// let thread = lua.create_thread(lua.create_function(|lua2, ()| {
|
/// let thread = lua.create_thread(lua.create_function(|lua2, ()| {
|
||||||
/// lua2.load("var = 123").exec()?;
|
/// lua2.load("var = 123").exec()?;
|
||||||
|
@ -315,13 +314,10 @@ impl<'lua> Thread<'lua> {
|
||||||
/// assert_eq!(lua.globals().get::<_, Option<u32>>("var")?, None);
|
/// assert_eq!(lua.globals().get::<_, Option<u32>>("var")?, None);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
///
|
|
||||||
/// # #[cfg(not(feature = "luau"))]
|
|
||||||
/// fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Requires `feature = "luau"`
|
/// Requires `feature = "luau"`
|
||||||
#[cfg(any(feature = "luau", doc))]
|
#[cfg(any(feature = "luau", docsrs))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn sandbox(&self) -> Result<()> {
|
pub fn sandbox(&self) -> Result<()> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use mlua::{Lua, Result, UserData};
|
use mlua::{GCMode, Lua, Result, UserData};
|
||||||
|
|
||||||
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
use mlua::Error;
|
use mlua::Error;
|
||||||
|
@ -39,7 +39,10 @@ fn test_gc_control() -> Result<()> {
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
|
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(feature = "lua54")]
|
||||||
assert_eq!(lua.gc_gen(0, 0), mlua::GCMode::Incremental);
|
{
|
||||||
|
assert_eq!(lua.gc_gen(0, 0), GCMode::Incremental);
|
||||||
|
assert_eq!(lua.gc_inc(0, 0, 0), GCMode::Generational);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "lua54",
|
feature = "lua54",
|
||||||
|
@ -55,6 +58,8 @@ fn test_gc_control() -> Result<()> {
|
||||||
assert!(lua.gc_is_running());
|
assert!(lua.gc_is_running());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_eq!(lua.gc_inc(200, 100, 13), GCMode::Incremental);
|
||||||
|
|
||||||
struct MyUserdata(Arc<()>);
|
struct MyUserdata(Arc<()>);
|
||||||
impl UserData for MyUserdata {}
|
impl UserData for MyUserdata {}
|
||||||
|
|
||||||
|
@ -67,9 +72,6 @@ fn test_gc_control() -> Result<()> {
|
||||||
lua.gc_collect()?;
|
lua.gc_collect()?;
|
||||||
assert_eq!(Arc::strong_count(&rc), 1);
|
assert_eq!(Arc::strong_count(&rc), 1);
|
||||||
|
|
||||||
#[cfg(feature = "lua54")]
|
|
||||||
assert_eq!(lua.gc_inc(0, 0, 0), mlua::GCMode::Generational);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue