pub(crate) unsafe fn pop_value(&self) -> Value {
        let state = self.state;
        match ffi::lua_type(state, -1) {
            ffi::LUA_TNIL => {
                ffi::lua_pop(state, 1);
                Nil
            }

            ffi::LUA_TBOOLEAN => {
                let b = Value::Boolean(ffi::lua_toboolean(state, -1) != 0);
                ffi::lua_pop(state, 1);
                b
            }

            ffi::LUA_TLIGHTUSERDATA => {
                let ud = Value::LightUserData(LightUserData(ffi::lua_touserdata(state, -1)));
                ffi::lua_pop(state, 1);
                ud
            }

            ffi::LUA_TNUMBER => {
                if ffi::lua_isinteger(state, -1) != 0 {
                    let i = Value::Integer(ffi::lua_tointeger(state, -1));
                    ffi::lua_pop(state, 1);
                    i
                } else {
                    let n = Value::Number(ffi::lua_tonumber(state, -1));
                    ffi::lua_pop(state, 1);
                    n
                }
            }

            #[cfg(feature = "luau")]
            ffi::LUA_TVECTOR => {
                let v = ffi::lua_tovector(state, -1);
                mlua_debug_assert!(!v.is_null(), "vector is null");
                let vec = Value::Vector(*v, *v.add(1), *v.add(2));
                ffi::lua_pop(state, 1);
                vec
            }

            ffi::LUA_TSTRING => Value::String(String(self.pop_ref())),

            ffi::LUA_TTABLE => Value::Table(Table(self.pop_ref())),

            ffi::LUA_TFUNCTION => Value::Function(Function(self.pop_ref())),

            ffi::LUA_TUSERDATA => {
                // We must prevent interaction with userdata types other than UserData OR a WrappedError.
                // WrappedPanics are automatically resumed.
                match get_gc_userdata::<WrappedFailure>(state, -1).as_mut() {
                    Some(WrappedFailure::Error(err)) => {
                        let err = err.clone();
                        ffi::lua_pop(state, 1);
                        Value::Error(err)
                    }
                    Some(WrappedFailure::Panic(panic)) => {
                        if let Some(panic) = panic.take() {
                            ffi::lua_pop(state, 1);
                            resume_unwind(panic);
                        }
                        // Previously resumed panic?
                        ffi::lua_pop(state, 1);
                        Nil
                    }
                    _ => Value::UserData(AnyUserData(self.pop_ref())),
                }
            }

            ffi::LUA_TTHREAD => Value::Thread(Thread(self.pop_ref())),

            #[cfg(feature = "luajit")]
            ffi::LUA_TCDATA => {
                ffi::lua_pop(state, 1);
                // TODO: Fix this in a next major release
                panic!("cdata objects cannot be handled by mlua yet");
            }

            _ => mlua_panic!("LUA_TNONE in pop_value"),
        }
    }
// Uses 2 stack spaces, does not call checkstack
Uses 2 stack spaces, does not call checkstack
Uses 2 stack spaces does not call checkstack
pub(crate) unsafe fn pop_value(&self) -> Value {
        let state = self.state;
        match ffi::lua_type(state, -1) {
            ffi::LUA_TNIL => {
                ffi::lua_pop(state, 1);
                Nil
            }
            ffi::LUA_TBOOLEAN => {
                let b = Value::Boolean(ffi::lua_toboolean(state, -1) != 0);
                ffi::lua_pop(state, 1);
                b
            }
            ffi::LUA_TLIGHTUSERDATA => {
                let ud = Value::LightUserData(LightUserData(ffi::lua_touserdata(state, -1)));
                ffi::lua_pop(state, 1);
                ud
            }
            ffi::LUA_TNUMBER => {
                if ffi::lua_isinteger(state, -1) != 0 {
                    let i = Value::Integer(ffi::lua_tointeger(state, -1));
                    ffi::lua_pop(state, 1);
                    i
                } else {
                    let n = Value::Number(ffi::lua_tonumber(state, -1));
                    ffi::lua_pop(state, 1);
                    n
                }
            }
            #[cfg(feature = "luau")]
            ffi::LUA_TVECTOR => {
                let v = ffi::lua_tovector(state, -1);
                mlua_debug_assert!(!v.is_null(), "vector is null");
                let vec = Value::Vector(*v, *v.add(1), *v.add(2));
                ffi::lua_pop(state, 1);
                vec
            }
            ffi::LUA_TSTRING => Value::String(String(self.pop_ref())),
            ffi::LUA_TTABLE => Value::Table(Table(self.pop_ref())),
            ffi::LUA_TFUNCTION => Value::Function(Function(self.pop_ref())),
            ffi::LUA_TUSERDATA => {
                // We must prevent interaction with userdata types other than UserData OR a WrappedError.
                // WrappedPanics are automatically resumed.
                match get_gc_userdata::<WrappedFailure>(state, -1).as_mut() {
                    Some(WrappedFailure::Error(err)) => {
                        let err = err.clone();
                        ffi::lua_pop(state, 1);
                        Value::Error(err)
                    }
                    Some(WrappedFailure::Panic(panic)) => {
                        if let Some(panic) = panic.take() {
                            ffi::lua_pop(state, 1);
                            resume_unwind(panic);
                        }
                        // Previously resumed panic?
                        ffi::lua_pop(state, 1);
                        Nil
                    }
                    _ => Value::UserData(AnyUserData(self.pop_ref())),
                }
            }
            ffi::LUA_TTHREAD => Value::Thread(Thread(self.pop_ref())),
            #[cfg(feature = "luajit")]
            ffi::LUA_TCDATA => {
                ffi::lua_pop(state, 1);
                // TODO: Fix this in a next major release
                panic!("cdata objects cannot be handled by mlua yet");
            }
            _ => mlua_panic!("LUA_TNONE in pop_value"),
        }
    }
pub ( crate ) unsafe fn pop_value ( & self ) -> Value { let state = self . state ; match ffi :: lua_type ( state , - 1 ) { ffi :: LUA_TNIL => { ffi :: lua_pop ( state , 1 ) ; Nil } ffi :: LUA_TBOOLEAN => { let b = Value :: Boolean ( ffi :: lua_toboolean ( state , - 1 ) != 0 ) ; ffi :: lua_pop ( state , 1 ) ; b } ffi :: LUA_TLIGHTUSERDATA => { let ud = Value :: LightUserData ( LightUserData ( ffi :: lua_touserdata ( state , - 1 ) ) ) ; ffi :: lua_pop ( state , 1 ) ; ud } ffi :: LUA_TNUMBER => { if ffi :: lua_isinteger ( state , - 1 ) != 0 { let i = Value :: Integer ( ffi :: lua_tointeger ( state , - 1 ) ) ; ffi :: lua_pop ( state , 1 ) ; i } else { let n = Value :: Number ( ffi :: lua_tonumber ( state , - 1 ) ) ; ffi :: lua_pop ( state , 1 ) ; n } } # [ cfg ( feature " " ) ] ffi :: LUA_TVECTOR => { let v = ffi :: lua_tovector ( state , - 1 ) ; mlua_debug_assert ! ( v is_null ( ) " " ) ; let vec = Value :: Vector ( * v , * v . add ( 1 ) , * v . add ( 2 ) ) ; ffi :: lua_pop ( state , 1 ) ; vec } ffi :: LUA_TSTRING => Value :: String ( String ( self . pop_ref ( ) ) ) , ffi :: LUA_TTABLE => Value :: Table ( Table ( self . pop_ref ( ) ) ) , ffi :: LUA_TFUNCTION => Value :: Function ( Function ( self . pop_ref ( ) ) ) , ffi :: LUA_TUSERDATA => { // We must prevent interaction with userdata types other than UserData OR a WrappedError. // WrappedPanics are automatically resumed. match get_gc_userdata :: < WrappedFailure > ( state , - 1 ) . as_mut ( ) { Some ( WrappedFailure :: Error ( err ) ) => { let err = err . clone ( ) ; ffi :: lua_pop ( state , 1 ) ; Value :: Error ( err ) } Some ( WrappedFailure :: Panic ( panic ) ) => { if let Some ( panic ) = panic . take ( ) { ffi :: lua_pop ( state , 1 ) ; resume_unwind ( panic ) ; } // Previously resumed panic? ffi :: lua_pop ( state , 1 ) ; Nil } _ => Value :: UserData ( AnyUserData ( self . pop_ref ( ) ) ) , } } ffi :: LUA_TTHREAD => Value :: Thread ( Thread ( self . pop_ref ( ) ) ) , # [ cfg ( feature " " ) ] ffi :: LUA_TCDATA => { ffi :: lua_pop ( state , 1 ) ; // TODO: Fix this in a next major release panic ! ( " " ) ; } _ => mlua_panic ! ( " " ) , } }
Uses 2 stack spaces, does not call checkstack
Uses 2 stack spaces does not call checkstack
&self
&self