Add new &Module parameter to native functions.

This commit is contained in:
Stephen Chung
2020-07-06 12:04:02 +08:00
parent 495d202af4
commit ea86888638
10 changed files with 107 additions and 99 deletions

View File

@@ -1,5 +1,6 @@
use crate::any::Dynamic;
use crate::engine::Engine;
use crate::module::Module;
use crate::parser::ScriptFnDef;
use crate::result::EvalAltResult;
use crate::utils::ImmutableString;
@@ -79,11 +80,11 @@ impl<S: Into<ImmutableString>> From<S> for FnPtr {
/// A general function trail object.
#[cfg(not(feature = "sync"))]
pub type FnAny = dyn Fn(&Engine, &mut FnCallArgs) -> Result<Dynamic, Box<EvalAltResult>>;
pub type FnAny = dyn Fn(&Engine, &Module, &mut FnCallArgs) -> Result<Dynamic, Box<EvalAltResult>>;
/// A general function trail object.
#[cfg(feature = "sync")]
pub type FnAny =
dyn Fn(&Engine, &mut FnCallArgs) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync;
dyn Fn(&Engine, &Module, &mut FnCallArgs) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync;
/// A standard function that gets an iterator from a type.
pub type IteratorFn = fn(Dynamic) -> Box<dyn Iterator<Item = Dynamic>>;