Skip to content

Commit 7539003

Browse files
committed
mlua-sys: Bump luau-src to v0.21 (Luau 0.736)
1 parent e9b9844 commit 7539003

6 files changed

Lines changed: 73 additions & 13 deletions

File tree

mlua-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cfg-if = "1.0"
4343
pkg-config = "0.3.17"
4444
lua-src = { version = ">= 551.0.0, < 551.1.0", optional = true }
4545
luajit-src = { version = ">= 210.7.0, < 210.8.0", optional = true }
46-
luau0-src = { version = "0.20.6", optional = true }
46+
luau0-src = { version = "0.21.0", optional = true }
4747

4848
[lints.rust]
4949
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(raw_dylib)'] }

mlua-sys/src/luau/lauxlib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ unsafe extern "C-unwind" {
5656
#[link_name = "luaL_newmetatable"]
5757
pub fn luaL_newmetatable_(L: *mut lua_State, tname: *const c_char) -> c_int;
5858
pub fn luaL_checkudata(L: *mut lua_State, ud: c_int, tname: *const c_char) -> *mut c_void;
59+
pub fn luaL_checkudatatagged(L: *mut lua_State, ud: c_int, tag: c_int) -> *mut c_void;
5960

6061
pub fn luaL_checkbuffer(L: *mut lua_State, narg: c_int, len: *mut usize) -> *mut c_void;
6162

@@ -85,8 +86,6 @@ unsafe extern "C-unwind" {
8586

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

88-
pub fn luaL_callyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int) -> c_int;
89-
9089
#[link_name = "luaL_traceback"]
9190
pub fn luaL_traceback_(L: *mut lua_State, L1: *mut lua_State, msg: *const c_char, level: c_int);
9291

@@ -138,6 +137,16 @@ pub unsafe fn luaL_opt<T>(
138137
}
139138
}
140139

140+
#[inline(always)]
141+
pub unsafe fn luaL_callyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int) -> c_int {
142+
lua::lua_callyieldable(L, nargs, nresults)
143+
}
144+
145+
#[inline(always)]
146+
pub unsafe fn luaL_pcallyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int, errfunc: c_int) -> c_int {
147+
lua::lua_pcallyieldable(L, nargs, nresults, errfunc)
148+
}
149+
141150
#[inline(always)]
142151
pub unsafe fn luaL_getmetatable(L: *mut lua_State, n: *const c_char) -> c_int {
143152
lua::lua_getfield(L, LUA_REGISTRYINDEX, n)
@@ -154,7 +163,7 @@ pub unsafe fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int {
154163
#[inline(always)]
155164
pub unsafe fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int) {
156165
assert_eq!(t, LUA_REGISTRYINDEX);
157-
lua::lua_unref(L, r#ref)
166+
lua::lua_unref(L, r#ref);
158167
}
159168

160169
pub unsafe fn luaL_sandbox(L: *mut lua_State, enabled: c_int) {

mlua-sys/src/luau/lua.rs

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ unsafe extern "C-unwind" {
259259
pub fn lua_call(L: *mut lua_State, nargs: c_int, nresults: c_int);
260260
pub fn lua_pcall(L: *mut lua_State, nargs: c_int, nresults: c_int, errfunc: c_int) -> c_int;
261261
pub fn lua_cpcall(L: *mut lua_State, f: lua_CFunction, ud: *mut c_void) -> c_int;
262+
pub fn lua_callyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int) -> c_int;
263+
pub fn lua_pcallyieldable(L: *mut lua_State, nargs: c_int, nresults: c_int, errfunc: c_int) -> c_int;
262264

263265
//
264266
// Coroutine functions
@@ -293,9 +295,13 @@ pub const LUA_GCSTEP: c_int = 6;
293295
pub const LUA_GCSETGOAL: c_int = 7;
294296
pub const LUA_GCSETSTEPMUL: c_int = 8;
295297
pub const LUA_GCSETSTEPSIZE: c_int = 9;
298+
pub const LUA_GCISPAUSED: c_int = 10;
299+
300+
pub type lua_CategoryName = unsafe extern "C" fn(L: *mut lua_State, memcat: u8) -> *const c_char;
296301

297302
unsafe extern "C-unwind" {
298303
pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int;
304+
pub fn lua_memorydump(L: *mut lua_State, file: *mut c_void, category_name: Option<lua_CategoryName>);
299305
}
300306

301307
//
@@ -304,6 +310,7 @@ unsafe extern "C-unwind" {
304310
unsafe extern "C-unwind" {
305311
pub fn lua_setmemcat(L: *mut lua_State, category: c_int);
306312
pub fn lua_totalbytes(L: *mut lua_State, category: c_int) -> usize;
313+
pub fn lua_allocationrate(L: *mut lua_State) -> i64;
307314
}
308315

309316
//
@@ -314,21 +321,33 @@ unsafe extern "C-unwind" {
314321
pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int;
315322
pub fn lua_rawiter(L: *mut lua_State, idx: c_int, iter: c_int) -> c_int;
316323
pub fn lua_concat(L: *mut lua_State, n: c_int);
324+
pub fn lua_setpointerencodekey(L: *mut lua_State, a: u64, b: u64, c: u64, d: u64);
317325
pub fn lua_encodepointer(L: *mut lua_State, p: usize) -> usize;
318326
pub fn lua_clock() -> c_double;
319327
pub fn lua_setuserdatatag(L: *mut lua_State, idx: c_int, tag: c_int);
320328
pub fn lua_setuserdatadtor(L: *mut lua_State, tag: c_int, dtor: Option<lua_Destructor>);
321329
pub fn lua_getuserdatadtor(L: *mut lua_State, tag: c_int) -> Option<lua_Destructor>;
330+
pub fn lua_setuserdatamark(L: *mut lua_State, tag: c_int, markfn: Option<lua_UserdataMark>);
331+
pub fn lua_setembeddergc(L: *mut lua_State, gcfn: Option<lua_EmbedderGc>);
332+
pub fn lua_weakref(L: *mut lua_State, idx: c_int) -> c_int;
333+
pub fn lua_weakunref(L: *mut lua_State, r#ref: c_int) -> c_int;
334+
pub fn lua_getweakref(L: *mut lua_State, r#ref: c_int) -> c_int;
322335
pub fn lua_setuserdatametatable(L: *mut lua_State, tag: c_int);
323336
pub fn lua_getuserdatametatable(L: *mut lua_State, tag: c_int);
337+
pub fn lua_getuserdataname(L: *mut lua_State, tag: c_int) -> *const c_char;
324338
pub fn lua_setlightuserdataname(L: *mut lua_State, tag: c_int, name: *const c_char);
325339
pub fn lua_getlightuserdataname(L: *mut lua_State, tag: c_int) -> *const c_char;
326340
pub fn lua_clonefunction(L: *mut lua_State, idx: c_int);
341+
pub fn lua_usesexport(L: *mut lua_State, idx: c_int) -> c_int;
327342
pub fn lua_cleartable(L: *mut lua_State, idx: c_int);
328343
pub fn lua_clonetable(L: *mut lua_State, idx: c_int);
329344
pub fn lua_getallocf(L: *mut lua_State, ud: *mut *mut c_void) -> lua_Alloc;
330345
}
331346

347+
pub type lua_UserdataMark = unsafe extern "C-unwind" fn(L: *mut lua_State, ud: *mut c_void);
348+
pub type lua_EmbedderMark = unsafe extern "C-unwind" fn(L: *mut lua_State, r#ref: c_int);
349+
pub type lua_EmbedderGc = unsafe extern "C-unwind" fn(L: *mut lua_State, markref: Option<lua_EmbedderMark>);
350+
332351
//
333352
// Reference system, can be used to pin objects
334353
//
@@ -337,7 +356,7 @@ pub const LUA_REFNIL: c_int = 0;
337356

338357
unsafe extern "C-unwind" {
339358
pub fn lua_ref(L: *mut lua_State, idx: c_int) -> c_int;
340-
pub fn lua_unref(L: *mut lua_State, r#ref: c_int);
359+
pub fn lua_unref(L: *mut lua_State, r#ref: c_int) -> c_int;
341360
}
342361

343362
//
@@ -516,6 +535,7 @@ pub type lua_CounterValue =
516535
unsafe extern "C-unwind" fn(context: *mut c_void, kind: c_int, line: c_int, hits: u64);
517536

518537
unsafe extern "C-unwind" {
538+
pub fn lua_callhook(L: *mut lua_State, hook: lua_Hook, userdata: *mut c_void);
519539
pub fn lua_stackdepth(L: *mut lua_State) -> c_int;
520540
pub fn lua_getinfo(L: *mut lua_State, level: c_int, what: *const c_char, ar: *mut lua_Debug) -> c_int;
521541
pub fn lua_getargument(L: *mut lua_State, level: c_int, n: c_int) -> c_int;
@@ -524,8 +544,12 @@ unsafe extern "C-unwind" {
524544
pub fn lua_getupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
525545
pub fn lua_setupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
526546

547+
pub fn lua_hascustomexecution(L: *mut lua_State, level: c_int) -> c_int;
548+
pub fn lua_incustomexecution(L: *mut lua_State, level: c_int) -> c_int;
549+
527550
pub fn lua_singlestep(L: *mut lua_State, enabled: c_int);
528551
pub fn lua_breakpoint(L: *mut lua_State, funcindex: c_int, line: c_int, enabled: c_int) -> c_int;
552+
pub fn lua_atbreakpoint(L: *mut lua_State) -> c_int;
529553

530554
pub fn lua_getcoverage(L: *mut lua_State, funcindex: c_int, context: *mut c_void, callback: lua_Coverage);
531555

@@ -548,6 +572,8 @@ pub struct lua_Debug {
548572
pub short_src: *const c_char,
549573
pub linedefined: c_int,
550574
pub currentline: c_int,
575+
pub protoid: c_int,
576+
pub bytecodeid: c_int,
551577
pub nupvals: u8,
552578
pub nparams: u8,
553579
pub isvararg: c_char,
@@ -585,8 +611,26 @@ pub struct lua_Callbacks {
585611
/// gets called when protected call results in an error
586612
pub debugprotectederror: Option<unsafe extern "C-unwind" fn(L: *mut lua_State)>,
587613

588-
/// gets called when memory is allocated
589-
pub onallocate: Option<unsafe extern "C-unwind" fn(L: *mut lua_State, osize: usize, nsize: usize)>,
614+
/// gets called after a heap object (or array) is allocated
615+
pub onallocate: Option<
616+
unsafe extern "C-unwind" fn(
617+
L: *mut lua_State,
618+
block: *mut c_void,
619+
osize: usize,
620+
nsize: usize,
621+
memcat: u8,
622+
tt: c_int,
623+
tag: c_int,
624+
),
625+
>,
626+
627+
/// gets called before `lua_resume` runs a coroutine
628+
pub preresume: Option<unsafe extern "C-unwind" fn(L: *mut lua_State)>,
629+
/// gets called after `lua_resume` returns
630+
pub postresume: Option<unsafe extern "C-unwind" fn(L: *mut lua_State)>,
631+
632+
/// gets called before a heap object (or array) is freed
633+
pub onfree: Option<unsafe extern "C-unwind" fn(L: *mut lua_State, block: *mut c_void)>,
590634
}
591635

592636
unsafe extern "C" {
@@ -597,9 +641,4 @@ unsafe extern "C" {
597641
unsafe extern "C" {
598642
pub fn luau_setfflag(name: *const c_char, value: c_int) -> c_int;
599643
pub fn lua_getmetatablepointer(L: *mut lua_State, idx: c_int) -> *const c_void;
600-
pub fn lua_gcdump(
601-
L: *mut lua_State,
602-
file: *mut c_void,
603-
category_name: Option<unsafe extern "C" fn(L: *mut lua_State, memcat: u8) -> *const c_char>,
604-
);
605644
}

mlua-sys/src/luau/luacode.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct lua_CompileOptions {
1414
pub vectorLib: *const c_char,
1515
pub vectorCtor: *const c_char,
1616
pub vectorType: *const c_char,
17+
pub vectorPrecision: c_int,
1718
pub mutableGlobals: *const *const c_char,
1819
pub userdataTypes: *const *const c_char,
1920
pub librariesWithKnownMembers: *const *const c_char,
@@ -32,6 +33,7 @@ impl Default for lua_CompileOptions {
3233
vectorLib: ptr::null(),
3334
vectorCtor: ptr::null(),
3435
vectorType: ptr::null(),
36+
vectorPrecision: 0,
3537
mutableGlobals: ptr::null(),
3638
userdataTypes: ptr::null(),
3739
librariesWithKnownMembers: ptr::null(),
@@ -82,6 +84,7 @@ unsafe extern "C" {
8284
pub fn luau_set_compile_constant_number(cons: *mut lua_CompileConstant, n: f64);
8385
pub fn luau_set_compile_constant_integer64(cons: *mut lua_CompileConstant, l: i64);
8486
pub fn luau_set_compile_constant_vector(cons: *mut lua_CompileConstant, x: f32, y: f32, z: f32, w: f32);
87+
pub fn luau_set_compile_constant_vectord(cons: *mut lua_CompileConstant, x: f64, y: f64, z: f64, w: f64);
8588
pub fn luau_set_compile_constant_string(cons: *mut lua_CompileConstant, s: *const c_char, l: usize);
8689
}
8790

mlua-sys/src/luau/luarequire.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,13 @@ unsafe extern "C-unwind" {
216216

217217
// Clears all entries from the require cache.
218218
pub fn luarequire_clearcache(L: *mut lua_State) -> c_int;
219+
220+
// Locks a placeholder table to prevent access during cyclic module loading.
221+
pub fn luarequire_lockplaceholder(L: *mut lua_State, idx: c_int);
222+
223+
// Populates a placeholder table from a module result table.
224+
pub fn luarequire_populateplaceholder(L: *mut lua_State, placeholder_idx: c_int, result_idx: c_int);
225+
226+
// Creates and caches a locked placeholder for the current module.
227+
pub fn luarequire_createplaceholder(L: *mut lua_State);
219228
}

src/luau/heap_dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl HeapDump {
3232
if file.is_null() {
3333
return None;
3434
}
35-
ffi::lua_gcdump(state, file as *mut _, Some(category_name));
35+
ffi::lua_memorydump(state, file as *mut _, Some(category_name));
3636
libc::fseek(file, 0, libc::SEEK_END);
3737
let len = libc::ftell(file);
3838
libc::rewind(file);

0 commit comments

Comments
 (0)