Restructure code base.

This commit is contained in:
Stephen Chung
2021-11-13 22:36:23 +08:00
parent 38884ede46
commit 64b889fb95
36 changed files with 154 additions and 140 deletions

30
src/func/plugin.rs Normal file
View File

@@ -0,0 +1,30 @@
//! Module defining macros for developing _plugins_.
use super::call::FnCallArgs;
pub use super::native::CallableFunction;
pub use crate::{
Dynamic, Engine, EvalAltResult, FnAccess, FnNamespace, ImmutableString, Module,
NativeCallContext, Position,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
pub use std::{any::TypeId, mem};
pub type RhaiResult = Result<Dynamic, Box<EvalAltResult>>;
#[cfg(not(features = "no_module"))]
pub use rhai_codegen::*;
#[cfg(features = "no_module")]
pub use rhai_codegen::{export_fn, register_exported_fn};
/// Trait implemented by a _plugin function_.
///
/// This trait should not be used directly.
/// 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;
/// Is this plugin function a method?
#[must_use]
fn is_method_call(&self) -> bool;
}