summaryrefslogtreecommitdiff
path: root/mlua-sys/src
diff options
context:
space:
mode:
authorPeter Marheine <peter@taricorp.net>2023-12-06 21:09:25 +1100
committerPeter Marheine <peter@taricorp.net>2023-12-06 21:09:25 +1100
commitb16f3895a0d14b1ef80c9c0f07b97f990f124c32 (patch)
tree3214936003c9dea1bddc5a134f849f412e1b7a8e /mlua-sys/src
parenta4c919231c5bbd6ad65b419b7f08d5976272c288 (diff)
downloadmlua-b16f3895a0d14b1ef80c9c0f07b97f990f124c32.zip
lua54: use changed return type for lua_rawlen
Lua 5.4 changed lua_rawlen to return lua_Unsigned, versus size_t in earlier versions. Change the C API signature to match, and add a wrapper function with the same name that maintains a stable Rust API by casting to usize.
Diffstat (limited to 'mlua-sys/src')
-rw-r--r--mlua-sys/src/lua54/lua.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/mlua-sys/src/lua54/lua.rs b/mlua-sys/src/lua54/lua.rs
index 66633bb..7eab2af 100644
--- a/mlua-sys/src/lua54/lua.rs
+++ b/mlua-sys/src/lua54/lua.rs
@@ -149,13 +149,20 @@ extern "C-unwind" {
pub fn lua_tointegerx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Integer;
pub fn lua_toboolean(L: *mut lua_State, idx: c_int) -> c_int;
pub fn lua_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char;
- pub fn lua_rawlen(L: *mut lua_State, idx: c_int) -> usize;
+ #[link_name = "lua_rawlen"]
+ fn lua_rawlen_(L: *mut lua_State, idx: c_int) -> lua_Unsigned;
pub fn lua_tocfunction(L: *mut lua_State, idx: c_int) -> Option<lua_CFunction>;
pub fn lua_touserdata(L: *mut lua_State, idx: c_int) -> *mut c_void;
pub fn lua_tothread(L: *mut lua_State, idx: c_int) -> *mut lua_State;
pub fn lua_topointer(L: *mut lua_State, idx: c_int) -> *const c_void;
}
+// lua_rawlen's return type changed from size_t to lua_Unsigned int in Lua 5.4.
+// This adapts the crate API to the new Lua ABI.
+pub unsafe fn lua_rawlen(L: *mut lua_State, idx: c_int) -> usize {
+ lua_rawlen_(L, idx) as usize
+}
+
//
// Comparison and arithmetic functions
//