diff options
author | kyren <kerriganw@gmail.com> | 2018-02-28 14:42:05 -0500 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2018-02-28 14:42:05 -0500 |
commit | d7995137d7f6a9dd1661391ca36310c75d693db0 (patch) | |
tree | d01175865c56f46865524adba9ef860c64edea5f | |
parent | 8824a236b2b156f107e2bd0c0d49220b570ae517 (diff) | |
download | mlua-d7995137d7f6a9dd1661391ca36310c75d693db0.zip |
Add debug API to ffi (not used yet, was using experimentally)
Also fix for cstr! macro
-rw-r--r-- | src/ffi.rs | 22 | ||||
-rw-r--r-- | src/macros.rs | 2 |
2 files changed, 22 insertions, 2 deletions
@@ -4,7 +4,7 @@ use std::ptr; use std::mem; -use std::os::raw::{c_char, c_double, c_int, c_longlong, c_void}; +use std::os::raw::{c_char, c_double, c_int, c_longlong, c_uchar, c_void}; pub type lua_Integer = c_longlong; pub type lua_Number = c_double; @@ -18,6 +18,24 @@ pub type lua_KFunction = unsafe extern "C" fn(state: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int; pub type lua_CFunction = unsafe extern "C" fn(state: *mut lua_State) -> c_int; +#[repr(C)] +pub struct lua_Debug { + pub event: c_int, + pub name: *const c_char, + pub namewhat: *const c_char, + pub what: *const c_char, + pub source: *const c_char, + pub currentline: c_int, + pub linedefined: c_int, + pub lastlinedefined: c_int, + pub nups: c_uchar, + pub nparams: c_uchar, + pub isvararg: c_char, + pub istailcall: c_char, + pub short_src: [c_char; LUA_IDSIZE as usize], + i_ci: *mut c_void, +} + pub const LUA_OK: c_int = 0; pub const LUA_YIELD: c_int = 1; pub const LUA_ERRRUN: c_int = 2; @@ -34,6 +52,7 @@ pub const LUAI_MAXSTACK: c_int = 1_000_000; pub const LUA_REGISTRYINDEX: c_int = -LUAI_MAXSTACK - 1000; pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1; pub const LUA_RIDX_GLOBALS: lua_Integer = 2; +pub const LUA_IDSIZE: c_int = 60; // Not actually defined in lua.h / luaconf.h pub const LUA_MAX_UPVALUES: c_int = 255; @@ -141,6 +160,7 @@ extern "C" { pub fn lua_error(state: *mut lua_State) -> !; pub fn lua_atpanic(state: *mut lua_State, panic: lua_CFunction) -> lua_CFunction; pub fn lua_gc(state: *mut lua_State, what: c_int, data: c_int) -> c_int; + pub fn lua_getinfo(state: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; pub fn luaopen_base(state: *mut lua_State) -> c_int; pub fn luaopen_coroutine(state: *mut lua_State) -> c_int; diff --git a/src/macros.rs b/src/macros.rs index 61ec299..f5342e2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,6 +1,6 @@ macro_rules! cstr { ($s:expr) => ( - concat!($s, "\0") as *const str as *const [c_char] as *const c_char + concat!($s, "\0") as *const str as *const [::std::os::raw::c_char] as *const ::std::os::raw::c_char ); } |