summaryrefslogtreecommitdiff
path: root/src/lua.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2022-02-25 23:51:51 +0000
committerAlex Orlenko <zxteam@protonmail.com>2022-03-21 01:08:47 +0000
commit3e5f8e7bb8bb2822629593ecbd316f0fda7b4de8 (patch)
treea3c671bd43c804fdf5369cd1fb25bbc4139876c6 /src/lua.rs
parentcab92f4ea2eb93d86a723384d6c08e0f16d16ad9 (diff)
downloadmlua-3e5f8e7bb8bb2822629593ecbd316f0fda7b4de8.zip
Enable `Lua::inspect_stack` for Luau
Diffstat (limited to 'src/lua.rs')
-rw-r--r--src/lua.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lua.rs b/src/lua.rs
index 90ca6d3..8a4475c 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -14,16 +14,15 @@ use rustc_hash::FxHashMap;
use crate::error::{Error, Result};
use crate::ffi;
use crate::function::Function;
-#[cfg(not(feature = "luau"))]
-use crate::hook::{Debug, HookTriggers};
+use crate::hook::Debug;
use crate::scope::Scope;
use crate::stdlib::StdLib;
use crate::string::String;
use crate::table::Table;
use crate::thread::Thread;
use crate::types::{
- Callback, CallbackUpvalue, DestructedUserdataMT, /*HookCallback,*/ Integer, LightUserData,
- LuaRef, MaybeSend, Number, RegistryKey,
+ Callback, CallbackUpvalue, DestructedUserdataMT, Integer, LightUserData, LuaRef, MaybeSend,
+ Number, RegistryKey,
};
use crate::userdata::{
AnyUserData, MetaMethod, UserData, UserDataCell, UserDataFields, UserDataMethods,
@@ -36,9 +35,6 @@ use crate::util::{
};
use crate::value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti, Value};
-#[cfg(not(feature = "luau"))]
-use crate::types::HookCallback;
-
#[cfg(not(feature = "lua54"))]
use crate::util::push_userdata;
#[cfg(feature = "lua54")]
@@ -47,6 +43,9 @@ use {
std::ffi::CStr,
};
+#[cfg(not(feature = "luau"))]
+use crate::{hook::HookTriggers, types::HookCallback};
+
#[cfg(not(feature = "send"))]
use std::rc::Rc;
@@ -933,14 +932,19 @@ impl Lua {
/// function that has called level `n` (except for tail calls, which do not count in the stack).
///
/// [`Debug`]: crate::hook::Debug
- #[cfg(not(feature = "luau"))]
pub fn inspect_stack(&self, level: usize) -> Option<Debug> {
unsafe {
let mut ar: ffi::lua_Debug = mem::zeroed();
- if ffi::lua_getstack(self.state, level as c_int, &mut ar) == 0 {
+ let level = level as c_int;
+ #[cfg(not(feature = "luau"))]
+ if ffi::lua_getstack(self.state, level, &mut ar) == 0 {
+ return None;
+ }
+ #[cfg(feature = "luau")]
+ if ffi::lua_getinfo(self.state, level, cstr!(""), &mut ar) == 0 {
return None;
}
- Some(Debug::new_owned(self, ar))
+ Some(Debug::new_owned(self, level, ar))
}
}