diff --git a/src/api/build_type.rs b/src/api/build_type.rs
index af0e0ca8..8fa940e7 100644
--- a/src/api/build_type.rs
+++ b/src/api/build_type.rs
@@ -117,10 +117,10 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
/// Register a custom function.
#[inline(always)]
- pub fn with_fn(
+ pub fn with_fn(
&mut self,
name: impl AsRef + Into,
- method: impl RegisterNativeFunction,
+ method: impl RegisterNativeFunction,
) -> &mut Self {
self.engine.register_fn(name, method);
self
@@ -152,7 +152,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
pub fn with_get(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, S> + crate::func::SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, S> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_get(name, get_fn);
self
@@ -165,7 +165,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
pub fn with_set(
&mut self,
name: impl AsRef,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), S> + crate::func::SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), S> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_set(name, set_fn);
self
@@ -180,8 +180,8 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
pub fn with_get_set(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, S1> + crate::func::SendSync + 'static,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), S2> + crate::func::SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, S1> + crate::func::SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), S2> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_get_set(name, get_fn, set_fn);
self
@@ -198,7 +198,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
#[inline(always)]
pub fn with_indexer_get(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, S> + crate::func::SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, S> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_indexer_get(get_fn);
self
@@ -210,7 +210,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
#[inline(always)]
pub fn with_indexer_set(
&mut self,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), S> + crate::func::SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), S> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_indexer_set(set_fn);
self
@@ -222,8 +222,8 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
#[inline(always)]
pub fn with_indexer_get_set(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, S1> + crate::func::SendSync + 'static,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), S2> + crate::func::SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, S1> + crate::func::SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), S2> + crate::func::SendSync + 'static,
) -> &mut Self {
self.engine.register_indexer_get_set(get_fn, set_fn);
self
diff --git a/src/api/deprecated.rs b/src/api/deprecated.rs
index 44bbc095..d090d6d4 100644
--- a/src/api/deprecated.rs
+++ b/src/api/deprecated.rs
@@ -185,10 +185,10 @@ impl Engine {
/// This method will be removed in the next major version.
#[deprecated(since = "1.9.1", note = "use `register_fn` instead")]
#[inline(always)]
- pub fn register_result_fn(
+ pub fn register_result_fn(
&mut self,
name: impl AsRef + Into,
- func: impl RegisterNativeFunction>,
+ func: impl RegisterNativeFunction>,
) -> &mut Self {
self.register_fn(name, func)
}
@@ -209,7 +209,7 @@ impl Engine {
pub fn register_get_result(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, RhaiResultOf>
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -230,7 +230,7 @@ impl Engine {
pub fn register_set_result(
&mut self,
name: impl AsRef,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), RhaiResultOf>
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -257,7 +257,7 @@ impl Engine {
S,
>(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, RhaiResultOf>
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -282,7 +282,7 @@ impl Engine {
S,
>(
&mut self,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), RhaiResultOf>
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -516,10 +516,10 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
/// This method will be removed in the next major version.
#[deprecated(since = "1.9.1", note = "use `with_fn` instead")]
#[inline(always)]
- pub fn with_result_fn(&mut self, name: N, method: F) -> &mut Self
+ pub fn with_result_fn(&mut self, name: X, method: F) -> &mut Self
where
- N: AsRef + Into,
- F: RegisterNativeFunction>,
+ X: AsRef + Into,
+ F: RegisterNativeFunction>,
{
self.with_fn(name, method)
}
@@ -541,7 +541,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
pub fn with_get_result(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, RhaiResultOf>
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -563,7 +563,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
pub fn with_set_result(
&mut self,
name: impl AsRef,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), RhaiResultOf>
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -586,7 +586,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
#[inline(always)]
pub fn with_indexer_get_result(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, RhaiResultOf>
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
@@ -607,7 +607,7 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
#[inline(always)]
pub fn with_indexer_set_result(
&mut self,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), RhaiResultOf>
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), RhaiResultOf>
+ crate::func::SendSync
+ 'static,
) -> &mut Self {
diff --git a/src/api/register.rs b/src/api/register.rs
index 844120f2..37a7179d 100644
--- a/src/api/register.rs
+++ b/src/api/register.rs
@@ -56,7 +56,7 @@ impl Engine {
/// # }
/// ```
#[inline]
- pub fn register_fn>(
+ pub fn register_fn>(
&mut self,
name: impl AsRef + Into,
func: F,
@@ -302,7 +302,7 @@ impl Engine {
pub fn register_get(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, S> + SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, S> + SendSync + 'static,
) -> &mut Self {
self.register_fn(crate::engine::make_getter(name.as_ref()).as_str(), get_fn)
}
@@ -352,7 +352,7 @@ impl Engine {
pub fn register_set(
&mut self,
name: impl AsRef,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), S> + SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), S> + SendSync + 'static,
) -> &mut Self {
self.register_fn(crate::engine::make_setter(name.as_ref()).as_str(), set_fn)
}
@@ -406,8 +406,8 @@ impl Engine {
pub fn register_get_set(
&mut self,
name: impl AsRef,
- get_fn: impl RegisterNativeFunction<(Mut,), V, S1> + SendSync + 'static,
- set_fn: impl RegisterNativeFunction<(Mut, V), (), S2> + SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut,), 1, V, S1> + SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, V), 2, (), S2> + SendSync + 'static,
) -> &mut Self {
self.register_get(&name, get_fn).register_set(&name, set_fn)
}
@@ -464,7 +464,7 @@ impl Engine {
#[inline]
pub fn register_indexer_get(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, S> + SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, S> + SendSync + 'static,
) -> &mut Self {
#[cfg(not(feature = "no_index"))]
if TypeId::of::() == TypeId::of::() {
@@ -539,7 +539,7 @@ impl Engine {
#[inline]
pub fn register_indexer_set(
&mut self,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), S> + SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), S> + SendSync + 'static,
) -> &mut Self {
#[cfg(not(feature = "no_index"))]
if TypeId::of::() == TypeId::of::() {
@@ -621,8 +621,8 @@ impl Engine {
S2,
>(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, X), V, S1> + SendSync + 'static,
- set_fn: impl RegisterNativeFunction<(Mut, X, V), (), S2> + SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut, X), 2, V, S1> + SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, X, V), 3, (), S2> + SendSync + 'static,
) -> &mut Self {
self.register_indexer_get(get_fn)
.register_indexer_set(set_fn)
diff --git a/src/func/register.rs b/src/func/register.rs
index bacd30cd..14186223 100644
--- a/src/func/register.rs
+++ b/src/func/register.rs
@@ -9,7 +9,10 @@ use crate::types::dynamic::{DynamicWriteLock, Variant};
use crate::{reify, Dynamic, NativeCallContext, RhaiResultOf};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
-use std::{any::TypeId, mem};
+use std::{
+ any::{type_name, TypeId},
+ mem,
+};
/// These types are used to build a unique _marker_ tuple type for each combination
/// of function parameter types in order to make each trait implementation unique.
@@ -19,13 +22,13 @@ use std::{any::TypeId, mem};
///
/// # Examples
///
-/// `RegisterNativeFunction<(Mut, B, Ref), R, ()>` = `Fn(&mut A, B, &C) -> R`
+/// `RegisterNativeFunction<(Mut, B, Ref), 3, R, ()>` = `Fn(&mut A, B, &C) -> R`
///
-/// `RegisterNativeFunction<(Mut, B, Ref), R, NativeCallContext>` = `Fn(NativeCallContext, &mut A, B, &C) -> R`
+/// `RegisterNativeFunction<(Mut, B, Ref), 3, R, NativeCallContext>` = `Fn(NativeCallContext, &mut A, B, &C) -> R`
///
-/// `RegisterNativeFunction<(Mut, B, Ref), R, RhaiResultOf<()>>` = `Fn(&mut A, B, &C) -> Result>`
+/// `RegisterNativeFunction<(Mut, B, Ref), 3, R, RhaiResultOf<()>>` = `Fn(&mut A, B, &C) -> Result>`
///
-/// `RegisterNativeFunction<(Mut, B, Ref), R, RhaiResultOf>` = `Fn(NativeCallContext, &mut A, B, &C) -> Result>`
+/// `RegisterNativeFunction<(Mut, B, Ref), 3, R, RhaiResultOf>` = `Fn(NativeCallContext, &mut A, B, &C) -> Result>`
///
/// These types are not actually used anywhere.
pub struct Mut(T);
@@ -66,18 +69,18 @@ pub fn by_value(data: &mut Dynamic) -> T {
///
/// * `ARGS` - a tuple containing parameter types, with `&mut T` represented by `Mut`.
/// * `RET` - return type of the function; if the function returns `Result`, it is the unwrapped inner value type.
-pub trait RegisterNativeFunction {
+pub trait RegisterNativeFunction {
/// Convert this function into a [`CallableFunction`].
#[must_use]
fn into_callable_function(self) -> CallableFunction;
/// Get the type ID's of this function's parameters.
#[must_use]
- fn param_types() -> Box<[TypeId]>;
+ fn param_types() -> [TypeId; N];
/// _(metadata)_ Get the type names of this function's parameters.
/// Exported under the `metadata` feature only.
#[cfg(feature = "metadata")]
#[must_use]
- fn param_names() -> Box<[&'static str]>;
+ fn param_names() -> [&'static str; N];
/// _(metadata)_ Get the type ID of this function's return value.
/// Exported under the `metadata` feature only.
#[cfg(feature = "metadata")]
@@ -89,7 +92,7 @@ pub trait RegisterNativeFunction {
#[inline(always)]
#[must_use]
fn return_type_name() -> &'static str {
- std::any::type_name::()
+ type_name::()
}
}
@@ -124,23 +127,24 @@ macro_rules! check_constant {
macro_rules! def_register {
() => {
- def_register!(imp Pure :);
+ def_register!(imp Pure : 0;);
};
- (imp $abi:ident : $($par:ident => $arg:expr => $mark:ty => $param:ty => $let:stmt => $clone:expr),*) => {
+ (imp $abi:ident : $n:expr ; $($par:ident => $arg:expr => $mark:ty => $param:ty => $let:stmt => $clone:expr),*) => {
// ^ function ABI type
- // ^ function parameter generic type name (A, B, C etc.)
- // ^ call argument(like A, *B, &mut C etc)
- // ^ function parameter marker type (A, Ref or Mut)
- // ^ function parameter actual type (A, &B or &mut C)
- // ^ argument let statement
+ // ^ number of parameters
+ // ^ function parameter generic type name (A, B, C etc.)
+ // ^ call argument(like A, *B, &mut C etc)
+ // ^ function parameter marker type (A, Ref or Mut)
+ // ^ function parameter actual type (A, &B or &mut C)
+ // ^ argument let statement
impl<
FN: Fn($($param),*) -> RET + SendSync + 'static,
$($par: Variant + Clone,)*
RET: Variant + Clone
- > RegisterNativeFunction<($($mark,)*), RET, ()> for FN {
- #[inline(always)] fn param_types() -> Box<[TypeId]> { Box::new([$(TypeId::of::<$par>()),*]) }
- #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { Box::new([$(std::any::type_name::<$param>()),*]) }
+ > RegisterNativeFunction<($($mark,)*), $n, RET, ()> for FN {
+ #[inline(always)] fn param_types() -> [TypeId;$n] { [$(TypeId::of::<$par>()),*] }
+ #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> [&'static str;$n] { [$(type_name::<$param>()),*] }
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::() }
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
CallableFunction::$abi(Shared::new(move |_ctx: NativeCallContext, args: &mut FnCallArgs| {
@@ -163,9 +167,9 @@ macro_rules! def_register {
FN: for<'a> Fn(NativeCallContext<'a>, $($param),*) -> RET + SendSync + 'static,
$($par: Variant + Clone,)*
RET: Variant + Clone
- > RegisterNativeFunction<($($mark,)*), RET, NativeCallContext<'static>> for FN {
- #[inline(always)] fn param_types() -> Box<[TypeId]> { Box::new([$(TypeId::of::<$par>()),*]) }
- #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { Box::new([$(std::any::type_name::<$param>()),*]) }
+ > RegisterNativeFunction<($($mark,)*), $n, RET, NativeCallContext<'static>> for FN {
+ #[inline(always)] fn param_types() -> [TypeId;$n] { [$(TypeId::of::<$par>()),*] }
+ #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> [&'static str;$n] { [$(type_name::<$param>()),*] }
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::() }
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
CallableFunction::$abi(Shared::new(move |ctx: NativeCallContext, args: &mut FnCallArgs| {
@@ -188,11 +192,11 @@ macro_rules! def_register {
FN: Fn($($param),*) -> RhaiResultOf + SendSync + 'static,
$($par: Variant + Clone,)*
RET: Variant + Clone
- > RegisterNativeFunction<($($mark,)*), RET, RhaiResultOf<()>> for FN {
- #[inline(always)] fn param_types() -> Box<[TypeId]> { Box::new([$(TypeId::of::<$par>()),*]) }
- #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { Box::new([$(std::any::type_name::<$param>()),*]) }
+ > RegisterNativeFunction<($($mark,)*), $n, RET, RhaiResultOf<()>> for FN {
+ #[inline(always)] fn param_types() -> [TypeId;$n] { [$(TypeId::of::<$par>()),*] }
+ #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> [&'static str;$n] { [$(type_name::<$param>()),*] }
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::>() }
- #[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { std::any::type_name::>() }
+ #[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { type_name::>() }
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
CallableFunction::$abi(Shared::new(move |_ctx: NativeCallContext, args: &mut FnCallArgs| {
// The arguments are assumed to be of the correct number and types!
@@ -211,11 +215,11 @@ macro_rules! def_register {
FN: for<'a> Fn(NativeCallContext<'a>, $($param),*) -> RhaiResultOf + SendSync + 'static,
$($par: Variant + Clone,)*
RET: Variant + Clone
- > RegisterNativeFunction<($($mark,)*), RET, RhaiResultOf>> for FN {
- #[inline(always)] fn param_types() -> Box<[TypeId]> { Box::new([$(TypeId::of::<$par>()),*]) }
- #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { Box::new([$(std::any::type_name::<$param>()),*]) }
+ > RegisterNativeFunction<($($mark,)*), $n, RET, RhaiResultOf>> for FN {
+ #[inline(always)] fn param_types() -> [TypeId;$n] { [$(TypeId::of::<$par>()),*] }
+ #[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> [&'static str;$n] { [$(type_name::<$param>()),*] }
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::>() }
- #[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { std::any::type_name::>() }
+ #[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { type_name::>() }
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
CallableFunction::$abi(Shared::new(move |ctx: NativeCallContext, args: &mut FnCallArgs| {
// The arguments are assumed to be of the correct number and types!
@@ -232,19 +236,20 @@ macro_rules! def_register {
//def_register!(imp_pop $($par => $mark => $param),*);
};
- ($p0:ident $(, $p:ident)*) => {
- def_register!(imp Pure : $p0 => $p0 => $p0 => $p0 => let $p0 => by_value $(, $p => $p => $p => $p => let $p => by_value)*);
- def_register!(imp Method : $p0 => &mut $p0 => Mut<$p0> => &mut $p0 => let mut $p0 => by_ref $(, $p => $p => $p => $p => let $p => by_value)*);
+ ($p0:ident:$n0:expr $(, $p:ident: $n:expr)*) => {
+ def_register!(imp Pure : $n0 ; $p0 => $p0 => $p0 => $p0 => let $p0 => by_value $(, $p => $p => $p => $p => let $p => by_value)*);
+ def_register!(imp Method : $n0 ; $p0 => &mut $p0 => Mut<$p0> => &mut $p0 => let mut $p0 => by_ref $(, $p => $p => $p => $p => let $p => by_value)*);
// ^ CallableFunction constructor
- // ^ first parameter passed through
- // ^ others passed by value (by_value)
+ // ^ number of arguments
+ // ^ first parameter passed through
+ // ^ others passed by value (by_value)
// Currently does not support first argument which is a reference, as there will be
// conflicting implementations since &T: Any and T: Any cannot be distinguished
//def_register!(imp $p0 => Ref<$p0> => &$p0 => by_ref $(, $p => $p => $p => by_value)*);
- def_register!($($p),*);
+ def_register!($($p: $n),*);
};
}
-def_register!(A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U, V);
+def_register!(A:20, B:19, C:18, D:17, E:16, F:15, G:14, H:13, J:12, K:11, L:10, M:9, N:8, P:7, Q:6, R:5, S:4, T:3, U:2, V:1);
diff --git a/src/module/mod.rs b/src/module/mod.rs
index 6f5854f7..af70abb7 100644
--- a/src/module/mod.rs
+++ b/src/module/mod.rs
@@ -1237,14 +1237,14 @@ impl Module {
/// assert!(module.contains_fn(hash));
/// ```
#[inline(always)]
- pub fn set_native_fn(
+ pub fn set_native_fn(
&mut self,
name: impl AsRef + Into,
func: F,
) -> u64
where
T: Variant + Clone,
- F: RegisterNativeFunction>,
+ F: RegisterNativeFunction>,
{
self.set_fn(
name,
@@ -1280,7 +1280,7 @@ impl Module {
where
A: Variant + Clone,
T: Variant + Clone,
- F: RegisterNativeFunction<(Mut,), T, RhaiResultOf> + SendSync + 'static,
+ F: RegisterNativeFunction<(Mut,), 1, T, RhaiResultOf> + SendSync + 'static,
{
self.set_fn(
crate::engine::make_getter(name.as_ref()).as_str(),
@@ -1321,7 +1321,7 @@ impl Module {
where
A: Variant + Clone,
T: Variant + Clone,
- F: RegisterNativeFunction<(Mut, T), (), RhaiResultOf> + SendSync + 'static,
+ F: RegisterNativeFunction<(Mut, T), 2, (), RhaiResultOf> + SendSync + 'static,
{
self.set_fn(
crate::engine::make_setter(name.as_ref()).as_str(),
@@ -1366,8 +1366,8 @@ impl Module {
pub fn set_getter_setter_fn(
&mut self,
name: impl AsRef,
- getter: impl RegisterNativeFunction<(Mut,), T, RhaiResultOf> + SendSync + 'static,
- setter: impl RegisterNativeFunction<(Mut, T), (), RhaiResultOf> + SendSync + 'static,
+ getter: impl RegisterNativeFunction<(Mut,), 1, T, RhaiResultOf> + SendSync + 'static,
+ setter: impl RegisterNativeFunction<(Mut, T), 2, (), RhaiResultOf> + SendSync + 'static,
) -> (u64, u64) {
(
self.set_getter_fn(name.as_ref(), getter),
@@ -1409,7 +1409,7 @@ impl Module {
A: Variant + Clone,
B: Variant + Clone,
T: Variant + Clone,
- F: RegisterNativeFunction<(Mut, B), T, RhaiResultOf> + SendSync + 'static,
+ F: RegisterNativeFunction<(Mut, B), 2, T, RhaiResultOf> + SendSync + 'static,
{
#[cfg(not(feature = "no_index"))]
if TypeId::of::() == TypeId::of::() {
@@ -1470,7 +1470,7 @@ impl Module {
A: Variant + Clone,
B: Variant + Clone,
T: Variant + Clone,
- F: RegisterNativeFunction<(Mut, B, T), (), RhaiResultOf> + SendSync + 'static,
+ F: RegisterNativeFunction<(Mut, B, T), 3, (), RhaiResultOf> + SendSync + 'static,
{
#[cfg(not(feature = "no_index"))]
if TypeId::of::() == TypeId::of::() {
@@ -1542,8 +1542,10 @@ impl Module {
S2,
>(
&mut self,
- get_fn: impl RegisterNativeFunction<(Mut, B), T, RhaiResultOf> + SendSync + 'static,
- set_fn: impl RegisterNativeFunction<(Mut, B, T), (), RhaiResultOf> + SendSync + 'static,
+ get_fn: impl RegisterNativeFunction<(Mut, B), 2, T, RhaiResultOf> + SendSync + 'static,
+ set_fn: impl RegisterNativeFunction<(Mut, B, T), 3, (), RhaiResultOf>
+ + SendSync
+ + 'static,
) -> (u64, u64) {
(
self.set_indexer_get_fn(get_fn),