Skip to content

Commit f7f04d5

Browse files
committed
Revert mlua-sys to v0.6.8
1 parent e10623d commit f7f04d5

File tree

10 files changed

+24
-203
lines changed

10 files changed

+24
-203
lines changed

mlua-sys/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mlua-sys"
3-
version = "0.7.0"
3+
version = "0.6.8"
44
authors = ["Aleksandr Orlenko <zxteam@pm.me>"]
55
rust-version = "1.71"
66
edition = "2021"
@@ -38,9 +38,9 @@ module = []
3838
cc = "1.0"
3939
cfg-if = "1.0"
4040
pkg-config = "0.3.17"
41-
lua-src = { version = ">= 547.1.0, < 547.2.0", optional = true }
42-
luajit-src = { version = ">= 210.6.0, < 210.7.0", optional = true }
43-
luau0-src = { version = "0.14.2", optional = true }
41+
lua-src = { version = ">= 547.0.0, < 547.1.0", optional = true }
42+
luajit-src = { version = ">= 210.5.0, < 210.6.0", optional = true }
43+
luau0-src = { version = "0.12.0", optional = true }
4444

4545
[lints.rust]
4646
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(raw_dylib)'] }

mlua-sys/src/lua51/lua.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ pub type lua_Reader =
8383
pub type lua_Writer =
8484
unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
8585

86-
/// Type for memory-allocation functions (no unwinding)
86+
/// Type for memory-allocation functions
8787
#[rustfmt::skip]
8888
pub type lua_Alloc =
89-
unsafe extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
89+
unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
9090

9191
#[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))]
9292
extern "C-unwind" {

mlua-sys/src/lua52/lua.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ pub type lua_Reader =
8888
pub type lua_Writer =
8989
unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
9090

91-
/// Type for memory-allocation functions (no unwinding)
91+
/// Type for memory-allocation functions
9292
#[rustfmt::skip]
9393
pub type lua_Alloc =
94-
unsafe extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
94+
unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
9595

9696
#[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))]
9797
extern "C-unwind" {

mlua-sys/src/lua53/lua.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ pub type lua_Reader =
9595
pub type lua_Writer =
9696
unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
9797

98-
/// Type for memory-allocation functions (no unwinding)
98+
/// Type for memory-allocation functions
9999
#[rustfmt::skip]
100100
pub type lua_Alloc =
101-
unsafe extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
101+
unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
102102

103103
#[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))]
104104
extern "C-unwind" {

mlua-sys/src/lua54/lua.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ pub type lua_Reader =
9494
pub type lua_Writer =
9595
unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
9696

97-
/// Type for memory-allocation functions (no unwinding)
97+
/// Type for memory-allocation functions
9898
#[rustfmt::skip]
9999
pub type lua_Alloc =
100-
unsafe extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
100+
unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
101101

102102
/// Type for warning functions
103103
pub type lua_WarnFunction = unsafe extern "C-unwind" fn(ud: *mut c_void, msg: *const c_char, tocont: c_int);

mlua-sys/src/luau/compat.rs

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

13-
pub const LUA_RESUMEERROR: c_int = -1;
14-
1513
unsafe fn compat53_reverse(L: *mut lua_State, mut a: c_int, mut b: c_int) {
1614
while a < b {
1715
lua_pushvalue(L, a);
@@ -286,19 +284,6 @@ pub unsafe fn lua_resume(L: *mut lua_State, from: *mut lua_State, narg: c_int, n
286284
ret
287285
}
288286

289-
#[inline(always)]
290-
pub unsafe fn lua_resumex(L: *mut lua_State, from: *mut lua_State, narg: c_int, nres: *mut c_int) -> c_int {
291-
let ret = if narg == LUA_RESUMEERROR {
292-
lua_resumeerror(L, from)
293-
} else {
294-
lua_resume_(L, from, narg)
295-
};
296-
if (ret == LUA_OK || ret == LUA_YIELD) && !(nres.is_null()) {
297-
*nres = lua_gettop(L);
298-
}
299-
ret
300-
}
301-
302287
//
303288
// lauxlib ported functions
304289
//
@@ -347,7 +332,7 @@ pub unsafe fn luaL_loadbufferenv(
347332
fn free(p: *mut c_void);
348333
}
349334

350-
unsafe extern "C" fn data_dtor(_: *mut lua_State, data: *mut c_void) {
335+
unsafe extern "C-unwind" fn data_dtor(data: *mut c_void) {
351336
free(*(data as *mut *mut c_char) as *mut c_void);
352337
}
353338

mlua-sys/src/luau/lauxlib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,10 @@ extern "C-unwind" {
6969

7070
pub fn luaL_newstate() -> *mut lua_State;
7171

72-
pub fn luaL_findtable(
73-
L: *mut lua_State,
74-
idx: c_int,
75-
fname: *const c_char,
76-
szhint: c_int,
77-
) -> *const c_char;
72+
// TODO: luaL_findtable
7873

7974
pub fn luaL_typename(L: *mut lua_State, idx: c_int) -> *const c_char;
8075

81-
pub fn luaL_callyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int) -> c_int;
82-
8376
// sandbox libraries and globals
8477
#[link_name = "luaL_sandbox"]
8578
pub fn luaL_sandbox_(L: *mut lua_State);

mlua-sys/src/luau/lua.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ pub type lua_Unsigned = c_uint;
7979
pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int;
8080
pub type lua_Continuation = unsafe extern "C-unwind" fn(L: *mut lua_State, status: c_int) -> c_int;
8181

82-
/// Type for userdata destructor functions (no unwinding).
83-
pub type lua_Destructor = unsafe extern "C" fn(L: *mut lua_State, *mut c_void);
82+
/// Type for userdata destructor functions.
83+
pub type lua_Udestructor = unsafe extern "C-unwind" fn(*mut c_void);
84+
pub type lua_Destructor = unsafe extern "C-unwind" fn(L: *mut lua_State, *mut c_void);
8485

85-
/// Type for memory-allocation functions (no unwinding).
86+
/// Type for memory-allocation functions.
8687
pub type lua_Alloc =
87-
unsafe extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
88+
unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
8889

8990
/// Returns Luau release version (eg. `0.xxx`).
9091
pub const fn luau_version() -> Option<&'static str> {
@@ -185,7 +186,7 @@ extern "C-unwind" {
185186
pub fn lua_pushlightuserdatatagged(L: *mut lua_State, p: *mut c_void, tag: c_int);
186187
pub fn lua_newuserdatatagged(L: *mut lua_State, sz: usize, tag: c_int) -> *mut c_void;
187188
pub fn lua_newuserdatataggedwithmetatable(L: *mut lua_State, sz: usize, tag: c_int) -> *mut c_void;
188-
pub fn lua_newuserdatadtor(L: *mut lua_State, sz: usize, dtor: lua_Destructor) -> *mut c_void;
189+
pub fn lua_newuserdatadtor(L: *mut lua_State, sz: usize, dtor: lua_Udestructor) -> *mut c_void;
189190

190191
pub fn lua_newbuffer(L: *mut lua_State, sz: usize) -> *mut c_void;
191192

@@ -284,7 +285,7 @@ extern "C-unwind" {
284285
pub fn lua_setuserdatatag(L: *mut lua_State, idx: c_int, tag: c_int);
285286
pub fn lua_setuserdatadtor(L: *mut lua_State, tag: c_int, dtor: Option<lua_Destructor>);
286287
pub fn lua_getuserdatadtor(L: *mut lua_State, tag: c_int) -> Option<lua_Destructor>;
287-
pub fn lua_setuserdatametatable(L: *mut lua_State, tag: c_int);
288+
pub fn lua_setuserdatametatable(L: *mut lua_State, tag: c_int, idx: c_int);
288289
pub fn lua_getuserdatametatable(L: *mut lua_State, tag: c_int);
289290
pub fn lua_setlightuserdataname(L: *mut lua_State, tag: c_int, name: *const c_char);
290291
pub fn lua_getlightuserdataname(L: *mut lua_State, tag: c_int) -> *const c_char;
@@ -339,14 +340,12 @@ pub unsafe fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut c_void {
339340
}
340341

341342
#[inline(always)]
342-
pub unsafe fn lua_newuserdata_t<T>(L: *mut lua_State, data: T) -> *mut T {
343-
unsafe extern "C" fn destructor<T>(_: *mut lua_State, ud: *mut c_void) {
343+
pub unsafe fn lua_newuserdata_t<T>(L: *mut lua_State) -> *mut T {
344+
unsafe extern "C-unwind" fn destructor<T>(ud: *mut c_void) {
344345
ptr::drop_in_place(ud as *mut T);
345346
}
346347

347-
let ud_ptr = lua_newuserdatadtor(L, const { mem::size_of::<T>() }, destructor::<T>) as *mut T;
348-
ptr::write(ud_ptr, data);
349-
ud_ptr
348+
lua_newuserdatadtor(L, mem::size_of::<T>(), destructor::<T>) as *mut T
350349
}
351350

352351
// TODO: lua_strlen

mlua-sys/src/luau/luarequire.rs

Lines changed: 0 additions & 154 deletions
This file was deleted.

mlua-sys/src/luau/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ pub use lua::*;
66
pub use luacode::*;
77
pub use luacodegen::*;
88
pub use lualib::*;
9-
pub use luarequire::*;
109

1110
pub mod compat;
1211
pub mod lauxlib;
1312
pub mod lua;
1413
pub mod luacode;
1514
pub mod luacodegen;
1615
pub mod lualib;
17-
pub mod luarequire;

0 commit comments

Comments
 (0)