Move ffi module into mlua-sys crate
This commit is contained in:
parent
0c53e09e30
commit
15dc0e9f23
|
@ -14,7 +14,7 @@ jobs:
|
||||||
|
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
cargo tarpaulin --out xml --tests --exclude-files benches/* --exclude-files src/ffi/*/*
|
cargo tarpaulin --out xml --tests --exclude-files benches/*
|
||||||
|
|
||||||
- name: Upload report to codecov.io
|
- name: Upload report to codecov.io
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
|
|
28
Cargo.toml
28
Cargo.toml
|
@ -9,8 +9,6 @@ readme = "README.md"
|
||||||
keywords = ["lua", "luajit", "luau", "async", "scripting"]
|
keywords = ["lua", "luajit", "luau", "async", "scripting"]
|
||||||
categories = ["api-bindings", "asynchronous"]
|
categories = ["api-bindings", "asynchronous"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
links = "lua"
|
|
||||||
build = "build/main.rs"
|
|
||||||
description = """
|
description = """
|
||||||
High level bindings to Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau
|
High level bindings to Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau
|
||||||
with async/await features and support of writing native Lua modules in Rust.
|
with async/await features and support of writing native Lua modules in Rust.
|
||||||
|
@ -23,18 +21,19 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"mlua_derive",
|
"mlua_derive",
|
||||||
|
"mlua-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
lua54 = []
|
lua54 = ["ffi/lua54"]
|
||||||
lua53 = []
|
lua53 = ["ffi/lua53"]
|
||||||
lua52 = []
|
lua52 = ["ffi/lua52"]
|
||||||
lua51 = []
|
lua51 = ["ffi/lua51"]
|
||||||
luajit = []
|
luajit = ["ffi/luajit"]
|
||||||
luajit52 = ["luajit"]
|
luajit52 = ["luajit", "ffi/luajit52"]
|
||||||
luau = ["luau0-src"]
|
luau = ["ffi/luau"]
|
||||||
vendored = ["lua-src", "luajit-src"]
|
vendored = ["ffi/vendored"]
|
||||||
module = ["mlua_derive"]
|
module = ["mlua_derive", "ffi/module"]
|
||||||
async = ["futures-core", "futures-task", "futures-util"]
|
async = ["futures-core", "futures-task", "futures-util"]
|
||||||
send = []
|
send = []
|
||||||
serialize = ["serde", "erased-serde", "serde-value"]
|
serialize = ["serde", "erased-serde", "serde-value"]
|
||||||
|
@ -55,12 +54,7 @@ erased-serde = { version = "0.3", optional = true }
|
||||||
serde-value = { version = "0.7", optional = true }
|
serde-value = { version = "0.7", optional = true }
|
||||||
parking_lot = { version = "0.12", optional = true }
|
parking_lot = { version = "0.12", optional = true }
|
||||||
|
|
||||||
[build-dependencies]
|
ffi = { package = "mlua-sys", version = "0.1.0", path = "mlua-sys" }
|
||||||
cc = { version = "1.0" }
|
|
||||||
pkg-config = { version = "0.3.17" }
|
|
||||||
lua-src = { version = ">= 544.0.0, < 550.0.0", optional = true }
|
|
||||||
luajit-src = { version = ">= 210.4.0, < 220.0.0", optional = true }
|
|
||||||
luau0-src = { version = "0.5.0", optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rustyline = "11.0"
|
rustyline = "11.0"
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
pub fn probe_lua() -> Option<PathBuf> {
|
|
||||||
None
|
|
||||||
}
|
|
115
build/main.rs
115
build/main.rs
|
@ -1,115 +0,0 @@
|
||||||
#[cfg_attr(
|
|
||||||
any(
|
|
||||||
feature = "luau",
|
|
||||||
all(
|
|
||||||
feature = "vendored",
|
|
||||||
any(
|
|
||||||
feature = "lua54",
|
|
||||||
feature = "lua53",
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
path = "find_vendored.rs"
|
|
||||||
)]
|
|
||||||
#[cfg_attr(
|
|
||||||
all(
|
|
||||||
not(feature = "vendored"),
|
|
||||||
any(
|
|
||||||
feature = "lua54",
|
|
||||||
feature = "lua53",
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
path = "find_normal.rs"
|
|
||||||
)]
|
|
||||||
#[cfg_attr(
|
|
||||||
not(any(
|
|
||||||
feature = "lua54",
|
|
||||||
feature = "lua53",
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit",
|
|
||||||
feature = "luau"
|
|
||||||
)),
|
|
||||||
path = "find_dummy.rs"
|
|
||||||
)]
|
|
||||||
mod find;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
#[cfg(not(any(
|
|
||||||
feature = "lua54",
|
|
||||||
feature = "lua53",
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit",
|
|
||||||
feature = "luau"
|
|
||||||
)))]
|
|
||||||
compile_error!(
|
|
||||||
"You must enable one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(
|
|
||||||
feature = "lua54",
|
|
||||||
any(
|
|
||||||
feature = "lua53",
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit",
|
|
||||||
feature = "luau"
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
compile_error!(
|
|
||||||
"You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(
|
|
||||||
feature = "lua53",
|
|
||||||
any(
|
|
||||||
feature = "lua52",
|
|
||||||
feature = "lua51",
|
|
||||||
feature = "luajit",
|
|
||||||
feature = "luau"
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
compile_error!(
|
|
||||||
"You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(
|
|
||||||
feature = "lua52",
|
|
||||||
any(feature = "lua51", feature = "luajit", feature = "luau")
|
|
||||||
))]
|
|
||||||
compile_error!(
|
|
||||||
"You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "lua51", any(feature = "luajit", feature = "luau")))]
|
|
||||||
compile_error!(
|
|
||||||
"You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "luajit", feature = "luau"))]
|
|
||||||
compile_error!(
|
|
||||||
"You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau"
|
|
||||||
);
|
|
||||||
|
|
||||||
// We don't support "vendored module" mode on windows
|
|
||||||
#[cfg(all(feature = "vendored", feature = "module", target_os = "windows"))]
|
|
||||||
compile_error!(
|
|
||||||
"Vendored (static) builds are not supported for modules on Windows.\n"
|
|
||||||
+ "Please, use `pkg-config` or custom mode to link to a Lua dll."
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "luau", feature = "module"))]
|
|
||||||
compile_error!("Luau does not support module mode");
|
|
||||||
|
|
||||||
#[cfg(any(not(feature = "module"), target_os = "windows"))]
|
|
||||||
find::probe_lua();
|
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=build");
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
[package]
|
||||||
|
name = "mlua-sys"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Aleksandr Orlenko <zxteam@pm.me>"]
|
||||||
|
edition = "2021"
|
||||||
|
repository = "https://github.com/khvzak/mlua"
|
||||||
|
readme = "README.md"
|
||||||
|
categories = ["external-ffi-bindings"]
|
||||||
|
license = "MIT"
|
||||||
|
links = "lua"
|
||||||
|
build = "build/main.rs"
|
||||||
|
description = """
|
||||||
|
Low level (FFI) bindings to Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau
|
||||||
|
"""
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
features = ["lua54", "vendored"]
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
lua54 = []
|
||||||
|
lua53 = []
|
||||||
|
lua52 = []
|
||||||
|
lua51 = []
|
||||||
|
luajit = []
|
||||||
|
luajit52 = ["luajit"]
|
||||||
|
luau = ["luau0-src"]
|
||||||
|
vendored = ["lua-src", "luajit-src"]
|
||||||
|
module = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
cc = "1.0"
|
||||||
|
cfg-if = "1.0"
|
||||||
|
pkg-config = "0.3.17"
|
||||||
|
lua-src = { version = ">= 544.0.0, < 550.0.0", optional = true }
|
||||||
|
luajit-src = { version = ">= 210.4.0, < 220.0.0", optional = true }
|
||||||
|
luau0-src = { version = "0.5.0", optional = true }
|
|
@ -0,0 +1,8 @@
|
||||||
|
# mlua-sys
|
||||||
|
|
||||||
|
Low level (FFI) bindings to Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox [Luau].
|
||||||
|
|
||||||
|
Intended to be consumed by the [mlua] crate.
|
||||||
|
|
||||||
|
[Luau]: https://github.com/Roblox/luau
|
||||||
|
[mlua]: https://crates.io/crates/mlua
|
|
@ -0,0 +1,19 @@
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(all(feature = "lua54", not(any(feature = "lua53", feature = "lua52", feature = "lua51", feature = "luajit", feature = "luau"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else if #[cfg(all(feature = "lua53", not(any(feature = "lua54", feature = "lua52", feature = "lua51", feature = "luajit", feature = "luau"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else if #[cfg(all(feature = "lua52", not(any(feature = "lua54", feature = "lua53", feature = "lua51", feature = "luajit", feature = "luau"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else if #[cfg(all(feature = "lua51", not(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "luajit", feature = "luau"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else if #[cfg(all(feature = "luajit", not(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "lua51", feature = "luau"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else if #[cfg(all(feature = "luau", not(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "lua51", feature = "luajit"))))] {
|
||||||
|
include!("main_inner.rs");
|
||||||
|
} else {
|
||||||
|
fn main() {
|
||||||
|
compile_error!("You can enable only one of the features: lua54, lua53, lua52, lua51, luajit, luajit52, luau");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(any(feature = "luau", feature = "vendored"))] {
|
||||||
|
#[path = "find_vendored.rs"]
|
||||||
|
mod find;
|
||||||
|
} else {
|
||||||
|
#[path = "find_normal.rs"]
|
||||||
|
mod find;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// We don't support "vendored module" mode on windows
|
||||||
|
#[cfg(all(feature = "vendored", feature = "module", target_os = "windows"))]
|
||||||
|
compile_error!(
|
||||||
|
"Vendored (static) builds are not supported for modules on Windows.\n"
|
||||||
|
+ "Please, use `pkg-config` or custom mode to link to a Lua dll."
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(all(feature = "luau", feature = "module"))]
|
||||||
|
compile_error!("Luau does not support module mode");
|
||||||
|
|
||||||
|
#[cfg(any(not(feature = "module"), target_os = "windows"))]
|
||||||
|
find::probe_lua();
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=build");
|
||||||
|
}
|
|
@ -1,38 +1,43 @@
|
||||||
//! Low level bindings to Lua 5.4/5.3/5.2/5.1 including LuaJIT.
|
//! Low level bindings to Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau.
|
||||||
|
|
||||||
#![allow(non_camel_case_types, non_snake_case, dead_code)]
|
#![allow(non_camel_case_types, non_snake_case, dead_code)]
|
||||||
|
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(any(feature = "lua54", doc))]
|
||||||
pub use lua54::*;
|
pub use lua54::*;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua53", doc))]
|
||||||
pub use lua53::*;
|
pub use lua53::*;
|
||||||
|
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(any(feature = "lua52", doc))]
|
||||||
pub use lua52::*;
|
pub use lua52::*;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit", doc))]
|
||||||
pub use lua51::*;
|
pub use lua51::*;
|
||||||
|
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", doc))]
|
||||||
pub use luau::*;
|
pub use luau::*;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const LUA_MAX_UPVALUES: c_int = 255;
|
pub const LUA_MAX_UPVALUES: c_int = 255;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", all(feature = "luajit", not(feature = "vendored"))))]
|
#[cfg(any(feature = "lua51", all(feature = "luajit", not(feature = "vendored"))))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const LUA_MAX_UPVALUES: c_int = 60;
|
pub const LUA_MAX_UPVALUES: c_int = 60;
|
||||||
|
|
||||||
#[cfg(all(feature = "luajit", feature = "vendored"))]
|
#[cfg(all(feature = "luajit", feature = "vendored"))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const LUA_MAX_UPVALUES: c_int = 120;
|
pub const LUA_MAX_UPVALUES: c_int = 120;
|
||||||
|
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(feature = "luau")]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const LUA_MAX_UPVALUES: c_int = 200;
|
pub const LUA_MAX_UPVALUES: c_int = 200;
|
||||||
|
|
||||||
// I believe `luaL_traceback` < 5.4 requires this much free stack to not error.
|
// I believe `luaL_traceback` < 5.4 requires this much free stack to not error.
|
||||||
// 5.4 uses `luaL_Buffer`
|
// 5.4 uses `luaL_Buffer`
|
||||||
|
#[doc(hidden)]
|
||||||
pub const LUA_TRACEBACK_STACK: c_int = 11;
|
pub const LUA_TRACEBACK_STACK: c_int = 11;
|
||||||
|
|
||||||
// The minimum alignment guaranteed by the architecture. This value is used to
|
// The minimum alignment guaranteed by the architecture. This value is used to
|
||||||
|
@ -51,6 +56,7 @@ pub const LUA_TRACEBACK_STACK: c_int = 11;
|
||||||
all(target_arch = "riscv32", not(target_os = "espidf")),
|
all(target_arch = "riscv32", not(target_os = "espidf")),
|
||||||
all(target_arch = "xtensa", not(target_os = "espidf")),
|
all(target_arch = "xtensa", not(target_os = "espidf")),
|
||||||
)))]
|
)))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const SYS_MIN_ALIGN: usize = 8;
|
pub const SYS_MIN_ALIGN: usize = 8;
|
||||||
#[cfg(all(any(
|
#[cfg(all(any(
|
||||||
target_arch = "x86_64",
|
target_arch = "x86_64",
|
||||||
|
@ -61,44 +67,35 @@ pub const SYS_MIN_ALIGN: usize = 8;
|
||||||
target_arch = "riscv64",
|
target_arch = "riscv64",
|
||||||
target_arch = "wasm64",
|
target_arch = "wasm64",
|
||||||
)))]
|
)))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const SYS_MIN_ALIGN: usize = 16;
|
pub const SYS_MIN_ALIGN: usize = 16;
|
||||||
// The allocator on the esp-idf platform guarentees 4 byte alignment.
|
// The allocator on the esp-idf platform guarentees 4 byte alignment.
|
||||||
#[cfg(all(any(
|
#[cfg(all(any(
|
||||||
all(target_arch = "riscv32", target_os = "espidf"),
|
all(target_arch = "riscv32", target_os = "espidf"),
|
||||||
all(target_arch = "xtensa", target_os = "espidf"),
|
all(target_arch = "xtensa", target_os = "espidf"),
|
||||||
)))]
|
)))]
|
||||||
|
#[doc(hidden)]
|
||||||
pub const SYS_MIN_ALIGN: usize = 4;
|
pub const SYS_MIN_ALIGN: usize = 4;
|
||||||
|
|
||||||
// Hack to avoid stripping a few unused Lua symbols that could be imported
|
#[macro_use]
|
||||||
// by C modules in unsafe mode
|
mod macros;
|
||||||
#[cfg(not(feature = "luau"))]
|
|
||||||
pub(crate) fn keep_lua_symbols() {
|
|
||||||
let mut _symbols: Vec<*const extern "C" fn()> = vec![
|
|
||||||
lua_atpanic as _,
|
|
||||||
lua_isuserdata as _,
|
|
||||||
lua_tocfunction as _,
|
|
||||||
luaL_loadstring as _,
|
|
||||||
luaL_openlibs as _,
|
|
||||||
];
|
|
||||||
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
|
||||||
{
|
|
||||||
_symbols.push(lua_getglobal as _);
|
|
||||||
_symbols.push(lua_setglobal as _);
|
|
||||||
_symbols.push(luaL_setfuncs as _);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(any(feature = "lua54", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua54")))]
|
||||||
pub mod lua54;
|
pub mod lua54;
|
||||||
|
|
||||||
#[cfg(feature = "lua53")]
|
#[cfg(any(feature = "lua53", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua53")))]
|
||||||
pub mod lua53;
|
pub mod lua53;
|
||||||
|
|
||||||
#[cfg(feature = "lua52")]
|
#[cfg(any(feature = "lua52", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "lua52")))]
|
||||||
pub mod lua52;
|
pub mod lua52;
|
||||||
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "lua51", feature = "luajit"))))]
|
||||||
pub mod lua51;
|
pub mod lua51;
|
||||||
|
|
||||||
#[cfg(feature = "luau")]
|
#[cfg(any(feature = "luau", doc))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
|
||||||
pub mod luau;
|
pub mod luau;
|
|
@ -1,4 +1,4 @@
|
||||||
//! MLua compatibility layer for Lua 5.2
|
//! MLua compatibility layer for Lua 5.3
|
||||||
|
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#[allow(unused_macros)]
|
||||||
|
macro_rules! cstr {
|
||||||
|
($s:expr) => {
|
||||||
|
concat!($s, "\0") as *const str as *const [::std::os::raw::c_char]
|
||||||
|
as *const ::std::os::raw::c_char
|
||||||
|
};
|
||||||
|
}
|
|
@ -84,7 +84,6 @@ mod macros;
|
||||||
mod chunk;
|
mod chunk;
|
||||||
mod conversion;
|
mod conversion;
|
||||||
mod error;
|
mod error;
|
||||||
mod ffi;
|
|
||||||
mod function;
|
mod function;
|
||||||
mod hook;
|
mod hook;
|
||||||
mod lua;
|
mod lua;
|
||||||
|
@ -106,7 +105,8 @@ mod value;
|
||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
pub use crate::{ffi::lua_CFunction, ffi::lua_State};
|
pub(crate) use ffi;
|
||||||
|
pub use ffi::{lua_CFunction, lua_State};
|
||||||
|
|
||||||
pub use crate::chunk::{AsChunk, Chunk, ChunkMode};
|
pub use crate::chunk::{AsChunk, Chunk, ChunkMode};
|
||||||
pub use crate::error::{Error, ErrorContext, ExternalError, ExternalResult, Result};
|
pub use crate::error::{Error, ErrorContext, ExternalError, ExternalResult, Result};
|
||||||
|
|
19
src/lua.rs
19
src/lua.rs
|
@ -359,7 +359,24 @@ impl Lua {
|
||||||
/// [`StdLib`]: crate::StdLib
|
/// [`StdLib`]: crate::StdLib
|
||||||
pub unsafe fn unsafe_new_with(libs: StdLib, options: LuaOptions) -> Lua {
|
pub unsafe fn unsafe_new_with(libs: StdLib, options: LuaOptions) -> Lua {
|
||||||
#[cfg(not(feature = "luau"))]
|
#[cfg(not(feature = "luau"))]
|
||||||
ffi::keep_lua_symbols();
|
{
|
||||||
|
// Workaround to avoid stripping a few unused Lua symbols that could be imported
|
||||||
|
// by C modules in unsafe mode
|
||||||
|
let mut _symbols: Vec<*const extern "C" fn()> = vec![
|
||||||
|
ffi::lua_atpanic as _,
|
||||||
|
ffi::lua_isuserdata as _,
|
||||||
|
ffi::lua_tocfunction as _,
|
||||||
|
ffi::luaL_loadstring as _,
|
||||||
|
ffi::luaL_openlibs as _,
|
||||||
|
];
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
|
{
|
||||||
|
_symbols.push(ffi::lua_getglobal as _);
|
||||||
|
_symbols.push(ffi::lua_setglobal as _);
|
||||||
|
_symbols.push(ffi::luaL_setfuncs as _);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Self::inner_new(libs, options)
|
Self::inner_new(libs, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue