Use combine_flatten for plugin modules.

This commit is contained in:
Stephen Chung
2020-08-21 21:48:45 +08:00
parent 40f71320f3
commit 08977e2a62
12 changed files with 64 additions and 19 deletions

View File

@@ -10,11 +10,16 @@ mod test {
pub mod special_array_package {
use rhai::{Array, INT};
#[rhai_fn(get = "foo", return_raw)]
#[inline(always)]
pub fn foo(array: &mut Array) -> Result<Dynamic, Box<EvalAltResult>> {
Ok(array[0].clone())
#[cfg(not(feature = "no_object"))]
#[rhai_mod()]
pub mod feature {
#[rhai_fn(get = "foo", return_raw)]
#[inline(always)]
pub fn foo(array: &mut Array) -> Result<Dynamic, Box<EvalAltResult>> {
Ok(array[0].clone())
}
}
#[rhai_fn(name = "test")]
#[inline(always)]
pub fn len(array: &mut Array, mul: INT) -> INT {
@@ -59,7 +64,8 @@ gen_unary_functions!(greet = make_greeting(INT, bool, char) -> String);
fn test_plugins_package() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
let m = exported_module!(test::special_array_package);
let mut m = Module::new();
m.combine_flatten(exported_module!(test::special_array_package));
engine.load_package(m);
reg_functions!(engine += greet::single(INT, bool, char));