Cleanup max upvalues constant a bit, add some luaconf.h assumptions

This commit is contained in:
kyren 2018-02-19 18:02:04 -05:00
parent d78420b51c
commit e19a5b6481
3 changed files with 4 additions and 3 deletions

View File

@ -21,6 +21,7 @@ default = ["builtin-lua"]
# * LUA_INTEGER is long long
# * LUA_NUMBER as double
# * LUA_EXTRASPACE is sizeof(void*)
# * LUAI_MAXSTACK is 1000000
builtin-lua = ["gcc"]
[dependencies]

View File

@ -34,6 +34,8 @@ pub const LUAI_MAXSTACK: c_int = 1_000_000;
pub const LUA_REGISTRYINDEX: c_int = -LUAI_MAXSTACK - 1000;
pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1;
pub const LUA_RIDX_GLOBALS: lua_Integer = 2;
// Not actually defined in lua.h / luaconf.h
pub const LUA_MAX_UPVALUES: c_int = 255;
pub const LUA_TNONE: c_int = -1;
pub const LUA_TNIL: c_int = 0;

View File

@ -146,12 +146,10 @@ impl<'lua> Function<'lua> {
let lua = self.0.lua;
unsafe {
stack_err_guard(lua.state, 0, || {
const MAX_LUA_UPVALUES: c_int = 255;
let args = args.to_lua_multi(lua)?;
let nargs = args.len() as c_int;
if nargs + 2 > MAX_LUA_UPVALUES {
if nargs + 2 > ffi::LUA_MAX_UPVALUES {
return Err(Error::BindError);
}