Lua 5.4 FFI
This commit is contained in:
parent
d366ce0dd4
commit
5c226b4915
|
@ -29,6 +29,7 @@ members = [
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["lua53"]
|
default = ["lua53"]
|
||||||
|
lua54 = []
|
||||||
lua53 = []
|
lua53 = []
|
||||||
lua52 = []
|
lua52 = []
|
||||||
lua51 = []
|
lua51 = []
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -53,7 +53,7 @@ typedef struct rs_item {
|
||||||
#define RS_INT(name, val) \
|
#define RS_INT(name, val) \
|
||||||
{ TY_INT, name, .int_val = val }
|
{ TY_INT, name, .int_val = val }
|
||||||
|
|
||||||
#if LUA_VERSION_NUM == 503
|
#if LUA_VERSION_NUM >= 503
|
||||||
#define TY_LUAINT 1
|
#define TY_LUAINT 1
|
||||||
#define RS_LUAINT(name, val) \
|
#define RS_LUAINT(name, val) \
|
||||||
{ TY_LUAINT, name, .lua_int_val = val }
|
{ TY_LUAINT, name, .lua_int_val = val }
|
||||||
|
@ -139,7 +139,7 @@ int write_int_item(FILE *f, const char *name, int value) {
|
||||||
return fprintf(f, "pub const %s: c_int = %d;\n", name, value);
|
return fprintf(f, "pub const %s: c_int = %d;\n", name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LUA_VERSION_NUM == 503
|
#if LUA_VERSION_NUM >= 503
|
||||||
int write_lua_int_item(FILE *f, const char *name, LUA_INTEGER value) {
|
int write_lua_int_item(FILE *f, const char *name, LUA_INTEGER value) {
|
||||||
return fprintf(f, "pub const %s: LUA_INTEGER = " LUA_INTEGER_FMT ";\n", name,
|
return fprintf(f, "pub const %s: LUA_INTEGER = " LUA_INTEGER_FMT ";\n", name,
|
||||||
value);
|
value);
|
||||||
|
@ -171,7 +171,7 @@ int write_item(FILE *f, const rs_item *c) {
|
||||||
switch (c->type) {
|
switch (c->type) {
|
||||||
case TY_INT:
|
case TY_INT:
|
||||||
return write_int_item(f, c->name, c->int_val);
|
return write_int_item(f, c->name, c->int_val);
|
||||||
#if LUA_VERSION_NUM == 503
|
#if LUA_VERSION_NUM >= 503
|
||||||
case TY_LUAINT:
|
case TY_LUAINT:
|
||||||
return write_lua_int_item(f, c->name, c->lua_int_val);
|
return write_lua_int_item(f, c->name, c->lua_int_val);
|
||||||
#endif
|
#endif
|
||||||
|
@ -251,7 +251,7 @@ int main(int argc, const char **argv) {
|
||||||
// == lauxlib.h ==========================================================
|
// == lauxlib.h ==========================================================
|
||||||
|
|
||||||
RS_COMMENT("lauxlib.h"),
|
RS_COMMENT("lauxlib.h"),
|
||||||
#if LUA_VERSION_NUM == 503
|
#if LUA_VERSION_NUM >= 503
|
||||||
RS_INT("LUAL_NUMSIZES", LUAL_NUMSIZES),
|
RS_INT("LUAL_NUMSIZES", LUAL_NUMSIZES),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -28,7 +28,7 @@ use std::ptr;
|
||||||
|
|
||||||
use super::lua::{self, lua_CFunction, lua_Integer, lua_Number, lua_State};
|
use super::lua::{self, lua_CFunction, lua_Integer, lua_Number, lua_State};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use super::glue::LUAL_NUMSIZES;
|
pub use super::glue::LUAL_NUMSIZES;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
|
@ -49,10 +49,10 @@ pub struct luaL_Reg {
|
||||||
pub func: lua_CFunction,
|
pub func: lua_CFunction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn luaL_checkversion(L: *mut lua_State) {
|
pub unsafe fn luaL_checkversion(L: *mut lua_State) {
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
luaL_checkversion_(
|
luaL_checkversion_(
|
||||||
L,
|
L,
|
||||||
lua::LUA_VERSION_NUM as lua_Number,
|
lua::LUA_VERSION_NUM as lua_Number,
|
||||||
|
@ -63,19 +63,19 @@ pub unsafe fn luaL_checkversion(L: *mut lua_State) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize);
|
pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize);
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number);
|
pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaL_getmetafield(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
pub fn luaL_getmetafield(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "luaL_getmetafield"]
|
#[link_name = "luaL_getmetafield"]
|
||||||
pub fn luaL_getmetafield_old(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
pub fn luaL_getmetafield_old(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
||||||
|
|
||||||
pub fn luaL_callmeta(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
pub fn luaL_callmeta(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaL_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char;
|
pub fn luaL_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char;
|
||||||
pub fn luaL_argerror(L: *mut lua_State, arg: c_int, l: *const c_char) -> c_int;
|
pub fn luaL_argerror(L: *mut lua_State, arg: c_int, l: *const c_char) -> c_int;
|
||||||
pub fn luaL_checklstring(L: *mut lua_State, arg: c_int, l: *mut usize) -> *const c_char;
|
pub fn luaL_checklstring(L: *mut lua_State, arg: c_int, l: *mut usize) -> *const c_char;
|
||||||
|
@ -90,20 +90,20 @@ extern "C" {
|
||||||
pub fn luaL_checkinteger(L: *mut lua_State, arg: c_int) -> lua_Integer;
|
pub fn luaL_checkinteger(L: *mut lua_State, arg: c_int) -> lua_Integer;
|
||||||
pub fn luaL_optinteger(L: *mut lua_State, arg: c_int, def: lua_Integer) -> lua_Integer;
|
pub fn luaL_optinteger(L: *mut lua_State, arg: c_int, def: lua_Integer) -> lua_Integer;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_checkstack(L: *mut lua_State, sz: c_int, msg: *const c_char);
|
pub fn luaL_checkstack(L: *mut lua_State, sz: c_int, msg: *const c_char);
|
||||||
pub fn luaL_checktype(L: *mut lua_State, arg: c_int, t: c_int);
|
pub fn luaL_checktype(L: *mut lua_State, arg: c_int, t: c_int);
|
||||||
pub fn luaL_checkany(L: *mut lua_State, arg: c_int);
|
pub fn luaL_checkany(L: *mut lua_State, arg: c_int);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaL_newmetatable(L: *mut lua_State, tname: *const c_char) -> c_int;
|
pub fn luaL_newmetatable(L: *mut lua_State, tname: *const c_char) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "luaL_newmetatable"]
|
#[link_name = "luaL_newmetatable"]
|
||||||
pub fn luaL_newmetatable_old(L: *mut lua_State, tname: *const c_char) -> c_int;
|
pub fn luaL_newmetatable_old(L: *mut lua_State, tname: *const c_char) -> c_int;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_setmetatable(L: *mut lua_State, tname: *const c_char);
|
pub fn luaL_setmetatable(L: *mut lua_State, tname: *const c_char);
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_testudata(L: *mut lua_State, ud: c_int, tname: *const c_char) -> *mut c_void;
|
pub fn luaL_testudata(L: *mut lua_State, ud: c_int, tname: *const c_char) -> *mut c_void;
|
||||||
pub fn luaL_checkudata(L: *mut lua_State, ud: c_int, tname: *const c_char) -> *mut c_void;
|
pub fn luaL_checkudata(L: *mut lua_State, ud: c_int, tname: *const c_char) -> *mut c_void;
|
||||||
|
|
||||||
|
@ -118,9 +118,9 @@ extern "C" {
|
||||||
lst: *const *const c_char,
|
lst: *const *const c_char,
|
||||||
) -> c_int;
|
) -> c_int;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_fileresult(L: *mut lua_State, stat: c_int, fname: *const c_char) -> c_int;
|
pub fn luaL_fileresult(L: *mut lua_State, stat: c_int, fname: *const c_char) -> c_int;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_execresult(L: *mut lua_State, stat: c_int) -> c_int;
|
pub fn luaL_execresult(L: *mut lua_State, stat: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,21 +132,21 @@ extern "C" {
|
||||||
pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int;
|
pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int;
|
||||||
pub fn luaL_unref(L: *mut lua_State, t: c_int, r: c_int);
|
pub fn luaL_unref(L: *mut lua_State, t: c_int, r: c_int);
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_loadfilex(L: *mut lua_State, filename: *const c_char, mode: *const c_char)
|
pub fn luaL_loadfilex(L: *mut lua_State, filename: *const c_char, mode: *const c_char)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn luaL_loadfile(L: *mut lua_State, filename: *const c_char) -> c_int;
|
pub fn luaL_loadfile(L: *mut lua_State, filename: *const c_char) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int {
|
pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int {
|
||||||
luaL_loadfilex(L, f, ptr::null())
|
luaL_loadfilex(L, f, ptr::null())
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_loadbufferx(
|
pub fn luaL_loadbufferx(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
buff: *const c_char,
|
buff: *const c_char,
|
||||||
|
@ -165,9 +165,11 @@ extern "C" {
|
||||||
|
|
||||||
pub fn luaL_newstate() -> *mut lua_State;
|
pub fn luaL_newstate() -> *mut lua_State;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_len(L: *mut lua_State, idx: c_int) -> lua_Integer;
|
pub fn luaL_len(L: *mut lua_State, idx: c_int) -> lua_Integer;
|
||||||
|
|
||||||
|
// TODO (lua54): luaL_addgsub
|
||||||
|
|
||||||
pub fn luaL_gsub(
|
pub fn luaL_gsub(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
s: *const c_char,
|
s: *const c_char,
|
||||||
|
@ -175,17 +177,17 @@ extern "C" {
|
||||||
r: *const c_char,
|
r: *const c_char,
|
||||||
) -> *const c_char;
|
) -> *const c_char;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_setfuncs(L: *mut lua_State, l: *const luaL_Reg, nup: c_int);
|
pub fn luaL_setfuncs(L: *mut lua_State, l: *const luaL_Reg, nup: c_int);
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_getsubtable(L: *mut lua_State, idx: c_int, fname: *const c_char) -> c_int;
|
pub fn luaL_getsubtable(L: *mut lua_State, idx: c_int, fname: *const c_char) -> c_int;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaL_traceback(L: *mut lua_State, L1: *mut lua_State, msg: *const c_char, level: c_int);
|
pub fn luaL_traceback(L: *mut lua_State, L1: *mut lua_State, msg: *const c_char, level: c_int);
|
||||||
|
|
||||||
// Skip Lua 5.2 implementation in favor of the compat53 one
|
// Skip Lua 5.2 implementation in favor of the compat53 one
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaL_requiref(
|
pub fn luaL_requiref(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
modname: *const c_char,
|
modname: *const c_char,
|
||||||
|
@ -288,7 +290,7 @@ pub unsafe fn luaL_getmetatable(L: *mut lua_State, n: *const c_char) {
|
||||||
|
|
||||||
// luaL_opt would be implemented here but it is undocumented, so it's omitted
|
// luaL_opt would be implemented here but it is undocumented, so it's omitted
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn luaL_loadbuffer(
|
pub unsafe fn luaL_loadbuffer(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
|
@ -301,4 +303,4 @@ pub unsafe fn luaL_loadbuffer(
|
||||||
|
|
||||||
// TODO: Add buffer API
|
// TODO: Add buffer API
|
||||||
|
|
||||||
// omitted: old module system compatibility
|
// omitted: old module system compatibility (removed in 5.4)
|
||||||
|
|
231
src/ffi/lua.rs
231
src/ffi/lua.rs
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -23,9 +23,11 @@
|
||||||
|
|
||||||
//! Contains definitions from `lua.h`.
|
//! Contains definitions from `lua.h`.
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
use std::os::raw::c_uchar;
|
use std::os::raw::c_uchar;
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
use std::os::raw::{c_uint, c_ushort};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use super::luaconf;
|
use super::luaconf;
|
||||||
|
@ -51,13 +53,14 @@ pub use super::compat53::{
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub use super::compat53::{
|
pub use super::compat53::{
|
||||||
lua_absindex, lua_arith, lua_compare, lua_copy, lua_len, lua_pushglobaltable, lua_pushstring,
|
lua_absindex, lua_arith, lua_compare, lua_copy, lua_len, lua_pushglobaltable, lua_pushstring,
|
||||||
lua_rawlen, lua_rawsetp, lua_resume, lua_setuservalue, lua_tonumberx, lua_upvalueindex,
|
lua_rawlen, lua_rawsetp, lua_resume as lua_resume_53, lua_setuservalue, lua_tonumberx,
|
||||||
|
lua_upvalueindex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
pub use super::compat53::lua_getglobal;
|
pub use super::compat53::lua_getglobal;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lua_upvalueindex(i: c_int) -> c_int {
|
pub fn lua_upvalueindex(i: c_int) -> c_int {
|
||||||
LUA_REGISTRYINDEX - i
|
LUA_REGISTRYINDEX - i
|
||||||
|
@ -71,7 +74,7 @@ pub const LUA_ERRSYNTAX: c_int = 3;
|
||||||
pub const LUA_ERRMEM: c_int = 4;
|
pub const LUA_ERRMEM: c_int = 4;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_ERRGCMM: c_int = 5;
|
pub const LUA_ERRGCMM: c_int = 5;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua54", feature = "lua51", feature = "luajit"))]
|
||||||
pub const LUA_ERRERR: c_int = 5;
|
pub const LUA_ERRERR: c_int = 5;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_ERRERR: c_int = 6;
|
pub const LUA_ERRERR: c_int = 6;
|
||||||
|
@ -91,6 +94,8 @@ pub const LUA_TFUNCTION: c_int = 6;
|
||||||
pub const LUA_TUSERDATA: c_int = 7;
|
pub const LUA_TUSERDATA: c_int = 7;
|
||||||
pub const LUA_TTHREAD: c_int = 8;
|
pub const LUA_TTHREAD: c_int = 8;
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub const LUA_NUMTYPES: c_int = 9;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_NUMTAGS: c_int = 9;
|
pub const LUA_NUMTAGS: c_int = 9;
|
||||||
|
|
||||||
|
@ -98,11 +103,11 @@ pub const LUA_NUMTAGS: c_int = 9;
|
||||||
pub const LUA_MINSTACK: c_int = 20;
|
pub const LUA_MINSTACK: c_int = 20;
|
||||||
|
|
||||||
// predefined values in the registry
|
// predefined values in the registry
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1;
|
pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_RIDX_GLOBALS: lua_Integer = 2;
|
pub const LUA_RIDX_GLOBALS: lua_Integer = 2;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_RIDX_LAST: lua_Integer = LUA_RIDX_GLOBALS;
|
pub const LUA_RIDX_LAST: lua_Integer = LUA_RIDX_GLOBALS;
|
||||||
|
|
||||||
/// A Lua number, usually equivalent to `f64`.
|
/// A Lua number, usually equivalent to `f64`.
|
||||||
|
@ -115,14 +120,14 @@ pub type lua_Integer = luaconf::LUA_INTEGER;
|
||||||
pub type lua_Unsigned = luaconf::LUA_UNSIGNED;
|
pub type lua_Unsigned = luaconf::LUA_UNSIGNED;
|
||||||
|
|
||||||
// type for continuation-function contexts
|
// type for continuation-function contexts
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub type lua_KContext = luaconf::LUA_KCONTEXT;
|
pub type lua_KContext = luaconf::LUA_KCONTEXT;
|
||||||
|
|
||||||
/// Type for native functions that can be passed to Lua.
|
/// Type for native functions that can be passed to Lua.
|
||||||
pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int;
|
pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int;
|
||||||
|
|
||||||
// Type for continuation functions
|
// Type for continuation functions
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub type lua_KFunction =
|
pub type lua_KFunction =
|
||||||
unsafe extern "C" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int;
|
unsafe extern "C" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int;
|
||||||
|
|
||||||
|
@ -132,7 +137,7 @@ pub type lua_Reader =
|
||||||
pub type lua_Writer =
|
pub type lua_Writer =
|
||||||
unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
|
unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int;
|
||||||
|
|
||||||
/// Type for memory-allocation functions.
|
// Type for memory-allocation functions.
|
||||||
pub type lua_Alloc = unsafe extern "C" fn(
|
pub type lua_Alloc = unsafe extern "C" fn(
|
||||||
ud: *mut c_void,
|
ud: *mut c_void,
|
||||||
ptr: *mut c_void,
|
ptr: *mut c_void,
|
||||||
|
@ -140,19 +145,28 @@ pub type lua_Alloc = unsafe extern "C" fn(
|
||||||
nsize: usize,
|
nsize: usize,
|
||||||
) -> *mut c_void;
|
) -> *mut c_void;
|
||||||
|
|
||||||
|
// Type for warning functions
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub type lua_WarnFunction =
|
||||||
|
unsafe extern "C" fn(ud: *mut c_void, msg: *const c_char, tocont: c_int);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// state manipulation
|
// state manipulation
|
||||||
pub fn lua_newstate(f: lua_Alloc, ud: *mut c_void) -> *mut lua_State;
|
pub fn lua_newstate(f: lua_Alloc, ud: *mut c_void) -> *mut lua_State;
|
||||||
pub fn lua_close(L: *mut lua_State);
|
pub fn lua_close(L: *mut lua_State);
|
||||||
pub fn lua_newthread(L: *mut lua_State) -> *mut lua_State;
|
pub fn lua_newthread(L: *mut lua_State) -> *mut lua_State;
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_resetthread(L: *mut lua_State) -> c_int;
|
||||||
|
|
||||||
pub fn lua_atpanic(L: *mut lua_State, panicf: lua_CFunction) -> lua_CFunction;
|
pub fn lua_atpanic(L: *mut lua_State, panicf: lua_CFunction) -> lua_CFunction;
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_version(L: *mut lua_State) -> lua_Number;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(feature = "lua53")]
|
||||||
pub fn lua_version(L: *mut lua_State) -> *const lua_Number;
|
pub fn lua_version(L: *mut lua_State) -> *const lua_Number;
|
||||||
|
|
||||||
// basic stack manipulation
|
// basic stack manipulation
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_absindex(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_absindex(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_gettop(L: *mut lua_State) -> c_int;
|
pub fn lua_gettop(L: *mut lua_State) -> c_int;
|
||||||
pub fn lua_settop(L: *mut lua_State, idx: c_int);
|
pub fn lua_settop(L: *mut lua_State, idx: c_int);
|
||||||
|
@ -163,9 +177,9 @@ extern "C" {
|
||||||
pub fn lua_insert(L: *mut lua_State, idx: c_int);
|
pub fn lua_insert(L: *mut lua_State, idx: c_int);
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_replace(L: *mut lua_State, idx: c_int);
|
pub fn lua_replace(L: *mut lua_State, idx: c_int);
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_rotate(L: *mut lua_State, idx: c_int, n: c_int);
|
pub fn lua_rotate(L: *mut lua_State, idx: c_int, n: c_int);
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_copy(L: *mut lua_State, fromidx: c_int, toidx: c_int);
|
pub fn lua_copy(L: *mut lua_State, fromidx: c_int, toidx: c_int);
|
||||||
pub fn lua_checkstack(L: *mut lua_State, sz: c_int) -> c_int;
|
pub fn lua_checkstack(L: *mut lua_State, sz: c_int) -> c_int;
|
||||||
|
|
||||||
|
@ -175,7 +189,7 @@ extern "C" {
|
||||||
pub fn lua_isnumber(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_isnumber(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_isstring(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_isstring(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_iscfunction(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_iscfunction(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_isinteger(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_isinteger(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_isuserdata(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_isuserdata(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_type(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_type(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
|
@ -183,17 +197,17 @@ extern "C" {
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_tonumber(L: *mut lua_State, idx: c_int) -> lua_Number;
|
pub fn lua_tonumber(L: *mut lua_State, idx: c_int) -> lua_Number;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_tonumberx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Number;
|
pub fn lua_tonumberx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Number;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_tointeger(L: *mut lua_State, idx: c_int) -> lua_Integer;
|
pub fn lua_tointeger(L: *mut lua_State, idx: c_int) -> lua_Integer;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_tointegerx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Integer;
|
pub fn lua_tointegerx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Integer;
|
||||||
pub fn lua_toboolean(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_toboolean(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char;
|
pub fn lua_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_objlen(L: *mut lua_State, idx: c_int) -> usize;
|
pub fn lua_objlen(L: *mut lua_State, idx: c_int) -> usize;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_rawlen(L: *mut lua_State, idx: c_int) -> usize;
|
pub fn lua_rawlen(L: *mut lua_State, idx: c_int) -> usize;
|
||||||
pub fn lua_tocfunction(L: *mut lua_State, idx: c_int) -> lua_CFunction;
|
pub fn lua_tocfunction(L: *mut lua_State, idx: c_int) -> lua_CFunction;
|
||||||
pub fn lua_touserdata(L: *mut lua_State, idx: c_int) -> *mut c_void;
|
pub fn lua_touserdata(L: *mut lua_State, idx: c_int) -> *mut c_void;
|
||||||
|
@ -215,31 +229,31 @@ pub const LUA_OPPOW: c_int = 5;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
pub const LUA_OPUNM: c_int = 6;
|
pub const LUA_OPUNM: c_int = 6;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPMOD: c_int = 3;
|
pub const LUA_OPMOD: c_int = 3;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPPOW: c_int = 4;
|
pub const LUA_OPPOW: c_int = 4;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPDIV: c_int = 5;
|
pub const LUA_OPDIV: c_int = 5;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPIDIV: c_int = 6;
|
pub const LUA_OPIDIV: c_int = 6;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPBAND: c_int = 7;
|
pub const LUA_OPBAND: c_int = 7;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPBOR: c_int = 8;
|
pub const LUA_OPBOR: c_int = 8;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPBXOR: c_int = 9;
|
pub const LUA_OPBXOR: c_int = 9;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPSHL: c_int = 10;
|
pub const LUA_OPSHL: c_int = 10;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPSHR: c_int = 11;
|
pub const LUA_OPSHR: c_int = 11;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPUNM: c_int = 12;
|
pub const LUA_OPUNM: c_int = 12;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub const LUA_OPBNOT: c_int = 13;
|
pub const LUA_OPBNOT: c_int = 13;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_arith(L: *mut lua_State, op: c_int);
|
pub fn lua_arith(L: *mut lua_State, op: c_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +267,7 @@ extern "C" {
|
||||||
pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int;
|
pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_lessthan(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int;
|
pub fn lua_lessthan(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int;
|
pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,13 +277,13 @@ extern "C" {
|
||||||
pub fn lua_pushnumber(L: *mut lua_State, n: lua_Number);
|
pub fn lua_pushnumber(L: *mut lua_State, n: lua_Number);
|
||||||
pub fn lua_pushinteger(L: *mut lua_State, n: lua_Integer);
|
pub fn lua_pushinteger(L: *mut lua_State, n: lua_Integer);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_pushlstring(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char;
|
pub fn lua_pushlstring(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_pushlstring"]
|
#[link_name = "lua_pushlstring"]
|
||||||
pub fn lua_pushlstring_old(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char;
|
pub fn lua_pushlstring_old(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_pushstring(L: *mut lua_State, s: *const c_char) -> *const c_char;
|
pub fn lua_pushstring(L: *mut lua_State, s: *const c_char) -> *const c_char;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_pushstring"]
|
#[link_name = "lua_pushstring"]
|
||||||
|
@ -286,49 +300,59 @@ extern "C" {
|
||||||
|
|
||||||
// get functions (Lua -> stack)
|
// get functions (Lua -> stack)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_getglobal(L: *mut lua_State, var: *const c_char) -> c_int;
|
pub fn lua_getglobal(L: *mut lua_State, var: *const c_char) -> c_int;
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
#[link_name = "lua_getglobal"]
|
#[link_name = "lua_getglobal"]
|
||||||
pub fn lua_getglobal_old(L: *mut lua_State, var: *const c_char);
|
pub fn lua_getglobal_old(L: *mut lua_State, var: *const c_char);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_gettable(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_gettable(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_gettable"]
|
#[link_name = "lua_gettable"]
|
||||||
pub fn lua_gettable_old(L: *mut lua_State, idx: c_int);
|
pub fn lua_gettable_old(L: *mut lua_State, idx: c_int);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_getfield(L: *mut lua_State, idx: c_int, k: *const c_char) -> c_int;
|
pub fn lua_getfield(L: *mut lua_State, idx: c_int, k: *const c_char) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_getfield"]
|
#[link_name = "lua_getfield"]
|
||||||
pub fn lua_getfield_old(L: *mut lua_State, idx: c_int, k: *const c_char);
|
pub fn lua_getfield_old(L: *mut lua_State, idx: c_int, k: *const c_char);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_geti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_int;
|
pub fn lua_geti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_int;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_rawget(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_rawget(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_rawget"]
|
#[link_name = "lua_rawget"]
|
||||||
pub fn lua_rawget_old(L: *mut lua_State, idx: c_int);
|
pub fn lua_rawget_old(L: *mut lua_State, idx: c_int);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_rawgeti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_int;
|
pub fn lua_rawgeti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_int;
|
||||||
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_rawgeti"]
|
#[link_name = "lua_rawgeti"]
|
||||||
pub fn lua_rawgeti_old(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
pub fn lua_rawgeti_old(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_rawgetp(L: *mut lua_State, idx: c_int, p: *const c_void) -> c_int;
|
pub fn lua_rawgetp(L: *mut lua_State, idx: c_int, p: *const c_void) -> c_int;
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
#[link_name = "lua_rawgetp"]
|
#[link_name = "lua_rawgetp"]
|
||||||
pub fn lua_rawgetp_old(L: *mut lua_State, idx: c_int, p: *const c_void);
|
pub fn lua_rawgetp_old(L: *mut lua_State, idx: c_int, p: *const c_void);
|
||||||
|
|
||||||
pub fn lua_createtable(L: *mut lua_State, narr: c_int, nrec: c_int);
|
pub fn lua_createtable(L: *mut lua_State, narr: c_int, nrec: c_int);
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_newuserdatauv(L: *mut lua_State, sz: usize, nuvalue: c_int) -> *mut c_void;
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "lua53",
|
||||||
|
feature = "lua52",
|
||||||
|
feature = "lua51",
|
||||||
|
feature = "luajit"
|
||||||
|
))]
|
||||||
pub fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut c_void;
|
pub fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut c_void;
|
||||||
pub fn lua_getmetatable(L: *mut lua_State, objindex: c_int) -> c_int;
|
pub fn lua_getmetatable(L: *mut lua_State, objindex: c_int) -> c_int;
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_getiuservalue(L: *mut lua_State, idx: c_int, n: c_int) -> c_int;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(feature = "lua53")]
|
||||||
pub fn lua_getuservalue(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_getuservalue(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
|
@ -338,28 +362,48 @@ extern "C" {
|
||||||
pub fn lua_getfenv(L: *mut lua_State, idx: c_int);
|
pub fn lua_getfenv(L: *mut lua_State, idx: c_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut c_void {
|
||||||
|
lua_newuserdatauv(L, sz, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn lua_getuservalue(L: *mut lua_State, idx: c_int) -> c_int {
|
||||||
|
lua_getiuservalue(L, idx, 1)
|
||||||
|
}
|
||||||
|
|
||||||
// set functions (stack -> Lua)
|
// set functions (stack -> Lua)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_setglobal(L: *mut lua_State, var: *const c_char);
|
pub fn lua_setglobal(L: *mut lua_State, var: *const c_char);
|
||||||
pub fn lua_settable(L: *mut lua_State, idx: c_int);
|
pub fn lua_settable(L: *mut lua_State, idx: c_int);
|
||||||
pub fn lua_setfield(L: *mut lua_State, idx: c_int, k: *const c_char);
|
pub fn lua_setfield(L: *mut lua_State, idx: c_int, k: *const c_char);
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_seti(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
pub fn lua_seti(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
||||||
pub fn lua_rawset(L: *mut lua_State, idx: c_int);
|
pub fn lua_rawset(L: *mut lua_State, idx: c_int);
|
||||||
pub fn lua_rawseti(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
pub fn lua_rawseti(L: *mut lua_State, idx: c_int, n: lua_Integer);
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_rawsetp(L: *mut lua_State, idx: c_int, p: *const c_void);
|
pub fn lua_rawsetp(L: *mut lua_State, idx: c_int, p: *const c_void);
|
||||||
pub fn lua_setmetatable(L: *mut lua_State, objindex: c_int) -> c_int;
|
pub fn lua_setmetatable(L: *mut lua_State, objindex: c_int) -> c_int;
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_setiuservalue(L: *mut lua_State, idx: c_int, n: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_setuservalue(L: *mut lua_State, idx: c_int);
|
pub fn lua_setuservalue(L: *mut lua_State, idx: c_int);
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_setfenv(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_setfenv(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn lua_setuservalue(L: *mut lua_State, idx: c_int) {
|
||||||
|
lua_setiuservalue(L, idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// 'load' and 'call' functions (load and run Lua code)
|
// 'load' and 'call' functions (load and run Lua code)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_callk(
|
pub fn lua_callk(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
nargs: c_int,
|
nargs: c_int,
|
||||||
|
@ -376,7 +420,7 @@ extern "C" {
|
||||||
k: Option<lua_CFunction>,
|
k: Option<lua_CFunction>,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_pcallk(
|
pub fn lua_pcallk(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
nargs: c_int,
|
nargs: c_int,
|
||||||
|
@ -412,7 +456,7 @@ extern "C" {
|
||||||
mode: *const c_char,
|
mode: *const c_char,
|
||||||
) -> c_int;
|
) -> c_int;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_dump(
|
pub fn lua_dump(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
writer: lua_Writer,
|
writer: lua_Writer,
|
||||||
|
@ -424,13 +468,13 @@ extern "C" {
|
||||||
pub fn lua_dump_old(L: *mut lua_State, writer: lua_Writer, data: *mut c_void) -> c_int;
|
pub fn lua_dump_old(L: *mut lua_State, writer: lua_Writer, data: *mut c_void) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_call(L: *mut lua_State, n: c_int, r: c_int) {
|
pub unsafe fn lua_call(L: *mut lua_State, n: c_int, r: c_int) {
|
||||||
lua_callk(L, n, r, 0, None)
|
lua_callk(L, n, r, 0, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_int {
|
pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_int {
|
||||||
lua_pcallk(L, n, r, f, 0, None)
|
lua_pcallk(L, n, r, f, 0, None)
|
||||||
|
@ -438,7 +482,7 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in
|
||||||
|
|
||||||
// coroutine functions
|
// coroutine functions
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_yieldk(
|
pub fn lua_yieldk(
|
||||||
L: *mut lua_State,
|
L: *mut lua_State,
|
||||||
nresults: c_int,
|
nresults: c_int,
|
||||||
|
@ -455,23 +499,57 @@ extern "C" {
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub fn lua_yield(L: *mut lua_State, nresults: c_int) -> c_int;
|
pub fn lua_yield(L: *mut lua_State, nresults: c_int) -> c_int;
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_resume(
|
||||||
|
L: *mut lua_State,
|
||||||
|
from: *mut lua_State,
|
||||||
|
narg: c_int,
|
||||||
|
nres: *mut c_int,
|
||||||
|
) -> c_int;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_resume(L: *mut lua_State, from: *mut lua_State, narg: c_int) -> c_int;
|
#[link_name = "lua_resume"]
|
||||||
|
pub fn lua_resume_53(L: *mut lua_State, from: *mut lua_State, narg: c_int) -> c_int;
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
#[link_name = "lua_resume"]
|
#[link_name = "lua_resume"]
|
||||||
pub fn lua_resume_old(L: *mut lua_State, narg: c_int) -> c_int;
|
pub fn lua_resume_old(L: *mut lua_State, narg: c_int) -> c_int;
|
||||||
|
|
||||||
pub fn lua_status(L: *mut lua_State) -> c_int;
|
pub fn lua_status(L: *mut lua_State) -> c_int;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_isyieldable(L: *mut lua_State) -> c_int;
|
pub fn lua_isyieldable(L: *mut lua_State) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_yield(L: *mut lua_State, n: c_int) -> c_int {
|
pub unsafe fn lua_yield(L: *mut lua_State, n: c_int) -> c_int {
|
||||||
lua_yieldk(L, n, 0, None)
|
lua_yieldk(L, n, 0, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "lua53",
|
||||||
|
feature = "lua52",
|
||||||
|
feature = "lua51",
|
||||||
|
feature = "luajit"
|
||||||
|
))]
|
||||||
|
pub unsafe fn lua_resume(
|
||||||
|
L: *mut lua_State,
|
||||||
|
from: *mut lua_State,
|
||||||
|
narg: c_int,
|
||||||
|
nres: *mut c_int,
|
||||||
|
) -> c_int {
|
||||||
|
let ret = lua_resume_53(L, from, narg);
|
||||||
|
if ret == LUA_OK || ret == LUA_YIELD {
|
||||||
|
*nres = lua_gettop(L);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// warning-related functions
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
extern "C" {
|
||||||
|
pub fn lua_setwarnf(L: *mut lua_State, f: lua_WarnFunction, ud: *mut c_void);
|
||||||
|
pub fn lua_warning(L: *mut lua_State, msg: *const c_char, tocont: c_int);
|
||||||
|
}
|
||||||
|
|
||||||
// garbage-collection function and options
|
// garbage-collection function and options
|
||||||
pub const LUA_GCSTOP: c_int = 0;
|
pub const LUA_GCSTOP: c_int = 0;
|
||||||
pub const LUA_GCRESTART: c_int = 1;
|
pub const LUA_GCRESTART: c_int = 1;
|
||||||
|
@ -481,10 +559,22 @@ pub const LUA_GCCOUNTB: c_int = 4;
|
||||||
pub const LUA_GCSTEP: c_int = 5;
|
pub const LUA_GCSTEP: c_int = 5;
|
||||||
pub const LUA_GCSETPAUSE: c_int = 6;
|
pub const LUA_GCSETPAUSE: c_int = 6;
|
||||||
pub const LUA_GCSETSTEPMUL: c_int = 7;
|
pub const LUA_GCSETSTEPMUL: c_int = 7;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub const LUA_GCISRUNNING: c_int = 9;
|
pub const LUA_GCISRUNNING: c_int = 9;
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub const LUA_GCGEN: c_int = 10;
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub const LUA_GCINC: c_int = 11;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_gc(L: *mut lua_State, what: c_int, ...) -> c_int;
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "lua53",
|
||||||
|
feature = "lua52",
|
||||||
|
feature = "lua51",
|
||||||
|
feature = "luajit"
|
||||||
|
))]
|
||||||
pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int;
|
pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,29 +583,31 @@ extern "C" {
|
||||||
pub fn lua_error(L: *mut lua_State) -> !;
|
pub fn lua_error(L: *mut lua_State) -> !;
|
||||||
pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int;
|
pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int;
|
||||||
pub fn lua_concat(L: *mut lua_State, n: c_int);
|
pub fn lua_concat(L: *mut lua_State, n: c_int);
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_len(L: *mut lua_State, idx: c_int);
|
pub fn lua_len(L: *mut lua_State, idx: c_int);
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn lua_stringtonumber(L: *mut lua_State, s: *const c_char) -> usize;
|
pub fn lua_stringtonumber(L: *mut lua_State, s: *const c_char) -> usize;
|
||||||
pub fn lua_getallocf(L: *mut lua_State, ud: *mut *mut c_void) -> lua_Alloc;
|
pub fn lua_getallocf(L: *mut lua_State, ud: *mut *mut c_void) -> lua_Alloc;
|
||||||
pub fn lua_setallocf(L: *mut lua_State, f: lua_Alloc, ud: *mut c_void);
|
pub fn lua_setallocf(L: *mut lua_State, f: lua_Alloc, ud: *mut c_void);
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_toclose(L: *mut lua_State, idx: c_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some useful macros
|
// some useful macros
|
||||||
// here, implemented as Rust functions
|
// here, implemented as Rust functions
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_getextraspace(L: *mut lua_State) -> *mut c_void {
|
pub unsafe fn lua_getextraspace(L: *mut lua_State) -> *mut c_void {
|
||||||
L.offset(-super::glue::LUA_EXTRASPACE as isize) as *mut c_void
|
L.offset(-super::glue::LUA_EXTRASPACE as isize) as *mut c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_tonumber(L: *mut lua_State, i: c_int) -> lua_Number {
|
pub unsafe fn lua_tonumber(L: *mut lua_State, i: c_int) -> lua_Number {
|
||||||
lua_tonumberx(L, i, ptr::null_mut())
|
lua_tonumberx(L, i, ptr::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_tointeger(L: *mut lua_State, i: c_int) -> lua_Integer {
|
pub unsafe fn lua_tointeger(L: *mut lua_State, i: c_int) -> lua_Integer {
|
||||||
lua_tointegerx(L, i, ptr::null_mut())
|
lua_tointegerx(L, i, ptr::null_mut())
|
||||||
|
@ -601,7 +693,7 @@ pub unsafe fn lua_getglobal(L: *mut lua_State, var: *const c_char) -> c_int {
|
||||||
lua_getfield(L, LUA_GLOBALSINDEX, var)
|
lua_getfield(L, LUA_GLOBALSINDEX, var)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_pushglobaltable(L: *mut lua_State) -> c_int {
|
pub unsafe fn lua_pushglobaltable(L: *mut lua_State) -> c_int {
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
|
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
|
||||||
|
@ -612,20 +704,20 @@ pub unsafe fn lua_tostring(L: *mut lua_State, i: c_int) -> *const c_char {
|
||||||
lua_tolstring(L, i, ptr::null_mut())
|
lua_tolstring(L, i, ptr::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_insert(L: *mut lua_State, idx: c_int) {
|
pub unsafe fn lua_insert(L: *mut lua_State, idx: c_int) {
|
||||||
lua_rotate(L, idx, 1)
|
lua_rotate(L, idx, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_remove(L: *mut lua_State, idx: c_int) {
|
pub unsafe fn lua_remove(L: *mut lua_State, idx: c_int) {
|
||||||
lua_rotate(L, idx, -1);
|
lua_rotate(L, idx, -1);
|
||||||
lua_pop(L, 1)
|
lua_pop(L, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lua_replace(L: *mut lua_State, idx: c_int) {
|
pub unsafe fn lua_replace(L: *mut lua_State, idx: c_int) {
|
||||||
lua_copy(L, -1, idx);
|
lua_copy(L, -1, idx);
|
||||||
|
@ -657,18 +749,21 @@ extern "C" {
|
||||||
pub fn lua_getupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
|
pub fn lua_getupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
|
||||||
pub fn lua_setupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
|
pub fn lua_setupvalue(L: *mut lua_State, funcindex: c_int, n: c_int) -> *const c_char;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_upvalueid(L: *mut lua_State, fidx: c_int, n: c_int) -> *mut c_void;
|
pub fn lua_upvalueid(L: *mut lua_State, fidx: c_int, n: c_int) -> *mut c_void;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn lua_upvaluejoin(L: *mut lua_State, fidx1: c_int, n1: c_int, fidx2: c_int, n2: c_int);
|
pub fn lua_upvaluejoin(L: *mut lua_State, fidx1: c_int, n1: c_int, fidx2: c_int, n2: c_int);
|
||||||
|
|
||||||
pub fn lua_sethook(L: *mut lua_State, func: lua_Hook, mask: c_int, count: c_int);
|
pub fn lua_sethook(L: *mut lua_State, func: lua_Hook, mask: c_int, count: c_int);
|
||||||
pub fn lua_gethook(L: *mut lua_State) -> Option<lua_Hook>;
|
pub fn lua_gethook(L: *mut lua_State) -> Option<lua_Hook>;
|
||||||
pub fn lua_gethookmask(L: *mut lua_State) -> c_int;
|
pub fn lua_gethookmask(L: *mut lua_State) -> c_int;
|
||||||
pub fn lua_gethookcount(L: *mut lua_State) -> c_int;
|
pub fn lua_gethookcount(L: *mut lua_State) -> c_int;
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub fn lua_setcstacklimit(L: *mut lua_State, limit: c_uint) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct lua_Debug {
|
pub struct lua_Debug {
|
||||||
pub event: c_int,
|
pub event: c_int,
|
||||||
|
@ -676,6 +771,8 @@ pub struct lua_Debug {
|
||||||
pub namewhat: *const c_char,
|
pub namewhat: *const c_char,
|
||||||
pub what: *const c_char,
|
pub what: *const c_char,
|
||||||
pub source: *const c_char,
|
pub source: *const c_char,
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub srclen: usize,
|
||||||
pub currentline: c_int,
|
pub currentline: c_int,
|
||||||
pub linedefined: c_int,
|
pub linedefined: c_int,
|
||||||
pub lastlinedefined: c_int,
|
pub lastlinedefined: c_int,
|
||||||
|
@ -683,6 +780,10 @@ pub struct lua_Debug {
|
||||||
pub nparams: c_uchar,
|
pub nparams: c_uchar,
|
||||||
pub isvararg: c_char,
|
pub isvararg: c_char,
|
||||||
pub istailcall: c_char,
|
pub istailcall: c_char,
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub ftransfer: c_ushort,
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub ntransfer: c_ushort,
|
||||||
pub short_src: [c_char; luaconf::LUA_IDSIZE as usize],
|
pub short_src: [c_char; luaconf::LUA_IDSIZE as usize],
|
||||||
// lua.h mentions this is for private use
|
// lua.h mentions this is for private use
|
||||||
i_ci: *mut c_void,
|
i_ci: *mut c_void,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -30,8 +30,8 @@ pub use super::glue::LUA_UNSIGNED;
|
||||||
|
|
||||||
pub use super::glue::LUA_IDSIZE;
|
pub use super::glue::LUA_IDSIZE;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use super::glue::LUAL_NUMSIZES;
|
pub use super::glue::LUAL_NUMSIZES;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub type LUA_KCONTEXT = isize; // intptr_t
|
pub type LUA_KCONTEXT = isize; // intptr_t
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -32,7 +32,7 @@ pub use super::glue::{
|
||||||
LUA_STRLIBNAME, LUA_TABLIBNAME,
|
LUA_STRLIBNAME, LUA_TABLIBNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use super::glue::LUA_UTF8LIBNAME;
|
pub use super::glue::LUA_UTF8LIBNAME;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua52", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "luajit"))]
|
||||||
|
@ -43,13 +43,13 @@ pub use super::glue::{LUA_FFILIBNAME, LUA_JITLIBNAME};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn luaopen_base(L: *mut lua_State) -> c_int;
|
pub fn luaopen_base(L: *mut lua_State) -> c_int;
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub fn luaopen_coroutine(L: *mut lua_State) -> c_int;
|
pub fn luaopen_coroutine(L: *mut lua_State) -> c_int;
|
||||||
pub fn luaopen_table(L: *mut lua_State) -> c_int;
|
pub fn luaopen_table(L: *mut lua_State) -> c_int;
|
||||||
pub fn luaopen_io(L: *mut lua_State) -> c_int;
|
pub fn luaopen_io(L: *mut lua_State) -> c_int;
|
||||||
pub fn luaopen_os(L: *mut lua_State) -> c_int;
|
pub fn luaopen_os(L: *mut lua_State) -> c_int;
|
||||||
pub fn luaopen_string(L: *mut lua_State) -> c_int;
|
pub fn luaopen_string(L: *mut lua_State) -> c_int;
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub fn luaopen_utf8(L: *mut lua_State) -> c_int;
|
pub fn luaopen_utf8(L: *mut lua_State) -> c_int;
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
pub fn luaopen_bit32(L: *mut lua_State) -> c_int;
|
pub fn luaopen_bit32(L: *mut lua_State) -> c_int;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2019 A. Orlenko
|
// Copyright (c) 2019-2020 A. Orlenko
|
||||||
// Copyright (c) 2014 J.C. Moyer
|
// Copyright (c) 2014 J.C. Moyer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -36,7 +36,10 @@ pub use self::lua::{
|
||||||
lua_Unsigned, lua_Writer,
|
lua_Unsigned, lua_Writer,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(feature = "lua54")]
|
||||||
|
pub use self::lua::lua_WarnFunction;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use self::lua::{lua_KContext, lua_KFunction};
|
pub use self::lua::{lua_KContext, lua_KFunction};
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
|
@ -155,10 +158,16 @@ pub use self::lua::{
|
||||||
lua_yield,
|
lua_yield,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(feature = "lua54")]
|
||||||
|
pub use self::lua::{
|
||||||
|
lua_getiuservalue, lua_newuserdatauv, lua_resetthread, lua_setcstacklimit, lua_setiuservalue,
|
||||||
|
lua_setwarnf, lua_toclose, lua_warning,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use self::lua::{lua_isyieldable, lua_version};
|
pub use self::lua::{lua_isyieldable, lua_version};
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub use self::lua::{lua_callk, lua_pcallk, lua_upvalueid, lua_upvaluejoin, lua_yieldk};
|
pub use self::lua::{lua_callk, lua_pcallk, lua_upvalueid, lua_upvaluejoin, lua_yieldk};
|
||||||
|
|
||||||
// auxiliary library types
|
// auxiliary library types
|
||||||
|
@ -177,7 +186,7 @@ pub use self::lauxlib::{
|
||||||
luaL_where,
|
luaL_where,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
pub use self::lauxlib::{luaL_execresult, luaL_fileresult, luaL_loadfilex};
|
pub use self::lauxlib::{luaL_execresult, luaL_fileresult, luaL_loadfilex};
|
||||||
|
|
||||||
// lualib.h functions
|
// lualib.h functions
|
||||||
|
@ -186,7 +195,7 @@ pub use self::lualib::{
|
||||||
luaopen_package, luaopen_string, luaopen_table,
|
luaopen_package, luaopen_string, luaopen_table,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use self::lualib::{luaopen_coroutine, luaopen_utf8};
|
pub use self::lualib::{luaopen_coroutine, luaopen_utf8};
|
||||||
|
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(feature = "lua52")]
|
||||||
|
@ -206,13 +215,19 @@ pub use self::lua::{
|
||||||
LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, LUA_YIELD,
|
LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, LUA_YIELD,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use self::lua::{
|
pub use self::lua::{
|
||||||
LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPIDIV, LUA_OPSHL, LUA_OPSHR,
|
LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPIDIV, LUA_OPSHL, LUA_OPSHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "lua54")]
|
||||||
|
pub use self::lua::{LUA_GCGEN, LUA_GCINC};
|
||||||
|
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
|
pub use self::lua::{LUA_GCISRUNNING, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD};
|
||||||
|
|
||||||
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua53", feature = "lua52"))]
|
||||||
pub use self::lua::{LUA_ERRGCMM, LUA_GCISRUNNING, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD};
|
pub use self::lua::LUA_ERRGCMM;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub use self::lua::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX};
|
pub use self::lua::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX};
|
||||||
|
@ -226,7 +241,7 @@ pub use self::lualib::{
|
||||||
LUA_STRLIBNAME, LUA_TABLIBNAME,
|
LUA_STRLIBNAME, LUA_TABLIBNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua54", feature = "lua53"))]
|
||||||
pub use self::lualib::LUA_UTF8LIBNAME;
|
pub use self::lualib::LUA_UTF8LIBNAME;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua52", feature = "luajit"))]
|
#[cfg(any(feature = "lua52", feature = "luajit"))]
|
||||||
|
|
Loading…
Reference in New Issue