From e523fb2c8651a0aecda4353f4d72700083e0027a Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sat, 8 Oct 2022 23:34:47 +0100 Subject: [PATCH] Update to Luau 0.548 (luau-src >=0.4) --- Cargo.toml | 2 +- src/ffi/luau/compat.rs | 2 +- src/ffi/luau/lua.rs | 5 ++++- src/function.rs | 5 ++++- src/hook.rs | 3 +++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69dc8ad..e0eea23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ cc = { version = "1.0" } pkg-config = { version = "0.3.17" } lua-src = { version = ">= 544.0.0, < 550.0.0", optional = true } luajit-src = { version = ">= 210.4.0, < 220.0.0", optional = true } -luau0-src = { version = "0.3.6", optional = true } +luau0-src = { version = "0.4.0", optional = true } [dev-dependencies] rustyline = "10.0" diff --git a/src/ffi/luau/compat.rs b/src/ffi/luau/compat.rs index c718214..043245a 100644 --- a/src/ffi/luau/compat.rs +++ b/src/ffi/luau/compat.rs @@ -423,7 +423,7 @@ pub unsafe fn luaL_traceback( level = numlevels - COMPAT53_LEVELS2; // and skip to last ones } else { lua_getinfo(L1, level, cstr!("sln"), &mut ar); - lua_pushfstring(L, cstr!("\n\t%s:"), ar.short_src.as_ptr()); + lua_pushfstring(L, cstr!("\n\t%s:"), ar.short_src); if ar.currentline > 0 { lua_pushfstring(L, cstr!("%d:"), ar.currentline); } diff --git a/src/ffi/luau/lua.rs b/src/ffi/luau/lua.rs index cbc2c40..624e427 100644 --- a/src/ffi/luau/lua.rs +++ b/src/ffi/luau/lua.rs @@ -257,6 +257,7 @@ extern "C" { extern "C" { pub fn lua_error(L: *mut lua_State) -> !; pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int; + pub fn lua_rawiter(L: *mut lua_State, idx: c_int, iter: c_int) -> c_int; pub fn lua_concat(L: *mut lua_State, n: c_int); // TODO: lua_encodepointer pub fn lua_clock() -> c_double; @@ -267,6 +268,7 @@ extern "C" { dtor: Option, ); pub fn lua_clonefunction(L: *mut lua_State, idx: c_int); + pub fn lua_cleartable(L: *mut lua_State, idx: c_int); } // @@ -460,13 +462,14 @@ pub struct lua_Debug { pub name: *const c_char, pub what: *const c_char, pub source: *const c_char, + pub short_src: *const c_char, pub linedefined: c_int, pub currentline: c_int, pub nupvals: u8, pub nparams: u8, pub isvararg: c_char, - pub short_src: [c_char; LUA_IDSIZE], pub userdata: *mut c_void, + pub ssbuf: [c_char; LUA_IDSIZE], } // diff --git a/src/function.rs b/src/function.rs index 892bf4b..dde2d32 100644 --- a/src/function.rs +++ b/src/function.rs @@ -273,7 +273,10 @@ impl<'lua> Function<'lua> { name_what: None, what: ptr_to_cstr_bytes(ar.what).map(|s| s.to_vec()), source: ptr_to_cstr_bytes(ar.source).map(|s| s.to_vec()), - short_src: ptr_to_cstr_bytes(&ar.short_src as *const _).map(|s| s.to_vec()), + #[cfg(not(feature = "luau"))] + short_src: ptr_to_cstr_bytes(ar.short_src.as_ptr()).map(|s| s.to_vec()), + #[cfg(feature = "luau")] + short_src: ptr_to_cstr_bytes(ar.short_src).map(|s| s.to_vec()), line_defined: ar.linedefined as i32, #[cfg(not(feature = "luau"))] last_line_defined: ar.lastlinedefined as i32, diff --git a/src/hook.rs b/src/hook.rs index c9e3714..f5f3082 100644 --- a/src/hook.rs +++ b/src/hook.rs @@ -102,7 +102,10 @@ impl<'lua> Debug<'lua> { DebugSource { source: ptr_to_cstr_bytes((*self.ar.get()).source), + #[cfg(not(feature = "luau"))] short_src: ptr_to_cstr_bytes((*self.ar.get()).short_src.as_ptr()), + #[cfg(feature = "luau")] + short_src: ptr_to_cstr_bytes((*self.ar.get()).short_src), line_defined: (*self.ar.get()).linedefined as i32, #[cfg(not(feature = "luau"))] last_line_defined: (*self.ar.get()).lastlinedefined as i32,