Add feature for registering bundled Lua modules
Enabled by default.
This commit is contained in:
1 parent
9b98c65060
commit
f3c065debd
4 files changed
+28
-16
No files matched your search
@@ -1,2 +1,20 @@
|
||||
#[cfg(feature = "bundled-lua-modules")]
|
||||
pub mod luacurl;
|
||||
#[cfg(feature = "bundled-lua-modules")]
|
||||
pub mod luasocket;
|
||||
|
||||
use mlua::{Lua, Result as LuaResult};
|
||||
|
||||
/// Registers Rust implementations of the Lua modules required by PoB's Lua code.
|
||||
pub fn register(lua: &Lua) -> LuaResult<()> {
|
||||
lua.register_module("lua-utf8", luautf8::create_module(lua)?)?;
|
||||
lua.register_module("socket", luasocket::create_module(lua)?)?;
|
||||
lua.register_module("lcurl.safe", luacurl::create_module(lua)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Nothing is registered so Lua resolves the required modules through `package.cpath`.
|
||||
#[cfg(not(feature = "bundled-lua-modules"))]
|
||||
pub fn register(_lua: &Lua) -> LuaResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
pob::modules::{luacurl, luasocket},
|
||||
util::append_lua_package_dir,
|
||||
};
|
||||
use crate::{pob::modules, util::append_lua_package_dir};
|
||||
use anyhow::{Result, anyhow};
|
||||
use mlua::{Integer, IntoLuaMulti, Lua, MultiValue, Number, Value};
|
||||
use std::{
|
||||
@@ -145,9 +142,7 @@ impl Subscript {
|
||||
append_lua_package_dir(&lua, &script_dir.join("lua"))?;
|
||||
|
||||
// register modules
|
||||
lua.register_module("lua-utf8", luautf8::create_module(&lua)?)?;
|
||||
lua.register_module("socket", luasocket::create_module(&lua)?)?;
|
||||
lua.register_module("lcurl.safe", luacurl::create_module(&lua)?)?;
|
||||
modules::register(&lua)?;
|
||||
|
||||
// register a proxy for each allowed blocking call.
|
||||
// forwards the call to the main thread and blocks on `reply_rx` until the main thread
|
||||
|
||||
Reference in new issue
Block a user