Add return type to function metadata.
This commit is contained in:
@@ -84,7 +84,15 @@ pub(crate) fn flatten_type_groups(ty: &syn::Type) -> &syn::Type {
|
||||
}
|
||||
|
||||
pub(crate) fn print_type(ty: &syn::Type) -> String {
|
||||
ty.to_token_stream().to_string().replace("& ", "&")
|
||||
ty.to_token_stream()
|
||||
.to_string()
|
||||
.replace(" , ", ", ")
|
||||
.replace("& ", "&")
|
||||
.replace(" :: ", "::")
|
||||
.replace(" ( ", "(")
|
||||
.replace(" ) ", ")")
|
||||
.replace(" < ", "<")
|
||||
.replace(" > ", ">")
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
@@ -582,6 +590,7 @@ impl ExportedFn {
|
||||
let callable_block = self.generate_callable("Token");
|
||||
let input_names_block = self.generate_input_names("Token");
|
||||
let input_types_block = self.generate_input_types("Token");
|
||||
let return_type_block = self.generate_return_type("Token");
|
||||
let dyn_result_fn_block = self.generate_dynamic_fn();
|
||||
quote! {
|
||||
#[allow(unused)]
|
||||
@@ -592,6 +601,7 @@ impl ExportedFn {
|
||||
#callable_block
|
||||
#input_names_block
|
||||
#input_types_block
|
||||
#return_type_block
|
||||
#dyn_result_fn_block
|
||||
}
|
||||
}
|
||||
@@ -687,6 +697,19 @@ impl ExportedFn {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_return_type(&self, on_type_name: &str) -> proc_macro2::TokenStream {
|
||||
let token_name: syn::Ident = syn::Ident::new(on_type_name, self.name().span());
|
||||
let return_type_fn_name: syn::Ident = syn::Ident::new(
|
||||
format!("{}_return_type", on_type_name.to_lowercase()).as_str(),
|
||||
self.name().span(),
|
||||
);
|
||||
quote! {
|
||||
pub fn #return_type_fn_name() -> &'static str {
|
||||
#token_name().return_type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_impl(&self, on_type_name: &str) -> proc_macro2::TokenStream {
|
||||
let sig_name = self.name().clone();
|
||||
let name = self.params.name.as_ref().map_or_else(
|
||||
@@ -701,6 +724,12 @@ impl ExportedFn {
|
||||
let mut unpack_exprs: Vec<syn::Expr> = Vec::new();
|
||||
let mut input_type_names: Vec<String> = Vec::new();
|
||||
let mut input_type_exprs: Vec<syn::Expr> = Vec::new();
|
||||
|
||||
let return_type = self
|
||||
.return_type()
|
||||
.map(print_type)
|
||||
.unwrap_or_else(|| "()".to_string());
|
||||
|
||||
let skip_first_arg;
|
||||
|
||||
if self.pass_context {
|
||||
@@ -867,6 +896,9 @@ impl ExportedFn {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![#(#input_type_exprs),*].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
#return_type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -136,6 +136,11 @@ pub(crate) fn generate_body(
|
||||
})
|
||||
.collect();
|
||||
|
||||
let return_type = function
|
||||
.return_type()
|
||||
.map(print_type)
|
||||
.unwrap_or_else(|| "()".to_string());
|
||||
|
||||
if let Some(ns) = function.params().namespace {
|
||||
namespace = ns;
|
||||
}
|
||||
@@ -151,7 +156,7 @@ pub(crate) fn generate_body(
|
||||
set_fn_stmts.push(
|
||||
syn::parse2::<syn::Stmt>(quote! {
|
||||
m.set_fn(#fn_literal, FnNamespace::#ns_str, FnAccess::Public,
|
||||
Some(&[#(#fn_input_names),*]), &[#(#fn_input_types),*],
|
||||
Some(&[#(#fn_input_names,)* #return_type]), &[#(#fn_input_types),*],
|
||||
#fn_token_name().into());
|
||||
})
|
||||
.unwrap(),
|
||||
@@ -166,6 +171,7 @@ pub(crate) fn generate_body(
|
||||
gen_fn_tokens.push(function.generate_callable(&fn_token_name.to_string()));
|
||||
gen_fn_tokens.push(function.generate_input_names(&fn_token_name.to_string()));
|
||||
gen_fn_tokens.push(function.generate_input_types(&fn_token_name.to_string()));
|
||||
gen_fn_tokens.push(function.generate_return_type(&fn_token_name.to_string()));
|
||||
}
|
||||
|
||||
let mut generate_fncall = syn::parse2::<syn::ItemMod>(quote! {
|
||||
|
@@ -292,6 +292,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -302,6 +305,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn() -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(do_nothing()))
|
||||
}
|
||||
@@ -340,6 +346,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -350,6 +359,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn(x: usize) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(do_something(x)))
|
||||
}
|
||||
@@ -388,6 +400,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -398,6 +413,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn(context: NativeCallContext, x: usize) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(do_something(context, x)))
|
||||
}
|
||||
@@ -438,6 +456,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"rhai::Dynamic"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -448,6 +469,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn() -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(return_dynamic())
|
||||
}
|
||||
@@ -482,7 +506,10 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let item_fn = syn::parse2::<ExportedFn>(input_tokens).unwrap();
|
||||
@@ -519,6 +546,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<usize>(),
|
||||
TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"usize"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -529,6 +559,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn(x: usize, y: usize) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(add_together(x, y)))
|
||||
}
|
||||
@@ -569,6 +602,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<usize>(),
|
||||
TypeId::of::<usize>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -579,6 +615,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn(x: &mut usize, y: usize) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(increment(x, y)))
|
||||
}
|
||||
@@ -618,6 +657,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<ImmutableString>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn token_callable() -> CallableFunction {
|
||||
Token().into()
|
||||
@@ -628,6 +670,9 @@ mod generate_tests {
|
||||
pub fn token_input_types() -> Box<[TypeId]> {
|
||||
Token().input_types()
|
||||
}
|
||||
pub fn token_return_type() -> &'static str {
|
||||
Token().return_type()
|
||||
}
|
||||
pub fn dynamic_result_fn(message: &str) -> Result<Dynamic, Box<EvalAltResult> > {
|
||||
Ok(Dynamic::from(special_print(message)))
|
||||
}
|
||||
|
@@ -297,7 +297,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, Some(&[]), &[],
|
||||
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, Some(&["INT"]), &[],
|
||||
get_mystic_number_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -321,6 +321,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn get_mystic_number_token_callable() -> CallableFunction {
|
||||
get_mystic_number_token().into()
|
||||
@@ -331,6 +334,9 @@ mod generate_tests {
|
||||
pub fn get_mystic_number_token_input_types() -> Box<[TypeId]> {
|
||||
get_mystic_number_token().input_types()
|
||||
}
|
||||
pub fn get_mystic_number_token_return_type() -> &'static str {
|
||||
get_mystic_number_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -365,7 +371,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("add_one_to", FnNamespace::Global, FnAccess::Public, Some(&["x: INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
m.set_fn("add_one_to", FnNamespace::Global, FnAccess::Public, Some(&["x: INT", "INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
add_one_to_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -390,6 +396,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_one_to_token_callable() -> CallableFunction {
|
||||
add_one_to_token().into()
|
||||
@@ -400,6 +409,9 @@ mod generate_tests {
|
||||
pub fn add_one_to_token_input_types() -> Box<[TypeId]> {
|
||||
add_one_to_token().input_types()
|
||||
}
|
||||
pub fn add_one_to_token_return_type() -> &'static str {
|
||||
add_one_to_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -433,7 +445,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("add_one_to", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
m.set_fn("add_one_to", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
add_one_to_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -458,6 +470,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_one_to_token_callable() -> CallableFunction {
|
||||
add_one_to_token().into()
|
||||
@@ -468,6 +483,9 @@ mod generate_tests {
|
||||
pub fn add_one_to_token_input_types() -> Box<[TypeId]> {
|
||||
add_one_to_token().input_types()
|
||||
}
|
||||
pub fn add_one_to_token_return_type() -> &'static str {
|
||||
add_one_to_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -512,9 +530,9 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "INT"]), &[core::any::TypeId::of::<INT>()],
|
||||
add_one_to_token().into());
|
||||
m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT"]),
|
||||
m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT", "INT"]),
|
||||
&[core::any::TypeId::of::<INT>(), core::any::TypeId::of::<INT>()],
|
||||
add_n_to_token().into());
|
||||
if flatten {} else {}
|
||||
@@ -540,6 +558,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_one_to_token_callable() -> CallableFunction {
|
||||
add_one_to_token().into()
|
||||
@@ -550,6 +571,9 @@ mod generate_tests {
|
||||
pub fn add_one_to_token_input_types() -> Box<[TypeId]> {
|
||||
add_one_to_token().input_types()
|
||||
}
|
||||
pub fn add_one_to_token_return_type() -> &'static str {
|
||||
add_one_to_token().return_type()
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
struct add_n_to_token();
|
||||
@@ -574,6 +598,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<INT>(),
|
||||
TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_n_to_token_callable() -> CallableFunction {
|
||||
add_n_to_token().into()
|
||||
@@ -584,6 +611,9 @@ mod generate_tests {
|
||||
pub fn add_n_to_token_input_types() -> Box<[TypeId]> {
|
||||
add_n_to_token().input_types()
|
||||
}
|
||||
pub fn add_n_to_token_return_type() -> &'static str {
|
||||
add_n_to_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -617,7 +647,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT"]),
|
||||
m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT", "INT"]),
|
||||
&[core::any::TypeId::of::<INT>(), core::any::TypeId::of::<INT>()],
|
||||
add_together_token().into());
|
||||
if flatten {} else {}
|
||||
@@ -645,6 +675,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<INT>(),
|
||||
TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_together_token_callable() -> CallableFunction {
|
||||
add_together_token().into()
|
||||
@@ -655,6 +688,9 @@ mod generate_tests {
|
||||
pub fn add_together_token_input_types() -> Box<[TypeId]> {
|
||||
add_together_token().input_types()
|
||||
}
|
||||
pub fn add_together_token_return_type() -> &'static str {
|
||||
add_together_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -689,13 +725,13 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("add", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT"]),
|
||||
m.set_fn("add", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT", "INT"]),
|
||||
&[core::any::TypeId::of::<INT>(), core::any::TypeId::of::<INT>()],
|
||||
add_together_token().into());
|
||||
m.set_fn("+", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT"]),
|
||||
m.set_fn("+", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT", "INT"]),
|
||||
&[core::any::TypeId::of::<INT>(), core::any::TypeId::of::<INT>()],
|
||||
add_together_token().into());
|
||||
m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT"]),
|
||||
m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(&["x: INT", "y: INT", "INT"]),
|
||||
&[core::any::TypeId::of::<INT>(), core::any::TypeId::of::<INT>()],
|
||||
add_together_token().into());
|
||||
if flatten {} else {}
|
||||
@@ -723,6 +759,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<INT>(),
|
||||
TypeId::of::<INT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn add_together_token_callable() -> CallableFunction {
|
||||
add_together_token().into()
|
||||
@@ -733,6 +772,9 @@ mod generate_tests {
|
||||
pub fn add_together_token_input_types() -> Box<[TypeId]> {
|
||||
add_together_token().input_types()
|
||||
}
|
||||
pub fn add_together_token_return_type() -> &'static str {
|
||||
add_together_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -948,7 +990,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, Some(&[]), &[],
|
||||
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, Some(&["INT"]), &[],
|
||||
get_mystic_number_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -972,6 +1014,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"INT"
|
||||
}
|
||||
}
|
||||
pub fn get_mystic_number_token_callable() -> CallableFunction {
|
||||
get_mystic_number_token().into()
|
||||
@@ -982,6 +1027,9 @@ mod generate_tests {
|
||||
pub fn get_mystic_number_token_input_types() -> Box<[TypeId]> {
|
||||
get_mystic_number_token().input_types()
|
||||
}
|
||||
pub fn get_mystic_number_token_return_type() -> &'static str {
|
||||
get_mystic_number_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1047,7 +1095,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &str"]), &[core::any::TypeId::of::<ImmutableString>()],
|
||||
Some(&["x: &str", "()"]), &[core::any::TypeId::of::<ImmutableString>()],
|
||||
print_out_to_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1072,6 +1120,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<ImmutableString>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn print_out_to_token_callable() -> CallableFunction {
|
||||
print_out_to_token().into()
|
||||
@@ -1082,6 +1133,9 @@ mod generate_tests {
|
||||
pub fn print_out_to_token_input_types() -> Box<[TypeId]> {
|
||||
print_out_to_token().input_types()
|
||||
}
|
||||
pub fn print_out_to_token_return_type() -> &'static str {
|
||||
print_out_to_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1116,7 +1170,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: String"]), &[core::any::TypeId::of::<ImmutableString>()],
|
||||
Some(&["x: String", "()"]), &[core::any::TypeId::of::<ImmutableString>()],
|
||||
print_out_to_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1141,6 +1195,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<ImmutableString>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn print_out_to_token_callable() -> CallableFunction {
|
||||
print_out_to_token().into()
|
||||
@@ -1151,6 +1208,9 @@ mod generate_tests {
|
||||
pub fn print_out_to_token_input_types() -> Box<[TypeId]> {
|
||||
print_out_to_token().input_types()
|
||||
}
|
||||
pub fn print_out_to_token_return_type() -> &'static str {
|
||||
print_out_to_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1185,7 +1245,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut FLOAT"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
Some(&["x: &mut FLOAT", "()"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
increment_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1210,6 +1270,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<FLOAT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn increment_token_callable() -> CallableFunction {
|
||||
increment_token().into()
|
||||
@@ -1220,6 +1283,9 @@ mod generate_tests {
|
||||
pub fn increment_token_input_types() -> Box<[TypeId]> {
|
||||
increment_token().input_types()
|
||||
}
|
||||
pub fn increment_token_return_type() -> &'static str {
|
||||
increment_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1257,7 +1323,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut FLOAT"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
Some(&["x: &mut FLOAT", "()"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
increment_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1282,6 +1348,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<FLOAT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn increment_token_callable() -> CallableFunction {
|
||||
increment_token().into()
|
||||
@@ -1292,6 +1361,9 @@ mod generate_tests {
|
||||
pub fn increment_token_input_types() -> Box<[TypeId]> {
|
||||
increment_token().input_types()
|
||||
}
|
||||
pub fn increment_token_return_type() -> &'static str {
|
||||
increment_token().return_type()
|
||||
}
|
||||
}
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
@@ -1350,7 +1422,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut FLOAT"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
Some(&["x: &mut FLOAT", "()"]), &[core::any::TypeId::of::<FLOAT>()],
|
||||
increment_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1375,6 +1447,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<FLOAT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn increment_token_callable() -> CallableFunction {
|
||||
increment_token().into()
|
||||
@@ -1385,6 +1460,9 @@ mod generate_tests {
|
||||
pub fn increment_token_input_types() -> Box<[TypeId]> {
|
||||
increment_token().input_types()
|
||||
}
|
||||
pub fn increment_token_return_type() -> &'static str {
|
||||
increment_token().return_type()
|
||||
}
|
||||
}
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
@@ -1441,7 +1519,8 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("get$square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64"]), &[core::any::TypeId::of::<u64>()],
|
||||
m.set_fn("get$square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "u64"]),
|
||||
&[core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1466,6 +1545,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"u64"
|
||||
}
|
||||
}
|
||||
pub fn int_foo_token_callable() -> CallableFunction {
|
||||
int_foo_token().into()
|
||||
@@ -1476,6 +1558,9 @@ mod generate_tests {
|
||||
pub fn int_foo_token_input_types() -> Box<[TypeId]> {
|
||||
int_foo_token().input_types()
|
||||
}
|
||||
pub fn int_foo_token_return_type() -> &'static str {
|
||||
int_foo_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1510,9 +1595,9 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64"]), &[core::any::TypeId::of::<u64>()],
|
||||
m.set_fn("square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "u64"]), &[core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
m.set_fn("get$square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64"]), &[core::any::TypeId::of::<u64>()],
|
||||
m.set_fn("get$square", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "u64"]), &[core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
}
|
||||
@@ -1537,6 +1622,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"u64"
|
||||
}
|
||||
}
|
||||
pub fn int_foo_token_callable() -> CallableFunction {
|
||||
int_foo_token().into()
|
||||
@@ -1547,6 +1635,9 @@ mod generate_tests {
|
||||
pub fn int_foo_token_input_types() -> Box<[TypeId]> {
|
||||
int_foo_token().input_types()
|
||||
}
|
||||
pub fn int_foo_token_return_type() -> &'static str {
|
||||
int_foo_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1581,7 +1672,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64"]),
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
@@ -1608,6 +1699,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<u64>(), TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn int_foo_token_callable() -> CallableFunction {
|
||||
int_foo_token().into()
|
||||
@@ -1618,6 +1712,9 @@ mod generate_tests {
|
||||
pub fn int_foo_token_input_types() -> Box<[TypeId]> {
|
||||
int_foo_token().input_types()
|
||||
}
|
||||
pub fn int_foo_token_return_type() -> &'static str {
|
||||
int_foo_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1652,10 +1749,10 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("set_sq", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64"]),
|
||||
m.set_fn("set_sq", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64"]),
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
@@ -1682,6 +1779,9 @@ mod generate_tests {
|
||||
fn input_types(&self) -> Box<[TypeId]> {
|
||||
new_vec![TypeId::of::<u64>(), TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn int_foo_token_callable() -> CallableFunction {
|
||||
int_foo_token().into()
|
||||
@@ -1692,6 +1792,9 @@ mod generate_tests {
|
||||
pub fn int_foo_token_input_types() -> Box<[TypeId]> {
|
||||
int_foo_token().input_types()
|
||||
}
|
||||
pub fn int_foo_token_return_type() -> &'static str {
|
||||
int_foo_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1727,7 +1830,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("index$get$", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "FLOAT"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
get_by_index_token().into());
|
||||
@@ -1756,6 +1859,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<MyCollection>(),
|
||||
TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"FLOAT"
|
||||
}
|
||||
}
|
||||
pub fn get_by_index_token_callable() -> CallableFunction {
|
||||
get_by_index_token().into()
|
||||
@@ -1766,6 +1872,9 @@ mod generate_tests {
|
||||
pub fn get_by_index_token_input_types() -> Box<[TypeId]> {
|
||||
get_by_index_token().input_types()
|
||||
}
|
||||
pub fn get_by_index_token_return_type() -> &'static str {
|
||||
get_by_index_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1801,12 +1910,12 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("get", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "FLOAT"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
get_by_index_token().into());
|
||||
m.set_fn("index$get$", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "FLOAT"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
get_by_index_token().into());
|
||||
@@ -1835,6 +1944,9 @@ mod generate_tests {
|
||||
new_vec![TypeId::of::<MyCollection>(),
|
||||
TypeId::of::<u64>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"FLOAT"
|
||||
}
|
||||
}
|
||||
pub fn get_by_index_token_callable() -> CallableFunction {
|
||||
get_by_index_token().into()
|
||||
@@ -1845,6 +1957,9 @@ mod generate_tests {
|
||||
pub fn get_by_index_token_input_types() -> Box<[TypeId]> {
|
||||
get_by_index_token().input_types()
|
||||
}
|
||||
pub fn get_by_index_token_return_type() -> &'static str {
|
||||
get_by_index_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1880,7 +1995,7 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("index$set$", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>(),
|
||||
core::any::TypeId::of::<FLOAT>()],
|
||||
@@ -1912,6 +2027,9 @@ mod generate_tests {
|
||||
TypeId::of::<u64>(),
|
||||
TypeId::of::<FLOAT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn set_by_index_token_callable() -> CallableFunction {
|
||||
set_by_index_token().into()
|
||||
@@ -1922,6 +2040,9 @@ mod generate_tests {
|
||||
pub fn set_by_index_token_input_types() -> Box<[TypeId]> {
|
||||
set_by_index_token().input_types()
|
||||
}
|
||||
pub fn set_by_index_token_return_type() -> &'static str {
|
||||
set_by_index_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1957,13 +2078,13 @@ mod generate_tests {
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("set", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>(),
|
||||
core::any::TypeId::of::<FLOAT>()],
|
||||
set_by_index_token().into());
|
||||
m.set_fn("index$set$", FnNamespace::Internal, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT"]),
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>(),
|
||||
core::any::TypeId::of::<FLOAT>()],
|
||||
@@ -1995,6 +2116,9 @@ mod generate_tests {
|
||||
TypeId::of::<u64>(),
|
||||
TypeId::of::<FLOAT>()].into_boxed_slice()
|
||||
}
|
||||
fn return_type(&self) -> &'static str {
|
||||
"()"
|
||||
}
|
||||
}
|
||||
pub fn set_by_index_token_callable() -> CallableFunction {
|
||||
set_by_index_token().into()
|
||||
@@ -2005,6 +2129,9 @@ mod generate_tests {
|
||||
pub fn set_by_index_token_input_types() -> Box<[TypeId]> {
|
||||
set_by_index_token().input_types()
|
||||
}
|
||||
pub fn set_by_index_token_return_type() -> &'static str {
|
||||
set_by_index_token().return_type()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user