Skip to content

Commit cd56f92

Browse files
committed
Update Luau definitions in mlua-sys to 0.700
1 parent 1bd1359 commit cd56f92

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

mlua-sys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mlua-sys"
3-
version = "0.8.3"
3+
version = "0.9.0"
44
authors = ["Aleksandr Orlenko <zxteam@pm.me>"]
55
rust-version = "1.71"
66
edition = "2021"
@@ -41,7 +41,7 @@ cfg-if = "1.0"
4141
pkg-config = "0.3.17"
4242
lua-src = { version = ">= 548.1.0, < 548.2.0", optional = true }
4343
luajit-src = { version = ">= 210.6.0, < 210.7.0", optional = true }
44-
luau0-src = { version = "0.15.6", optional = true }
44+
luau0-src = { version = "0.16.0", optional = true, git = "https://github.com/mlua-rs/luau-src-rs" }
4545

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

mlua-sys/src/luau/compat.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ pub unsafe fn lua_rawgeti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_in
203203

204204
#[inline(always)]
205205
pub unsafe fn lua_rawgetp(L: *mut lua_State, idx: c_int, p: *const c_void) -> c_int {
206-
let abs_i = lua_absindex(L, idx);
207-
lua_pushlightuserdata(L, p as *mut c_void);
208-
lua_rawget(L, abs_i)
206+
lua_rawgetptagged(L, idx, p, 0)
209207
}
210208

211209
#[inline(always)]
@@ -239,11 +237,7 @@ pub unsafe fn lua_rawseti(L: *mut lua_State, idx: c_int, n: lua_Integer) {
239237

240238
#[inline(always)]
241239
pub unsafe fn lua_rawsetp(L: *mut lua_State, idx: c_int, p: *const c_void) {
242-
let abs_i = lua_absindex(L, idx);
243-
luaL_checkstack(L, 1, cstr!("not enough stack slots available"));
244-
lua_pushlightuserdata(L, p as *mut c_void);
245-
lua_insert(L, -2);
246-
lua_rawset(L, abs_i);
240+
lua_rawsetptagged(L, idx, p, 0)
247241
}
248242

249243
#[inline(always)]

mlua-sys/src/luau/lua.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ unsafe extern "C-unwind" {
203203
pub fn lua_rawget(L: *mut lua_State, idx: c_int) -> c_int;
204204
#[link_name = "lua_rawgeti"]
205205
pub fn lua_rawgeti_(L: *mut lua_State, idx: c_int, n: c_int) -> c_int;
206+
pub fn lua_rawgetptagged(L: *mut lua_State, idx: c_int, p: *const c_void, tag: c_int) -> c_int;
206207
pub fn lua_createtable(L: *mut lua_State, narr: c_int, nrec: c_int);
207208

208209
pub fn lua_setreadonly(L: *mut lua_State, idx: c_int, enabled: c_int);
@@ -220,6 +221,7 @@ unsafe extern "C-unwind" {
220221
pub fn lua_rawset(L: *mut lua_State, idx: c_int);
221222
#[link_name = "lua_rawseti"]
222223
pub fn lua_rawseti_(L: *mut lua_State, idx: c_int, n: c_int);
224+
pub fn lua_rawsetptagged(L: *mut lua_State, idx: c_int, p: *const c_void, tag: c_int);
223225
pub fn lua_setmetatable(L: *mut lua_State, objindex: c_int) -> c_int;
224226
pub fn lua_setfenv(L: *mut lua_State, idx: c_int) -> c_int;
225227

@@ -545,4 +547,9 @@ unsafe extern "C" {
545547
unsafe extern "C" {
546548
pub fn luau_setfflag(name: *const c_char, value: c_int) -> c_int;
547549
pub fn lua_getmetatablepointer(L: *mut lua_State, idx: c_int) -> *const c_void;
550+
pub fn lua_gcdump(
551+
L: *mut lua_State,
552+
file: *mut c_void,
553+
category_name: Option<unsafe extern "C" fn(L: *mut lua_State, memcat: u8) -> *const c_char>,
554+
);
548555
}

mlua-sys/src/luau/luarequire.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ pub enum luarequire_WriteResult {
2323
Failure,
2424
}
2525

26+
/// Represents whether a configuration file is present, and if so, its syntax.
27+
#[repr(C)]
28+
pub enum luarequire_ConfigStatus {
29+
Absent,
30+
// Signals the presence of multiple configuration files
31+
Ambiguous,
32+
PresentJson,
33+
PresentLuau,
34+
}
35+
2636
#[repr(C)]
2737
pub struct luarequire_Configuration {
2838
// Returns whether requires are permitted from the given chunkname.
@@ -90,13 +100,14 @@ pub struct luarequire_Configuration {
90100
size_out: *mut usize,
91101
) -> luarequire_WriteResult,
92102

93-
// Returns whether a configuration file is present in the current context.
94-
// If not, require-by-string will call to_parent until either a configuration file is present or
103+
// Returns whether a configuration file is present in the current context, and if so, its syntax.
104+
// If not present, require-by-string will call to_parent until either a configuration file is present or
95105
// NAVIGATE_FAILURE is returned (at root).
96-
pub is_config_present: unsafe extern "C-unwind" fn(L: *mut lua_State, ctx: *mut c_void) -> bool,
106+
pub get_config_status:
107+
unsafe extern "C-unwind" fn(L: *mut lua_State, ctx: *mut c_void) -> luarequire_ConfigStatus,
97108

98109
// Parses the configuration file in the current context for the given alias and returns its
99-
// value or WRITE_FAILURE if not found. This function is only called if is_config_present
110+
// value or WRITE_FAILURE if not found. This function is only called if get_config_status
100111
// returns true. If this function pointer is set, get_config must not be set. Opting in to this
101112
// function pointer disables parsing configuration files internally and can be used for finer
102113
// control over the configuration file parsing process.
@@ -111,9 +122,10 @@ pub struct luarequire_Configuration {
111122
) -> luarequire_WriteResult,
112123
>,
113124

114-
// Provides the contents of the configuration file in the current context. This function is only called
115-
// if is_config_present returns true. If this function pointer is set, get_alias must not be set. Opting
116-
// in to this function pointer enables parsing configuration files internally.
125+
// Provides the contents of the configuration file in the current context.
126+
// This function is only called if get_config_status does not return CONFIG_ABSENT. If this function
127+
// pointer is set, get_alias must not be set. Opting in to this function pointer enables parsing
128+
// configuration files internally.
117129
pub get_config: Option<
118130
unsafe extern "C-unwind" fn(
119131
L: *mut lua_State,
@@ -124,6 +136,13 @@ pub struct luarequire_Configuration {
124136
) -> luarequire_WriteResult,
125137
>,
126138

139+
// Returns the maximum number of milliseconds to allow for executing a given Luau-syntax configuration
140+
// file. This function is only called if get_config_status returns CONFIG_PRESENT_LUAU and can be left
141+
// undefined if support for Luau-syntax configuration files is not needed. A default value of 2000ms is
142+
// used. Negative values are treated as infinite.
143+
pub get_luau_config_timeout:
144+
Option<unsafe extern "C-unwind" fn(L: *mut lua_State, ctx: *mut c_void) -> c_int>,
145+
127146
// Executes the module and places the result on the stack. Returns the number of results placed on the
128147
// stack.
129148
// Returning -1 directs the requiring thread to yield. In this case, this thread should be resumed with

0 commit comments

Comments
 (0)