Add has_context to plugin functions.

This commit is contained in:
Stephen Chung
2022-12-03 17:03:15 +08:00
parent 249180b1e0
commit 4998eb6139
9 changed files with 98 additions and 48 deletions

View File

@@ -24,12 +24,16 @@ pub use rhai_codegen::{export_fn, register_exported_fn};
/// Use the `#[export_module]` and `#[export_fn]` procedural attributes instead.
pub trait PluginFunction {
/// Call the plugin function with the arguments provided.
fn call(&self, context: NativeCallContext, args: &mut FnCallArgs) -> RhaiResult;
fn call(&self, context: Option<NativeCallContext>, args: &mut FnCallArgs) -> RhaiResult;
/// Is this plugin function a method?
#[must_use]
fn is_method_call(&self) -> bool;
/// Does this plugin function contain a [`NativeCallContext`] parameter?
#[must_use]
fn has_context(&self) -> bool;
/// Is this plugin function pure?
///
/// This defaults to `true` such that any old implementation that has constant-checking code