Allow NativeCallContext in function arguments.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rhai_codegen"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
edition = "2018"
|
||||
authors = ["jhwgh1968"]
|
||||
description = "Procedural macro support package for Rhai, a scripting language for Rust"
|
||||
|
@@ -222,6 +222,7 @@ pub(crate) struct ExportedFn {
|
||||
entire_span: proc_macro2::Span,
|
||||
signature: syn::Signature,
|
||||
is_public: bool,
|
||||
pass_context: bool,
|
||||
return_dynamic: bool,
|
||||
mut_receiver: bool,
|
||||
params: ExportedFnParams,
|
||||
@@ -237,15 +238,36 @@ impl Parse for ExportedFn {
|
||||
let dynamic_type_path2 = syn::parse2::<syn::Path>(quote! { rhai::Dynamic }).unwrap();
|
||||
let mut return_dynamic = false;
|
||||
|
||||
let context_type_path1 = syn::parse2::<syn::Path>(quote! { NativeCallContext }).unwrap();
|
||||
let context_type_path2 =
|
||||
syn::parse2::<syn::Path>(quote! { rhai::NativeCallContext }).unwrap();
|
||||
let mut pass_context = false;
|
||||
|
||||
// #[cfg] attributes are not allowed on functions due to what is generated for them
|
||||
crate::attrs::deny_cfg_attr(&fn_all.attrs)?;
|
||||
|
||||
// Determine if the function is public.
|
||||
let is_public = matches!(fn_all.vis, syn::Visibility::Public(_));
|
||||
// Determine whether function generates a special calling convention for a mutable
|
||||
// reciever.
|
||||
|
||||
// Determine if the function requires a call context
|
||||
if let Some(first_arg) = fn_all.sig.inputs.first() {
|
||||
if let syn::FnArg::Typed(syn::PatType { ref ty, .. }) = first_arg {
|
||||
match flatten_type_groups(ty.as_ref()) {
|
||||
syn::Type::Path(p)
|
||||
if p.path == context_type_path1 || p.path == context_type_path2 =>
|
||||
{
|
||||
pass_context = true;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let skip_slots = if pass_context { 1 } else { 0 };
|
||||
|
||||
// Determine whether function generates a special calling convention for a mutable receiver.
|
||||
let mut_receiver = {
|
||||
if let Some(first_arg) = fn_all.sig.inputs.first() {
|
||||
if let Some(first_arg) = fn_all.sig.inputs.iter().skip(skip_slots).next() {
|
||||
match first_arg {
|
||||
syn::FnArg::Receiver(syn::Receiver {
|
||||
reference: Some(_), ..
|
||||
@@ -265,8 +287,7 @@ impl Parse for ExportedFn {
|
||||
_ => {
|
||||
return Err(syn::Error::new(
|
||||
ty.span(),
|
||||
"references from Rhai in this position \
|
||||
must be mutable",
|
||||
"references from Rhai in this position must be mutable",
|
||||
))
|
||||
}
|
||||
},
|
||||
@@ -281,7 +302,7 @@ impl Parse for ExportedFn {
|
||||
};
|
||||
|
||||
// All arguments after the first must be moved except for &str.
|
||||
for arg in fn_all.sig.inputs.iter().skip(1) {
|
||||
for arg in fn_all.sig.inputs.iter().skip(skip_slots + 1) {
|
||||
let ty = match arg {
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => ty,
|
||||
_ => panic!("internal error: receiver argument outside of first position!?"),
|
||||
@@ -304,8 +325,7 @@ impl Parse for ExportedFn {
|
||||
if !is_ok {
|
||||
return Err(syn::Error::new(
|
||||
ty.span(),
|
||||
"this type in this position passes from \
|
||||
Rhai by value",
|
||||
"this type in this position passes from Rhai by value",
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -337,6 +357,7 @@ impl Parse for ExportedFn {
|
||||
entire_span,
|
||||
signature: fn_all.sig,
|
||||
is_public,
|
||||
pass_context,
|
||||
return_dynamic,
|
||||
mut_receiver,
|
||||
params: ExportedFnParams::default(),
|
||||
@@ -363,6 +384,10 @@ impl ExportedFn {
|
||||
self.params.skip
|
||||
}
|
||||
|
||||
pub(crate) fn pass_context(&self) -> bool {
|
||||
self.pass_context
|
||||
}
|
||||
|
||||
pub(crate) fn signature(&self) -> &syn::Signature {
|
||||
&self.signature
|
||||
}
|
||||
@@ -418,11 +443,13 @@ impl ExportedFn {
|
||||
}
|
||||
|
||||
pub(crate) fn arg_list(&self) -> impl Iterator<Item = &syn::FnArg> {
|
||||
self.signature.inputs.iter()
|
||||
let skip = if self.pass_context { 1 } else { 0 };
|
||||
self.signature.inputs.iter().skip(skip)
|
||||
}
|
||||
|
||||
pub(crate) fn arg_count(&self) -> usize {
|
||||
self.signature.inputs.len()
|
||||
let skip = if self.pass_context { 1 } else { 0 };
|
||||
self.signature.inputs.len() - skip
|
||||
}
|
||||
|
||||
pub(crate) fn return_type(&self) -> Option<&syn::Type> {
|
||||
@@ -625,6 +652,10 @@ impl ExportedFn {
|
||||
let mut input_type_exprs: Vec<syn::Expr> = Vec::new();
|
||||
let skip_first_arg;
|
||||
|
||||
if self.pass_context {
|
||||
unpack_exprs.push(syn::parse2::<syn::Expr>(quote! { context }).unwrap());
|
||||
}
|
||||
|
||||
// Handle the first argument separately if the function has a "method like" receiver
|
||||
if is_method_call {
|
||||
skip_first_arg = true;
|
||||
@@ -764,9 +795,7 @@ impl ExportedFn {
|
||||
let type_name = syn::Ident::new(on_type_name, proc_macro2::Span::call_site());
|
||||
quote! {
|
||||
impl PluginFunction for #type_name {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), #arg_count,
|
||||
"wrong arg count: {} != {}",
|
||||
args.len(), #arg_count);
|
||||
|
@@ -68,7 +68,7 @@ pub(crate) fn generate_body(
|
||||
);
|
||||
}
|
||||
|
||||
// NB: these are token streams, because reparsing messes up "> >" vs ">>"
|
||||
// NB: these are token streams, because re-parsing messes up "> >" vs ">>"
|
||||
let mut gen_fn_tokens: Vec<proc_macro2::TokenStream> = Vec::new();
|
||||
for function in fns {
|
||||
function.update_scope(&parent_scope);
|
||||
|
@@ -277,9 +277,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 0usize,
|
||||
"wrong arg count: {} != {}", args.len(), 0usize);
|
||||
Ok(Dynamic::from(do_nothing()))
|
||||
@@ -320,9 +318,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<usize>();
|
||||
@@ -352,6 +348,49 @@ mod generate_tests {
|
||||
assert_streams_eq(item_fn.generate(), expected_tokens);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_arg_fn_with_context() {
|
||||
let input_tokens: TokenStream = quote! {
|
||||
pub fn do_something(context: NativeCallContext, x: usize) {}
|
||||
};
|
||||
|
||||
let expected_tokens = quote! {
|
||||
#[allow(unused)]
|
||||
pub mod rhai_fn_do_something {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<usize>();
|
||||
Ok(Dynamic::from(do_something(context, arg0)))
|
||||
}
|
||||
|
||||
fn is_method_call(&self) -> bool { false }
|
||||
fn is_variadic(&self) -> bool { false }
|
||||
fn clone_boxed(&self) -> Box<dyn PluginFunction> { Box::new(Token()) }
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
}
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn dynamic_result_fn(context: NativeCallContext, x: usize) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(super::do_something(context, x)))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let item_fn = syn::parse2::<ExportedFn>(input_tokens).unwrap();
|
||||
assert!(item_fn.pass_context());
|
||||
assert_streams_eq(item_fn.generate(), expected_tokens);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_dynamic() {
|
||||
let input_tokens: TokenStream = quote! {
|
||||
@@ -366,9 +405,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 0usize,
|
||||
"wrong arg count: {} != {}", args.len(), 0usize);
|
||||
Ok(return_dynamic())
|
||||
@@ -405,9 +442,7 @@ mod generate_tests {
|
||||
|
||||
let expected_tokens = quote! {
|
||||
impl PluginFunction for MyType {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<usize>();
|
||||
@@ -439,9 +474,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<usize>();
|
||||
@@ -485,9 +518,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<usize>();
|
||||
@@ -532,9 +563,7 @@ mod generate_tests {
|
||||
use super::*;
|
||||
struct Token();
|
||||
impl PluginFunction for Token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).take_immutable_string().unwrap();
|
||||
|
@@ -302,9 +302,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct get_mystic_number_token();
|
||||
impl PluginFunction for get_mystic_number_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 0usize,
|
||||
"wrong arg count: {} != {}", args.len(), 0usize);
|
||||
Ok(Dynamic::from(get_mystic_number()))
|
||||
@@ -364,9 +362,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_one_to_token();
|
||||
impl PluginFunction for add_one_to_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<INT>();
|
||||
@@ -441,9 +437,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_one_to_token();
|
||||
impl PluginFunction for add_one_to_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<INT>();
|
||||
@@ -469,9 +463,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_n_to_token();
|
||||
impl PluginFunction for add_n_to_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<INT>();
|
||||
@@ -535,9 +527,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_together_token();
|
||||
impl PluginFunction for add_together_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<INT>();
|
||||
@@ -608,9 +598,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_together_token();
|
||||
impl PluginFunction for add_together_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg0 = mem::take(args[0usize]).cast::<INT>();
|
||||
@@ -850,9 +838,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct get_mystic_number_token();
|
||||
impl PluginFunction for get_mystic_number_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 0usize,
|
||||
"wrong arg count: {} != {}", args.len(), 0usize);
|
||||
Ok(Dynamic::from(get_mystic_number()))
|
||||
@@ -943,9 +929,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct print_out_to_token();
|
||||
impl PluginFunction for print_out_to_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).take_immutable_string().unwrap();
|
||||
@@ -1007,9 +991,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct print_out_to_token();
|
||||
impl PluginFunction for print_out_to_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = mem::take(args[0usize]).take_string().unwrap();
|
||||
@@ -1071,9 +1053,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct increment_token();
|
||||
impl PluginFunction for increment_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = &mut args[0usize].write_lock::<FLOAT>().unwrap();
|
||||
@@ -1138,9 +1118,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct increment_token();
|
||||
impl PluginFunction for increment_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = &mut args[0usize].write_lock::<FLOAT>().unwrap();
|
||||
@@ -1225,9 +1203,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct increment_token();
|
||||
impl PluginFunction for increment_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = &mut args[0usize].write_lock::<FLOAT>().unwrap();
|
||||
@@ -1310,9 +1286,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct int_foo_token();
|
||||
impl PluginFunction for int_foo_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = &mut args[0usize].write_lock::<u64>().unwrap();
|
||||
@@ -1376,9 +1350,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct int_foo_token();
|
||||
impl PluginFunction for int_foo_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 1usize,
|
||||
"wrong arg count: {} != {}", args.len(), 1usize);
|
||||
let arg0 = &mut args[0usize].write_lock::<u64>().unwrap();
|
||||
@@ -1442,9 +1414,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct int_foo_token();
|
||||
impl PluginFunction for int_foo_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
@@ -1513,9 +1483,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct int_foo_token();
|
||||
impl PluginFunction for int_foo_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
@@ -1580,9 +1548,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct get_by_index_token();
|
||||
impl PluginFunction for get_by_index_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
@@ -1652,9 +1618,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct get_by_index_token();
|
||||
impl PluginFunction for get_by_index_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 2usize,
|
||||
"wrong arg count: {} != {}", args.len(), 2usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
@@ -1721,9 +1685,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct set_by_index_token();
|
||||
impl PluginFunction for set_by_index_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 3usize,
|
||||
"wrong arg count: {} != {}", args.len(), 3usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
@@ -1797,9 +1759,7 @@ mod generate_tests {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct set_by_index_token();
|
||||
impl PluginFunction for set_by_index_token {
|
||||
fn call(&self,
|
||||
args: &mut [&mut Dynamic]
|
||||
) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
fn call(&self, context: NativeCallContext, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
debug_assert_eq!(args.len(), 3usize,
|
||||
"wrong arg count: {} != {}", args.len(), 3usize);
|
||||
let arg1 = mem::take(args[1usize]).cast::<u64>();
|
||||
|
Reference in New Issue
Block a user