Skip to content

Commit e19a5b6

Browse files
committed
Cleanup max upvalues constant a bit, add some luaconf.h assumptions
1 parent d78420b commit e19a5b6

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ default = ["builtin-lua"]
2121
# * LUA_INTEGER is long long
2222
# * LUA_NUMBER as double
2323
# * LUA_EXTRASPACE is sizeof(void*)
24+
# * LUAI_MAXSTACK is 1000000
2425
builtin-lua = ["gcc"]
2526

2627
[dependencies]

src/ffi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub const LUAI_MAXSTACK: c_int = 1_000_000;
3434
pub const LUA_REGISTRYINDEX: c_int = -LUAI_MAXSTACK - 1000;
3535
pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1;
3636
pub const LUA_RIDX_GLOBALS: lua_Integer = 2;
37+
// Not actually defined in lua.h / luaconf.h
38+
pub const LUA_MAX_UPVALUES: c_int = 255;
3739

3840
pub const LUA_TNONE: c_int = -1;
3941
pub const LUA_TNIL: c_int = 0;

src/function.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,10 @@ impl<'lua> Function<'lua> {
146146
let lua = self.0.lua;
147147
unsafe {
148148
stack_err_guard(lua.state, 0, || {
149-
const MAX_LUA_UPVALUES: c_int = 255;
150-
151149
let args = args.to_lua_multi(lua)?;
152150
let nargs = args.len() as c_int;
153151

154-
if nargs + 2 > MAX_LUA_UPVALUES {
152+
if nargs + 2 > ffi::LUA_MAX_UPVALUES {
155153
return Err(Error::BindError);
156154
}
157155

0 commit comments

Comments
 (0)