Skip to content

Commit 9ea98e3

Browse files
committed
Sync mlua-sys with the main branch
1 parent 0ad03be commit 9ea98e3

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

mlua-sys/src/lua51/compat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ pub unsafe fn luaL_getsubtable(L: *mut lua_State, idx: c_int, fname: *const c_ch
548548

549549
pub unsafe fn luaL_requiref(L: *mut lua_State, modname: *const c_char, openf: lua_CFunction, glb: c_int) {
550550
luaL_checkstack(L, 3, cstr!("not enough stack slots available"));
551-
luaL_getsubtable(L, LUA_REGISTRYINDEX, cstr!("_LOADED"));
551+
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
552552
if lua_getfield(L, -1, modname) == LUA_TNIL {
553553
lua_pop(L, 1);
554554
lua_pushcfunction(L, openf);

mlua-sys/src/lua51/lauxlib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use super::lua::{self, lua_CFunction, lua_Integer, lua_Number, lua_State};
88
// Extra error code for 'luaL_load'
99
pub const LUA_ERRFILE: c_int = lua::LUA_ERRERR + 1;
1010

11+
// Key, in the registry, for table of loaded modules
12+
pub const LUA_LOADED_TABLE: *const c_char = cstr!("_LOADED");
13+
1114
#[repr(C)]
1215
pub struct luaL_Reg {
1316
pub name: *const c_char,

mlua-sys/src/lua52/compat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub unsafe fn luaL_tolstring(L: *mut lua_State, mut idx: c_int, len: *mut usize)
232232

233233
pub unsafe fn luaL_requiref(L: *mut lua_State, modname: *const c_char, openf: lua_CFunction, glb: c_int) {
234234
luaL_checkstack(L, 3, cstr!("not enough stack slots available"));
235-
luaL_getsubtable(L, LUA_REGISTRYINDEX, cstr!("_LOADED"));
235+
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
236236
if lua_getfield(L, -1, modname) == LUA_TNIL {
237237
lua_pop(L, 1);
238238
lua_pushcfunction(L, openf);

mlua-sys/src/lua52/lauxlib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ use super::lua::{self, lua_CFunction, lua_Integer, lua_Number, lua_State, lua_Un
88
// Extra error code for 'luaL_load'
99
pub const LUA_ERRFILE: c_int = lua::LUA_ERRERR + 1;
1010

11+
// Key, in the registry, for table of loaded modules
12+
pub const LUA_LOADED_TABLE: *const c_char = cstr!("_LOADED");
13+
14+
// Key, in the registry, for table of preloaded loaders
15+
pub const LUA_PRELOAD_TABLE: *const c_char = cstr!("_PRELOAD");
16+
1117
#[repr(C)]
1218
pub struct luaL_Reg {
1319
pub name: *const c_char,

mlua-sys/src/luau/compat.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use super::lauxlib::*;
1010
use super::lua::*;
1111
use super::luacode::*;
1212

13+
pub const LUA_RESUMEERROR: c_int = -1;
14+
1315
unsafe fn compat53_reverse(L: *mut lua_State, mut a: c_int, mut b: c_int) {
1416
while a < b {
1517
lua_pushvalue(L, a);
@@ -291,6 +293,19 @@ pub unsafe fn lua_resume(L: *mut lua_State, from: *mut lua_State, narg: c_int, n
291293
ret
292294
}
293295

296+
#[inline(always)]
297+
pub unsafe fn lua_resumex(L: *mut lua_State, from: *mut lua_State, narg: c_int, nres: *mut c_int) -> c_int {
298+
let ret = if narg == LUA_RESUMEERROR {
299+
lua_resumeerror(L, from)
300+
} else {
301+
lua_resume_(L, from, narg)
302+
};
303+
if (ret == LUA_OK || ret == LUA_YIELD) && !(nres.is_null()) {
304+
*nres = lua_gettop(L);
305+
}
306+
ret
307+
}
308+
294309
//
295310
// lauxlib ported functions
296311
//

mlua-sys/src/luau/luarequire.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::os::raw::{c_char, c_int, c_void};
44

55
use super::lua::lua_State;
66

7+
pub const LUA_REGISTERED_MODULES_TABLE: *const c_char = cstr!("_REGISTEREDMODULES");
8+
79
#[repr(C)]
810
pub enum luarequire_NavigateResult {
911
Success,

0 commit comments

Comments
 (0)