Skip to content

Commit 79c2ef9

Browse files
committed
Fix Lua55 support
1 parent c02c43f commit 79c2ef9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Build {
147147
}
148148
_ if target.contains("apple-ios") => {
149149
match version {
150-
Lua54 => config.define("LUA_USE_IOS", None),
150+
Lua54 | Lua55 => config.define("LUA_USE_IOS", None),
151151
_ => config.define("LUA_USE_POSIX", None),
152152
};
153153
}
@@ -212,7 +212,10 @@ impl Build {
212212

213213
if let Lua54 = version {
214214
config.define("LUA_COMPAT_5_3", None);
215-
#[cfg(feature = "ucid")]
215+
}
216+
217+
#[cfg(feature = "ucid")]
218+
if let Lua54 | Lua55 = version {
216219
config.define("LUA_UCID", None);
217220
}
218221

testcrate/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
#![allow(unsafe_op_in_unsafe_fn, clippy::missing_safety_doc)]
1+
#![allow(unsafe_op_in_unsafe_fn, non_snake_case, clippy::missing_safety_doc)]
22

33
use std::os::raw::{c_char, c_int, c_long, c_void};
44

55
unsafe extern "C" {
66
pub fn luaL_newstate() -> *mut c_void;
7+
8+
#[cfg(not(feature = "lua55"))]
79
pub fn luaL_openlibs(state: *mut c_void);
10+
#[cfg(feature = "lua55")]
11+
pub fn luaL_openselectedlibs(state: *mut c_void, load: c_int, preload: c_int);
12+
813
pub fn lua_getfield(state: *mut c_void, index: c_int, k: *const c_char);
914
pub fn lua_tolstring(state: *mut c_void, index: c_int, len: *mut c_long) -> *const c_char;
1015
pub fn luaL_loadstring(state: *mut c_void, s: *const c_char) -> c_int;
@@ -43,6 +48,11 @@ unsafe extern "C" {
4348
pub fn lua_getglobal(state: *mut c_void, k: *const c_char) -> c_int;
4449
}
4550

51+
#[cfg(feature = "lua55")]
52+
pub unsafe fn luaL_openlibs(state: *mut c_void) {
53+
luaL_openselectedlibs(state, !0, 0);
54+
}
55+
4656
#[cfg(feature = "lua51")]
4757
pub unsafe fn lua_getglobal(state: *mut c_void, k: *const c_char) {
4858
lua_getfield(state, -10002 /* LUA_GLOBALSINDEX */, k);

0 commit comments

Comments
 (0)