Export LuaDebug

This commit is contained in:
William Venner 2021-10-09 01:09:10 +01:00
parent 4acec5adf2
commit eea1e4b15d
5 changed files with 39 additions and 39 deletions

2
Cargo.lock generated
View File

@ -109,7 +109,7 @@ dependencies = [
[[package]]
name = "gmod"
version = "4.0.2"
version = "4.0.3"
dependencies = [
"cfg_table",
"cstr",

View File

@ -1,6 +1,6 @@
[package]
name = "gmod"
version = "4.0.2"
version = "4.0.3"
authors = ["William Venner <william@venner.io>"]
edition = "2018"
license = "MIT"

View File

@ -8,7 +8,7 @@ macro_rules! find_library {
};
}
use super::{LuaError, State as LuaState, lua_state::LuaDebug};
use super::{LuaError, State as LuaState, LuaDebug};
pub type LuaInt = isize;
pub type LuaSize = usize;

View File

@ -470,38 +470,3 @@ impl std::ops::Deref for LuaState {
&self.0
}
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct LuaDebug {
pub event: i32,
pub name: LuaString,
pub namewhat: LuaString,
pub what: LuaString,
pub source: LuaString,
pub currentline: i32,
pub nups: i32,
pub linedefined: i32,
pub lastlinedefined: i32,
pub short_src: [std::os::raw::c_char; LUA_IDSIZE],
i_ci: i32
}
impl std::fmt::Debug for LuaDebug {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
unsafe {
f.debug_struct("LuaDebug")
.field("event", &self.event)
.field("name", &std::ffi::CStr::from_ptr(self.name))
.field("namewhat", &std::ffi::CStr::from_ptr(self.namewhat))
.field("what", &std::ffi::CStr::from_ptr(self.what))
.field("source", &std::ffi::CStr::from_ptr(self.source))
.field("currentline", &self.currentline)
.field("nups", &self.nups)
.field("linedefined", &self.linedefined)
.field("lastlinedefined", &self.lastlinedefined)
.field("short_src", &std::ffi::CStr::from_ptr(self.short_src.as_ptr()))
.field("i_ci", &self.i_ci)
.finish()
}
}
}

View File

@ -78,3 +78,38 @@ macro_rules! lua_stack_guard {
$code
}};
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct LuaDebug {
pub event: i32,
pub name: LuaString,
pub namewhat: LuaString,
pub what: LuaString,
pub source: LuaString,
pub currentline: i32,
pub nups: i32,
pub linedefined: i32,
pub lastlinedefined: i32,
pub short_src: [std::os::raw::c_char; LUA_IDSIZE],
i_ci: i32
}
impl std::fmt::Debug for LuaDebug {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
unsafe {
f.debug_struct("LuaDebug")
.field("event", &self.event)
.field("name", &std::ffi::CStr::from_ptr(self.name))
.field("namewhat", &std::ffi::CStr::from_ptr(self.namewhat))
.field("what", &std::ffi::CStr::from_ptr(self.what))
.field("source", &std::ffi::CStr::from_ptr(self.source))
.field("currentline", &self.currentline)
.field("nups", &self.nups)
.field("linedefined", &self.linedefined)
.field("lastlinedefined", &self.lastlinedefined)
.field("short_src", &std::ffi::CStr::from_ptr(self.short_src.as_ptr()))
.field("i_ci", &self.i_ci)
.finish()
}
}
}