Implement namespaces chain.
This commit is contained in:
@@ -121,7 +121,7 @@ where:
|
||||
* `context: &mut EvalContext` - mutable reference to the current evaluation _context_, exposing the following:
|
||||
* `context.scope: &mut Scope` - mutable reference to the current [`Scope`]; variables can be added to/removed from it.
|
||||
* `context.engine(): &Engine` - reference to the current [`Engine`].
|
||||
* `context.namespace(): &Module` - reference to the current _global namespace_ (as a [module]) containing all script-defined functions.
|
||||
* `context.namespaces(): &[&Module]` - reference to the chain of namespaces (as a slice of [modules]) containing all script-defined functions.
|
||||
* `context.this_ptr(): Option<&Dynamic>` - reference to the current bound [`this`] pointer, if any.
|
||||
* `context.call_level(): usize` - the current nesting level of function calls.
|
||||
|
||||
|
@@ -77,7 +77,7 @@ where:
|
||||
* `context: &EvalContext` - reference to the current evaluation _context_, which exposes the following fields:
|
||||
* `context.scope: &Scope` - reference to the current [`Scope`] containing all variables up to the current evaluation position.
|
||||
* `context.engine(): &Engine` - reference to the current [`Engine`].
|
||||
* `context.namespace(): &Module` - reference to the current _global namespace_ (as a [module]) containing all script-defined functions.
|
||||
* `context.namespaces(): &[&Module]` - reference to the chain of namespaces (as a slice of [modules]) containing all script-defined functions.
|
||||
* `context.this_ptr(): Option<&Dynamic>` - reference to the current bound [`this`] pointer, if any.
|
||||
* `context.call_level(): usize` - the current nesting level of function calls.
|
||||
|
||||
|
@@ -249,8 +249,8 @@ let fn_ptr = engine.eval_ast::<FnPtr>(&ast)?;
|
||||
ast.retain_functions(|_, _, _| true);
|
||||
|
||||
// Create native call context via a tuple containing the Engine and the
|
||||
// set of script-defined functions (within the AST)
|
||||
let context = (&engine, ast.as_ref()).into();
|
||||
// set of script-defined functions (within the AST) in form of a slice.
|
||||
let context = (&engine, &[ast.as_ref()]).into();
|
||||
|
||||
// 'f' captures: the engine, the AST, and the closure
|
||||
let f = move |x: i64| fn_ptr.call_dynamic(context, None, [x.into()]);
|
||||
|
@@ -72,8 +72,7 @@ where:
|
||||
* `context.engine(): &Engine` - the current [`Engine`], with all configurations and settings.
|
||||
This is sometimes useful for calling a script-defined function within the same evaluation context
|
||||
using [`Engine::call_fn`][`call_fn`], or calling a [function pointer].
|
||||
|
||||
* `context.namespace(): &Module` - the global namespace of script-defined functions, as a [`Module`].
|
||||
* `context.namespaces(): &[&Module]` - reference to the chain of namespaces (as a slice of [modules]) containing all script-defined functions.
|
||||
|
||||
* `args: &mut [&mut Dynamic]` - a slice containing `&mut` references to [`Dynamic`] values.
|
||||
The slice is guaranteed to contain enough arguments _of the correct types_.
|
||||
|
Reference in New Issue
Block a user