You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,20 +8,21 @@ Bug fixes
8
8
---------
9
9
10
10
*`Engine::compact_script` now properly compacts scripts with custom syntax that uses `$raw$` (thanks [`@yuvalrakavy`](https://github.com/yuvalrakavy)[`#1079`](https://github.com/rhaiscript/rhai/pull/1079)).
11
-
* The string methods `split`, `split_rev` and their variants are now marked pure so they can be called on `const` strings ([`#1081`](https://github.com/rhaiscript/rhai/issues/1081)).
12
-
*`array.index_of` now falls back to value comparison for string argument when no script function of that name is registered ([`#795`](https://github.com/rhaiscript/rhai/issues/795)).
11
+
* The string methods `split`, `split_rev` and their variants are now marked `pure` so they can be called on `const` strings (thanks [`@theJC`](https://github.com/theJC)[`#1082`](https://github.com/rhaiscript/rhai/pull/1082)).
12
+
*The array method `index_of` now falls back to value comparison for string argument when no script function of that name is registered (thanks [`@yinho999`](https://github.com/yinho999)[`#1086`](https://github.com/rhaiscript/rhai/pull/1086)).
13
13
14
14
New features
15
15
------------
16
16
17
17
* A new advanced callback, `Engine::on_missing_function`, is added (gated under the `internals` feature) to override default handling when a called function or method is not found (thanks [`@yuvalrakavy`](https://github.com/yuvalrakavy)[`#1067`](https://github.com/rhaiscript/rhai/pull/1067)).
18
+
* A new method, `EvalContext::new_frame`, is added to created an isolated frame guard that automatically restores field values upon `Drop` (thanks [`@yuvalrakavy`](https://github.com/yuvalrakavy) for the idea [`#1085`](https://github.com/rhaiscript/rhai/pull/1085)).
18
19
19
20
Enhancements
20
21
------------
21
22
22
23
* Procedural macros such as `#[export_module]` and `#[derive(CustomType)]` no longer require importing standard Rhai types (thanks [`@timokoesters`](https://github.com/timokoesters)[`#1071`](https://github.com/rhaiscript/rhai/pull/1071)).
23
-
*`FnPtr::call_fn_as_method` and `FnPtr::call_as_method_within_context` are added (when not under `no_object`) to accept a `this` pointer for calling the function pointer as a method call.
24
-
*`NativeCallContext::call_method` and `NativeCallContext::call_native_method` are added (when not under `no_object`) to accept a `this` pointer for method calls.
24
+
*`FnPtr::call_fn_as_method` and `FnPtr::call_as_method_within_context` are added (when not under `no_object`) to accept a `this` pointer for calling the function pointer as a method call (thanks [`@yunfengzh`](https://github.com/yunfengzh) for the request [`#1080`](https://github.com/rhaiscript/rhai/pull/1080)).
25
+
*`NativeCallContext::call_method` and `NativeCallContext::call_native_method` are added (when not under `no_object`) to accept a `this` pointer for method calls (thanks [`@yunfengzh`](https://github.com/yunfengzh) for the idea [`#1080`](https://github.com/rhaiscript/rhai/pull/1080)).
/// Create a new isolated runtime frame guard, restoring field values upon `Drop`.
409
+
///
410
+
/// The [frame guard][EvalContextFrameGuard] returned derefs to [`EvalContext`].
411
+
///
412
+
/// # Examples
413
+
///
414
+
/// ```rust,ignore
415
+
/// // The following pushes a new, empty, caching layer to make sure that new function resolutions
416
+
/// // do not persist. This is useful if the resolution will be volatile.
417
+
/// let result: i64 = context.new_frame()
418
+
/// .with_new_caching_layer()
419
+
/// .call_fn("foo", (0_i64,))?;
420
+
///
421
+
/// // In the above example, the resolution to function 'foo' will not be cached outside the frame.
422
+
/// // The next call to 'foo' will be resolved again instead of using the cached resolution,
423
+
/// // even if 'foo' is redefined.
424
+
///
425
+
/// // The following modifies the [`EvalContext`] before using, restoring its state afterwards.
426
+
/// {
427
+
/// // Modify the context before using...
428
+
/// let context = context.new_frame()
429
+
/// .rewind_scope(true) // rewinds the scope...
430
+
/// .with_source("new source") // new source...
431
+
/// .with_namespace(new_module) // add new namespace module...
432
+
/// .up_call_level();
433
+
///
434
+
/// // Call a function with the modified context...
435
+
/// let result: i64 = context.call_fn("foo", (0_i64,))?;
436
+
///
437
+
/// // ... at end of block, context automatically restored to previous state.
438
+
/// }
439
+
/// ```
440
+
///
441
+
/// ## `Drop` behavior
442
+
///
443
+
/// Upon `Drop`, the following fields will be automatically restored to the previous values:
444
+
///
445
+
/// * the stack of imported [modules][crate::Module] will be rewound to the original depth if more have been added via [`EvalContextFrameGuard::with_import`].
446
+
/// * the stack of scripted function [modules][crate::Module] will be rewound to the original depth if more have been added via [`EvalContextFrameGuard::with_namespace`].
447
+
/// * the original functions resolution cache will be restored if a new caching layer was created via [`EvalContextFrameGuard::with_new_caching_layer`].
448
+
/// * the original [scope][EvalContext::scope] will be rewound if [`EvalContextFrameGuard::rewind_scope`] was set to `true`.
449
+
/// * the [source][GlobalRuntimeState::source] will be restored if a new source was set via [`EvalContextFrameGuard::with_source`] or cleared via [`EvalContextFrameGuard::clear_source`].
450
+
/// * the current [nesting level][GlobalRuntimeState::level] of function calls will be restored if modified via [`EvalContextFrameGuard::up_call_level`].
451
+
/// * the current [`tag`][GlobalRuntimeState::tag] will be restored if modified via [`EvalContextFrameGuard::with_tag`] or [`EvalContextFrameGuard::clear_tag`].
0 commit comments