Update check_stack requirements
This commit is contained in:
parent
7623016d4a
commit
a74b637ed4
|
@ -554,7 +554,7 @@ impl Lua {
|
|||
{
|
||||
let loaded = unsafe {
|
||||
let _sg = StackGuard::new(self.state);
|
||||
check_stack(self.state, 3)?;
|
||||
check_stack(self.state, 2)?;
|
||||
protect_lua!(self.state, 0, 1, state => {
|
||||
ffi::luaL_getsubtable(state, ffi::LUA_REGISTRYINDEX, cstr!("_LOADED"));
|
||||
})?;
|
||||
|
@ -976,7 +976,7 @@ impl Lua {
|
|||
pub fn create_table(&self) -> Result<Table> {
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(self.state);
|
||||
check_stack(self.state, 3)?;
|
||||
check_stack(self.state, 2)?;
|
||||
protect_lua!(self.state, 0, 1, state => ffi::lua_newtable(state))?;
|
||||
Ok(Table(self.pop_ref()))
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
|||
fn wrap_method<'scope, 'lua, 'callback: 'scope, T: 'scope>(
|
||||
scope: &Scope<'lua, 'scope>,
|
||||
data: Rc<RefCell<T>>,
|
||||
data_ptr: *mut c_void,
|
||||
data_ptr: *const c_void,
|
||||
method: NonStaticMethod<'callback, T>,
|
||||
) -> Result<Function<'lua>> {
|
||||
// On methods that actually receive the userdata, we fake a type check on the passed in
|
||||
|
@ -264,9 +264,9 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
|||
if let Some(Value::UserData(ud)) = value {
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 3)?;
|
||||
check_stack(lua.state, 2)?;
|
||||
lua.push_userdata_ref(&ud.0)?;
|
||||
if get_userdata(lua.state, -1) == data_ptr {
|
||||
if get_userdata(lua.state, -1) as *const _ == data_ptr {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,9 +240,9 @@ impl<'lua> LuaSerdeExt<'lua> for Lua {
|
|||
}
|
||||
}
|
||||
|
||||
// Uses 6 stack spaces and calls checkstack.
|
||||
// Uses 2 stack spaces and calls checkstack.
|
||||
pub(crate) unsafe fn init_metatables(state: *mut ffi::lua_State) -> Result<()> {
|
||||
check_stack(state, 3)?;
|
||||
check_stack(state, 2)?;
|
||||
protect_lua!(state, 0, 0, state => {
|
||||
ffi::lua_createtable(state, 0, 1);
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ impl<'lua> ser::SerializeSeq for SerializeVec<'lua> {
|
|||
let value = lua.to_value_with(value, self.options)?;
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 5)?;
|
||||
check_stack(lua.state, 4)?;
|
||||
|
||||
lua.push_ref(&self.table.0);
|
||||
lua.push_value(value)?;
|
||||
|
|
|
@ -62,7 +62,7 @@ impl<'lua> Table<'lua> {
|
|||
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 6)?;
|
||||
check_stack(lua.state, 5)?;
|
||||
|
||||
lua.push_ref(&self.0);
|
||||
lua.push_value(key)?;
|
||||
|
@ -101,7 +101,7 @@ impl<'lua> Table<'lua> {
|
|||
|
||||
let value = unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 5)?;
|
||||
check_stack(lua.state, 4)?;
|
||||
|
||||
lua.push_ref(&self.0);
|
||||
lua.push_value(key)?;
|
||||
|
@ -119,7 +119,7 @@ impl<'lua> Table<'lua> {
|
|||
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 5)?;
|
||||
check_stack(lua.state, 4)?;
|
||||
|
||||
lua.push_ref(&self.0);
|
||||
lua.push_value(key)?;
|
||||
|
@ -192,7 +192,7 @@ impl<'lua> Table<'lua> {
|
|||
|
||||
unsafe {
|
||||
let _sg = StackGuard::new(lua.state);
|
||||
check_stack(lua.state, 6)?;
|
||||
check_stack(lua.state, 5)?;
|
||||
|
||||
lua.push_ref(&self.0);
|
||||
lua.push_value(key)?;
|
||||
|
|
|
@ -246,7 +246,7 @@ pub unsafe fn pop_error(state: *mut ffi::lua_State, err_code: c_int) -> Error {
|
|||
}
|
||||
}
|
||||
|
||||
// Uses 3 stack spaces
|
||||
// Uses 3 stack spaces, does not call checkstack.
|
||||
#[inline]
|
||||
pub unsafe fn push_string<S: AsRef<[u8]> + ?Sized>(
|
||||
state: *mut ffi::lua_State,
|
||||
|
@ -258,13 +258,13 @@ pub unsafe fn push_string<S: AsRef<[u8]> + ?Sized>(
|
|||
})
|
||||
}
|
||||
|
||||
// Uses 3 stack spaces
|
||||
// Uses 3 stack spaces, does not call checkstack.
|
||||
#[inline]
|
||||
pub unsafe fn push_table(state: *mut ffi::lua_State, narr: c_int, nrec: c_int) -> Result<()> {
|
||||
protect_lua!(state, 0, 1, |state| ffi::lua_createtable(state, narr, nrec))
|
||||
}
|
||||
|
||||
// Uses 4 stack spaces
|
||||
// Uses 4 stack spaces, does not call checkstack.
|
||||
pub unsafe fn rawset_field<S>(state: *mut ffi::lua_State, table: c_int, field: &S) -> Result<()>
|
||||
where
|
||||
S: AsRef<[u8]> + ?Sized,
|
||||
|
|
Loading…
Reference in New Issue