Fix codegen and tests to new API changes.

This commit is contained in:
Stephen Chung 2020-08-06 14:10:27 +08:00
parent 4465a44673
commit dd6b6cd49f
5 changed files with 82 additions and 80 deletions

View File

@ -150,7 +150,7 @@ impl ExportedFn {
pub fn generate(self) -> proc_macro2::TokenStream { pub fn generate(self) -> proc_macro2::TokenStream {
let name: syn::Ident = syn::Ident::new( let name: syn::Ident = syn::Ident::new(
&format!("rhai_fn__{}", self.name().to_string()), &format!("rhai_fn_{}", self.name().to_string()),
self.name().span(), self.name().span(),
); );
let impl_block = self.generate_impl("Token"); let impl_block = self.generate_impl("Token");
@ -171,8 +171,9 @@ impl ExportedFn {
pub fn generate_callable(&self, on_type_name: &str) -> proc_macro2::TokenStream { pub fn generate_callable(&self, on_type_name: &str) -> proc_macro2::TokenStream {
let token_name: syn::Ident = syn::Ident::new(on_type_name, self.name().span()); let token_name: syn::Ident = syn::Ident::new(on_type_name, self.name().span());
let callable_fn_name: syn::Ident = syn::Ident::new( let callable_fn_name: syn::Ident = syn::Ident::new(
format!("{}__callable", on_type_name).as_str(), format!("{}_callable", on_type_name.to_lowercase()).as_str(),
self.name().span()); self.name().span(),
);
quote! { quote! {
pub fn #callable_fn_name() -> CallableFunction { pub fn #callable_fn_name() -> CallableFunction {
CallableFunction::from_plugin(#token_name()) CallableFunction::from_plugin(#token_name())
@ -183,8 +184,9 @@ impl ExportedFn {
pub fn generate_input_types(&self, on_type_name: &str) -> proc_macro2::TokenStream { pub fn generate_input_types(&self, on_type_name: &str) -> proc_macro2::TokenStream {
let token_name: syn::Ident = syn::Ident::new(on_type_name, self.name().span()); let token_name: syn::Ident = syn::Ident::new(on_type_name, self.name().span());
let input_types_fn_name: syn::Ident = syn::Ident::new( let input_types_fn_name: syn::Ident = syn::Ident::new(
format!("{}__input_types", on_type_name).as_str(), format!("{}_input_types", on_type_name.to_lowercase()).as_str(),
self.name().span()); self.name().span(),
);
quote! { quote! {
pub fn #input_types_fn_name() -> Box<[std::any::TypeId]> { pub fn #input_types_fn_name() -> Box<[std::any::TypeId]> {
#token_name().input_types() #token_name().input_types()
@ -218,7 +220,7 @@ impl ExportedFn {
} }
}; };
let downcast_span = quote_spanned!( let downcast_span = quote_spanned!(
arg_type.span()=> args[0usize].downcast_mut::<#arg_type>().unwrap()); arg_type.span()=> &mut *args[0usize].write_lock::<#arg_type>().unwrap());
unpack_stmts.push( unpack_stmts.push(
syn::parse2::<syn::Stmt>(quote! { syn::parse2::<syn::Stmt>(quote! {
let #var: &mut _ = #downcast_span; let #var: &mut _ = #downcast_span;
@ -603,7 +605,7 @@ mod generate_tests {
let expected_tokens = quote! { let expected_tokens = quote! {
#[allow(unused)] #[allow(unused)]
pub mod rhai_fn__do_nothing { pub mod rhai_fn_do_nothing {
use super::*; use super::*;
struct Token(); struct Token();
impl PluginFunction for Token { impl PluginFunction for Token {
@ -625,10 +627,10 @@ mod generate_tests {
vec![].into_boxed_slice() vec![].into_boxed_slice()
} }
} }
pub fn Token__callable() -> CallableFunction { pub fn token_callable() -> CallableFunction {
CallableFunction::from_plugin(Token()) CallableFunction::from_plugin(Token())
} }
pub fn Token__input_types() -> Box<[std::any::TypeId]> { pub fn token_input_types() -> Box<[std::any::TypeId]> {
Token().input_types() Token().input_types()
} }
} }
@ -646,7 +648,7 @@ mod generate_tests {
let expected_tokens = quote! { let expected_tokens = quote! {
#[allow(unused)] #[allow(unused)]
pub mod rhai_fn__do_something { pub mod rhai_fn_do_something {
use super::*; use super::*;
struct Token(); struct Token();
impl PluginFunction for Token { impl PluginFunction for Token {
@ -669,10 +671,10 @@ mod generate_tests {
vec![std::any::TypeId::of::<usize>()].into_boxed_slice() vec![std::any::TypeId::of::<usize>()].into_boxed_slice()
} }
} }
pub fn Token__callable() -> CallableFunction { pub fn token_callable() -> CallableFunction {
CallableFunction::from_plugin(Token()) CallableFunction::from_plugin(Token())
} }
pub fn Token__input_types() -> Box<[std::any::TypeId]> { pub fn token_input_types() -> Box<[std::any::TypeId]> {
Token().input_types() Token().input_types()
} }
} }
@ -723,7 +725,7 @@ mod generate_tests {
let expected_tokens = quote! { let expected_tokens = quote! {
#[allow(unused)] #[allow(unused)]
pub mod rhai_fn__add_together { pub mod rhai_fn_add_together {
use super::*; use super::*;
struct Token(); struct Token();
impl PluginFunction for Token { impl PluginFunction for Token {
@ -748,10 +750,10 @@ mod generate_tests {
std::any::TypeId::of::<usize>()].into_boxed_slice() std::any::TypeId::of::<usize>()].into_boxed_slice()
} }
} }
pub fn Token__callable() -> CallableFunction { pub fn token_callable() -> CallableFunction {
CallableFunction::from_plugin(Token()) CallableFunction::from_plugin(Token())
} }
pub fn Token__input_types() -> Box<[std::any::TypeId]> { pub fn token_input_types() -> Box<[std::any::TypeId]> {
Token().input_types() Token().input_types()
} }
} }
@ -769,7 +771,7 @@ mod generate_tests {
let expected_tokens = quote! { let expected_tokens = quote! {
#[allow(unused)] #[allow(unused)]
pub mod rhai_fn__increment { pub mod rhai_fn_increment {
use super::*; use super::*;
struct Token(); struct Token();
impl PluginFunction for Token { impl PluginFunction for Token {
@ -782,7 +784,7 @@ mod generate_tests {
args.len(), 2usize), Position::none()))); args.len(), 2usize), Position::none())));
} }
let arg1 = args[1usize].downcast_clone::<usize>().unwrap(); let arg1 = args[1usize].downcast_clone::<usize>().unwrap();
let arg0: &mut _ = args[0usize].downcast_mut::<usize>().unwrap(); let arg0: &mut _ = args[0usize].write_lock::<usize>().unwrap();
Ok(Dynamic::from(increment(arg0, arg1))) Ok(Dynamic::from(increment(arg0, arg1)))
} }
@ -794,10 +796,10 @@ mod generate_tests {
std::any::TypeId::of::<usize>()].into_boxed_slice() std::any::TypeId::of::<usize>()].into_boxed_slice()
} }
} }
pub fn Token__callable() -> CallableFunction { pub fn token_callable() -> CallableFunction {
CallableFunction::from_plugin(Token()) CallableFunction::from_plugin(Token())
} }
pub fn Token__input_types() -> Box<[std::any::TypeId]> { pub fn token_input_types() -> Box<[std::any::TypeId]> {
Token().input_types() Token().input_types()
} }
} }
@ -816,7 +818,7 @@ mod generate_tests {
let expected_tokens = quote! { let expected_tokens = quote! {
#[allow(unused)] #[allow(unused)]
pub mod rhai_fn__special_print { pub mod rhai_fn_special_print {
use super::*; use super::*;
struct Token(); struct Token();
impl PluginFunction for Token { impl PluginFunction for Token {
@ -839,10 +841,10 @@ mod generate_tests {
vec![std::any::TypeId::of::<ImmutableString>()].into_boxed_slice() vec![std::any::TypeId::of::<ImmutableString>()].into_boxed_slice()
} }
} }
pub fn Token__callable() -> CallableFunction { pub fn token_callable() -> CallableFunction {
CallableFunction::from_plugin(Token()) CallableFunction::from_plugin(Token())
} }
pub fn Token__input_types() -> Box<[std::any::TypeId]> { pub fn token_input_types() -> Box<[std::any::TypeId]> {
Token().input_types() Token().input_types()
} }
} }

View File

@ -99,7 +99,7 @@ pub fn export_module(
pub fn exported_module(module_path: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn exported_module(module_path: proc_macro::TokenStream) -> proc_macro::TokenStream {
let module_path = parse_macro_input!(module_path as syn::Path); let module_path = parse_macro_input!(module_path as syn::Path);
let tokens = quote::quote! { let tokens = quote::quote! {
#module_path::rhai_module__generate() #module_path::rhai_module_generate()
}; };
proc_macro::TokenStream::from(tokens) proc_macro::TokenStream::from(tokens)
} }
@ -133,7 +133,7 @@ pub fn register_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenS
let mut g = rust_modpath.clone().segments; let mut g = rust_modpath.clone().segments;
g.pop(); g.pop();
let ident = syn::Ident::new( let ident = syn::Ident::new(
&format!("rhai_fn__{}", rust_modpath.segments.last().unwrap().ident), &format!("rhai_fn_{}", rust_modpath.segments.last().unwrap().ident),
items[2].span(), items[2].span(),
); );
g.push_value(syn::PathSegment { g.push_value(syn::PathSegment {
@ -144,8 +144,8 @@ pub fn register_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenS
}; };
let tokens = quote! { let tokens = quote! {
#rhai_module.set_fn(#export_name, rhai::FnAccess::Public, #rhai_module.set_fn(#export_name, rhai::FnAccess::Public,
#gen_mod_path::Token__input_types().as_ref(), #gen_mod_path::token_input_types().as_ref(),
#gen_mod_path::Token__callable()); #gen_mod_path::token_callable());
}; };
proc_macro::TokenStream::from(tokens) proc_macro::TokenStream::from(tokens)

View File

@ -265,7 +265,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m m
} }
@ -294,15 +294,15 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_fn("get_mystic_number", FnAccess::Public, &[], m.set_fn("get_mystic_number", FnAccess::Public, &[],
CallableFunction::from_plugin(get_mystic_number__Token())); CallableFunction::from_plugin(get_mystic_number_token()));
m m
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct get_mystic_number__Token(); struct get_mystic_number_token();
impl PluginFunction for get_mystic_number__Token { impl PluginFunction for get_mystic_number_token {
fn call(&self, fn call(&self,
args: &mut [&mut Dynamic], pos: Position args: &mut [&mut Dynamic], pos: Position
) -> Result<Dynamic, Box<EvalAltResult>> { ) -> Result<Dynamic, Box<EvalAltResult>> {
@ -317,17 +317,17 @@ mod generate_tests {
fn is_method_call(&self) -> bool { false } fn is_method_call(&self) -> bool { false }
fn is_varadic(&self) -> bool { false } fn is_varadic(&self) -> bool { false }
fn clone_boxed(&self) -> Box<dyn PluginFunction> { fn clone_boxed(&self) -> Box<dyn PluginFunction> {
Box::new(get_mystic_number__Token()) Box::new(get_mystic_number_token())
} }
fn input_types(&self) -> Box<[std::any::TypeId]> { fn input_types(&self) -> Box<[std::any::TypeId]> {
vec![].into_boxed_slice() vec![].into_boxed_slice()
} }
} }
pub fn get_mystic_number__Token__callable() -> CallableFunction { pub fn get_mystic_number_token_callable() -> CallableFunction {
CallableFunction::from_plugin(get_mystic_number__Token()) CallableFunction::from_plugin(get_mystic_number_token())
} }
pub fn get_mystic_number__Token__input_types() -> Box<[std::any::TypeId]> { pub fn get_mystic_number_token_input_types() -> Box<[std::any::TypeId]> {
get_mystic_number__Token().input_types() get_mystic_number_token().input_types()
} }
} }
}; };
@ -354,15 +354,15 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_fn("add_one_to", FnAccess::Public, &[core::any::TypeId::of::<INT>()], m.set_fn("add_one_to", FnAccess::Public, &[core::any::TypeId::of::<INT>()],
CallableFunction::from_plugin(add_one_to__Token())); CallableFunction::from_plugin(add_one_to_token()));
m m
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct add_one_to__Token(); struct add_one_to_token();
impl PluginFunction for add_one_to__Token { impl PluginFunction for add_one_to_token {
fn call(&self, fn call(&self,
args: &mut [&mut Dynamic], pos: Position args: &mut [&mut Dynamic], pos: Position
) -> Result<Dynamic, Box<EvalAltResult>> { ) -> Result<Dynamic, Box<EvalAltResult>> {
@ -378,17 +378,17 @@ mod generate_tests {
fn is_method_call(&self) -> bool { false } fn is_method_call(&self) -> bool { false }
fn is_varadic(&self) -> bool { false } fn is_varadic(&self) -> bool { false }
fn clone_boxed(&self) -> Box<dyn PluginFunction> { fn clone_boxed(&self) -> Box<dyn PluginFunction> {
Box::new(add_one_to__Token()) Box::new(add_one_to_token())
} }
fn input_types(&self) -> Box<[std::any::TypeId]> { fn input_types(&self) -> Box<[std::any::TypeId]> {
vec![std::any::TypeId::of::<INT>()].into_boxed_slice() vec![std::any::TypeId::of::<INT>()].into_boxed_slice()
} }
} }
pub fn add_one_to__Token__callable() -> CallableFunction { pub fn add_one_to_token_callable() -> CallableFunction {
CallableFunction::from_plugin(add_one_to__Token()) CallableFunction::from_plugin(add_one_to_token())
} }
pub fn add_one_to__Token__input_types() -> Box<[std::any::TypeId]> { pub fn add_one_to_token_input_types() -> Box<[std::any::TypeId]> {
add_one_to__Token().input_types() add_one_to_token().input_types()
} }
} }
}; };
@ -415,16 +415,16 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_fn("add_together", FnAccess::Public, &[core::any::TypeId::of::<INT>(), m.set_fn("add_together", FnAccess::Public, &[core::any::TypeId::of::<INT>(),
core::any::TypeId::of::<INT>()], core::any::TypeId::of::<INT>()],
CallableFunction::from_plugin(add_together__Token())); CallableFunction::from_plugin(add_together_token()));
m m
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct add_together__Token(); struct add_together_token();
impl PluginFunction for add_together__Token { impl PluginFunction for add_together_token {
fn call(&self, fn call(&self,
args: &mut [&mut Dynamic], pos: Position args: &mut [&mut Dynamic], pos: Position
) -> Result<Dynamic, Box<EvalAltResult>> { ) -> Result<Dynamic, Box<EvalAltResult>> {
@ -441,18 +441,18 @@ mod generate_tests {
fn is_method_call(&self) -> bool { false } fn is_method_call(&self) -> bool { false }
fn is_varadic(&self) -> bool { false } fn is_varadic(&self) -> bool { false }
fn clone_boxed(&self) -> Box<dyn PluginFunction> { fn clone_boxed(&self) -> Box<dyn PluginFunction> {
Box::new(add_together__Token()) Box::new(add_together_token())
} }
fn input_types(&self) -> Box<[std::any::TypeId]> { fn input_types(&self) -> Box<[std::any::TypeId]> {
vec![std::any::TypeId::of::<INT>(), vec![std::any::TypeId::of::<INT>(),
std::any::TypeId::of::<INT>()].into_boxed_slice() std::any::TypeId::of::<INT>()].into_boxed_slice()
} }
} }
pub fn add_together__Token__callable() -> CallableFunction { pub fn add_together_token_callable() -> CallableFunction {
CallableFunction::from_plugin(add_together__Token()) CallableFunction::from_plugin(add_together_token())
} }
pub fn add_together__Token__input_types() -> Box<[std::any::TypeId]> { pub fn add_together_token_input_types() -> Box<[std::any::TypeId]> {
add_together__Token().input_types() add_together_token().input_types()
} }
} }
}; };
@ -475,7 +475,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_var("MYSTIC_NUMBER", 42); m.set_var("MYSTIC_NUMBER", 42);
m m
@ -503,7 +503,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_var("MYSTIC_NUMBER", 42); m.set_var("MYSTIC_NUMBER", 42);
m m
@ -533,7 +533,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m m
} }
@ -558,7 +558,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m m
} }
@ -587,16 +587,16 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_fn("print_out_to", FnAccess::Public, m.set_fn("print_out_to", FnAccess::Public,
&[core::any::TypeId::of::<ImmutableString>()], &[core::any::TypeId::of::<ImmutableString>()],
CallableFunction::from_plugin(print_out_to__Token())); CallableFunction::from_plugin(print_out_to_token()));
m m
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct print_out_to__Token(); struct print_out_to_token();
impl PluginFunction for print_out_to__Token { impl PluginFunction for print_out_to_token {
fn call(&self, fn call(&self,
args: &mut [&mut Dynamic], pos: Position args: &mut [&mut Dynamic], pos: Position
) -> Result<Dynamic, Box<EvalAltResult>> { ) -> Result<Dynamic, Box<EvalAltResult>> {
@ -612,17 +612,17 @@ mod generate_tests {
fn is_method_call(&self) -> bool { false } fn is_method_call(&self) -> bool { false }
fn is_varadic(&self) -> bool { false } fn is_varadic(&self) -> bool { false }
fn clone_boxed(&self) -> Box<dyn PluginFunction> { fn clone_boxed(&self) -> Box<dyn PluginFunction> {
Box::new(print_out_to__Token()) Box::new(print_out_to_token())
} }
fn input_types(&self) -> Box<[std::any::TypeId]> { fn input_types(&self) -> Box<[std::any::TypeId]> {
vec![std::any::TypeId::of::<ImmutableString>()].into_boxed_slice() vec![std::any::TypeId::of::<ImmutableString>()].into_boxed_slice()
} }
} }
pub fn print_out_to__Token__callable() -> CallableFunction { pub fn print_out_to_token_callable() -> CallableFunction {
CallableFunction::from_plugin(print_out_to__Token()) CallableFunction::from_plugin(print_out_to_token())
} }
pub fn print_out_to__Token__input_types() -> Box<[std::any::TypeId]> { pub fn print_out_to_token_input_types() -> Box<[std::any::TypeId]> {
print_out_to__Token().input_types() print_out_to_token().input_types()
} }
} }
}; };
@ -649,16 +649,16 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
m.set_fn("increment", FnAccess::Public, m.set_fn("increment", FnAccess::Public,
&[core::any::TypeId::of::<FLOAT>()], &[core::any::TypeId::of::<FLOAT>()],
CallableFunction::from_plugin(increment__Token())); CallableFunction::from_plugin(increment_token()));
m m
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct increment__Token(); struct increment_token();
impl PluginFunction for increment__Token { impl PluginFunction for increment_token {
fn call(&self, fn call(&self,
args: &mut [&mut Dynamic], pos: Position args: &mut [&mut Dynamic], pos: Position
) -> Result<Dynamic, Box<EvalAltResult>> { ) -> Result<Dynamic, Box<EvalAltResult>> {
@ -667,24 +667,24 @@ mod generate_tests {
format!("wrong arg count: {} != {}", format!("wrong arg count: {} != {}",
args.len(), 1usize), Position::none()))); args.len(), 1usize), Position::none())));
} }
let arg0: &mut _ = args[0usize].downcast_mut::<FLOAT>().unwrap(); let arg0: &mut _ = args[0usize].write_lock::<FLOAT>().unwrap();
Ok(Dynamic::from(increment(arg0))) Ok(Dynamic::from(increment(arg0)))
} }
fn is_method_call(&self) -> bool { true } fn is_method_call(&self) -> bool { true }
fn is_varadic(&self) -> bool { false } fn is_varadic(&self) -> bool { false }
fn clone_boxed(&self) -> Box<dyn PluginFunction> { fn clone_boxed(&self) -> Box<dyn PluginFunction> {
Box::new(increment__Token()) Box::new(increment_token())
} }
fn input_types(&self) -> Box<[std::any::TypeId]> { fn input_types(&self) -> Box<[std::any::TypeId]> {
vec![std::any::TypeId::of::<FLOAT>()].into_boxed_slice() vec![std::any::TypeId::of::<FLOAT>()].into_boxed_slice()
} }
} }
pub fn increment__Token__callable() -> CallableFunction { pub fn increment_token_callable() -> CallableFunction {
CallableFunction::from_plugin(increment__Token()) CallableFunction::from_plugin(increment_token())
} }
pub fn increment__Token__input_types() -> Box<[std::any::TypeId]> { pub fn increment_token_input_types() -> Box<[std::any::TypeId]> {
increment__Token().input_types() increment_token().input_types()
} }
} }
}; };

View File

@ -26,7 +26,7 @@ pub(crate) fn generate_body(
let mut gen_fn_tokens: Vec<proc_macro2::TokenStream> = Vec::new(); let mut gen_fn_tokens: Vec<proc_macro2::TokenStream> = Vec::new();
for function in fns { for function in fns {
let fn_token_name = syn::Ident::new( let fn_token_name = syn::Ident::new(
&format!("{}__Token", function.name().to_string()), &format!("{}_Token", function.name().to_string()),
function.name().span(), function.name().span(),
); );
let fn_literal = let fn_literal =
@ -90,7 +90,7 @@ pub(crate) fn generate_body(
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_module__generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
#(#set_fn_stmts)* #(#set_fn_stmts)*
#(#set_const_stmts)* #(#set_const_stmts)*

View File

@ -152,7 +152,7 @@ to partition the slice:
let (first, rest) = args.split_at_mut(1); let (first, rest) = args.split_at_mut(1);
// Mutable reference to the first parameter // Mutable reference to the first parameter
let this_ptr = first[0].downcast_mut::<A>().unwrap(); let this_ptr = first[0].write_lock::<A>().unwrap();
// Immutable reference to the second value parameter // Immutable reference to the second value parameter
// This can be mutable but there is no point because the parameter is passed by value // This can be mutable but there is no point because the parameter is passed by value