Merge pull request #572 from schungx/master

Handle documentation with plugins.
This commit is contained in:
Stephen Chung 2022-06-05 19:59:50 +08:00 committed by GitHub
commit 9e343ea8f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 346 additions and 91 deletions

View File

@ -11,6 +11,7 @@ Bug fixes
* Missing `to_int` from `Decimal` is added. * Missing `to_int` from `Decimal` is added.
* Parsing of index expressions is relaxed and many cases no longer result in an index-type error to allow for custom indexers. * Parsing of index expressions is relaxed and many cases no longer result in an index-type error to allow for custom indexers.
* Merging or combining a self-contained `AST` into another `AST` now works properly. * Merging or combining a self-contained `AST` into another `AST` now works properly.
* Plugin modules/functions no longer generate errors under `#![deny(missing_docs)]`.
Deprecated API's Deprecated API's
---------------- ----------------
@ -24,6 +25,7 @@ Enhancements
* `Engine::def_tag`, `Engine::def_tag_mut` and `Engine::set_tag` are added to manage a default value for the custom evaluation state, accessible via `EvalState::tag()` (which is the same as `NativeCallContext::tag()`). * `Engine::def_tag`, `Engine::def_tag_mut` and `Engine::set_tag` are added to manage a default value for the custom evaluation state, accessible via `EvalState::tag()` (which is the same as `NativeCallContext::tag()`).
* Originally, the debugger's custom state uses the same state as `EvalState::tag()` (which is the same as `NativeCallContext::tag()`). It is now split into its own variable accessible under `Debugger::state()`. * Originally, the debugger's custom state uses the same state as `EvalState::tag()` (which is the same as `NativeCallContext::tag()`). It is now split into its own variable accessible under `Debugger::state()`.
* Non-borrowed string keys can now be deserialized for object maps via `serde`. * Non-borrowed string keys can now be deserialized for object maps via `serde`.
* `Scope::get` is added to get a reference to a variable's value.
Version 1.7.0 Version 1.7.0

View File

@ -22,7 +22,7 @@ ahash = { version = "0.7", default-features = false }
num-traits = { version = "0.2", default-features = false } num-traits = { version = "0.2", default-features = false }
bitflags = { version = "1", default-features = false } bitflags = { version = "1", default-features = false }
smartstring = { version = "1", default-features = false } smartstring = { version = "1", default-features = false }
rhai_codegen = { version = "1.4", path = "codegen", default-features = false } rhai_codegen = { version = "1.4.1", path = "codegen", default-features = false }
no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true } no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
libm = { version = "0.2", default-features = false, optional = true } libm = { version = "0.2", default-features = false, optional = true }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rhai_codegen" name = "rhai_codegen"
version = "1.4.0" version = "1.4.1"
edition = "2018" edition = "2018"
authors = ["jhwgh1968", "Stephen Chung"] authors = ["jhwgh1968", "Stephen Chung"]
description = "Procedural macros support package for Rhai, a scripting language and engine for Rust" description = "Procedural macros support package for Rhai, a scripting language and engine for Rust"

View File

@ -620,6 +620,7 @@ impl ExportedFn {
#[automatically_derived] #[automatically_derived]
#vis mod #name { #vis mod #name {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#impl_block #impl_block
#dyn_result_fn_block #dyn_result_fn_block
@ -655,6 +656,9 @@ impl ExportedFn {
.resolved_at(Span::call_site()); .resolved_at(Span::call_site());
if self.params.return_raw.is_some() { if self.params.return_raw.is_some() {
quote_spanned! { return_span => quote_spanned! { return_span =>
#[allow(unused)]
#[doc(hidden)]
#[inline(always)]
pub #dynamic_signature { pub #dynamic_signature {
#name(#(#arguments),*).map(Dynamic::from) #name(#(#arguments),*).map(Dynamic::from)
} }
@ -662,6 +666,7 @@ impl ExportedFn {
} else { } else {
quote_spanned! { return_span => quote_spanned! { return_span =>
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] #[inline(always)]
pub #dynamic_signature { pub #dynamic_signature {
Ok(Dynamic::from(#name(#(#arguments),*))) Ok(Dynamic::from(#name(#(#arguments),*)))
@ -864,6 +869,7 @@ impl ExportedFn {
quote! { quote! {
#(#cfg_attrs)* #(#cfg_attrs)*
#[doc(hidden)]
impl #type_name { impl #type_name {
#param_names #param_names
#[inline(always)] pub fn param_types() -> [TypeId; #arg_count] { [#(#input_type_exprs),*] } #[inline(always)] pub fn param_types() -> [TypeId; #arg_count] { [#(#input_type_exprs),*] }

View File

@ -239,6 +239,7 @@ pub fn generate_body(
gen_fn_tokens.push(quote! { gen_fn_tokens.push(quote! {
#(#cfg_attrs)* #(#cfg_attrs)*
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct #fn_token_name(); pub struct #fn_token_name();
}); });
@ -250,6 +251,7 @@ pub fn generate_body(
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -257,6 +259,7 @@ pub fn generate_body(
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
#(#set_fn_statements)* #(#set_fn_statements)*
#(#set_const_statements)* #(#set_const_statements)*

View File

@ -275,7 +275,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_do_nothing { pub mod rhai_fn_do_nothing {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["()"]; pub const PARAM_NAMES: &'static [&'static str] = &["()"];
#[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] } #[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] }
@ -288,6 +290,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn() -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn() -> RhaiResult {
Ok(Dynamic::from(do_nothing())) Ok(Dynamic::from(do_nothing()))
} }
@ -308,7 +311,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_do_something { pub mod rhai_fn_do_something {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] }
@ -323,6 +328,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn(x: usize) -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn(x: usize) -> RhaiResult {
Ok(Dynamic::from(do_something(x))) Ok(Dynamic::from(do_something(x)))
} }
@ -343,7 +349,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_do_something { pub mod rhai_fn_do_something {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] }
@ -358,6 +366,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn(context: NativeCallContext, x: usize) -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn(context: NativeCallContext, x: usize) -> RhaiResult {
Ok(Dynamic::from(do_something(context, x))) Ok(Dynamic::from(do_something(context, x)))
} }
@ -381,7 +390,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_return_dynamic { pub mod rhai_fn_return_dynamic {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["rhai::Dynamic"]; pub const PARAM_NAMES: &'static [&'static str] = &["rhai::Dynamic"];
#[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] } #[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] }
@ -395,6 +406,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn() -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn() -> RhaiResult {
Ok(Dynamic::from(return_dynamic())) Ok(Dynamic::from(return_dynamic()))
} }
@ -412,6 +424,7 @@ mod generate_tests {
}; };
let expected_tokens = quote! { let expected_tokens = quote! {
#[doc(hidden)]
impl TestStruct { impl TestStruct {
pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<usize>()] }
@ -441,7 +454,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_add_together { pub mod rhai_fn_add_together {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "y: usize", "usize"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: usize", "y: usize", "usize"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<usize>(), TypeId::of::<usize>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<usize>(), TypeId::of::<usize>()] }
@ -457,6 +472,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn(x: usize, y: usize) -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn(x: usize, y: usize) -> RhaiResult {
Ok(Dynamic::from(add_together(x, y))) Ok(Dynamic::from(add_together(x, y)))
} }
@ -477,7 +493,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_increment { pub mod rhai_fn_increment {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut usize", "y: usize", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut usize", "y: usize", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<usize>(), TypeId::of::<usize>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<usize>(), TypeId::of::<usize>()] }
@ -496,6 +514,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { true } #[inline(always)] fn is_method_call(&self) -> bool { true }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn(x: &mut usize, y: usize) -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn(x: &mut usize, y: usize) -> RhaiResult {
Ok(Dynamic::from(increment(x, y))) Ok(Dynamic::from(increment(x, y)))
} }
@ -517,7 +536,9 @@ mod generate_tests {
#[automatically_derived] #[automatically_derived]
pub mod rhai_fn_special_print { pub mod rhai_fn_special_print {
use super::*; use super::*;
#[doc(hidden)]
pub struct Token(); pub struct Token();
#[doc(hidden)]
impl Token { impl Token {
pub const PARAM_NAMES: &'static [&'static str] = &["message: &str", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["message: &str", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] }
@ -532,6 +553,7 @@ mod generate_tests {
#[inline(always)] fn is_method_call(&self) -> bool { false } #[inline(always)] fn is_method_call(&self) -> bool { false }
} }
#[allow(unused)] #[allow(unused)]
#[doc(hidden)]
#[inline(always)] pub fn dynamic_result_fn(message: &str) -> RhaiResult { #[inline(always)] pub fn dynamic_result_fn(message: &str) -> RhaiResult {
Ok(Dynamic::from(special_print(message))) Ok(Dynamic::from(special_print(message)))
} }

View File

@ -323,6 +323,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -330,6 +331,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten {} else {} if flatten {} else {}
} }
@ -358,6 +360,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -365,6 +368,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public,
Some(get_mystic_number_token::PARAM_NAMES), &[], Some(get_mystic_number_token::PARAM_NAMES), &[],
@ -372,7 +376,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_mystic_number_token(); pub struct get_mystic_number_token();
#[doc(hidden)]
impl get_mystic_number_token { impl get_mystic_number_token {
pub const PARAM_NAMES: &'static [&'static str] = &["INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] } #[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] }
@ -426,6 +432,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -433,6 +440,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn_with_comments("get_mystic_number", FnNamespace::Internal, FnAccess::Public, m.set_fn_with_comments("get_mystic_number", FnNamespace::Internal, FnAccess::Public,
Some(get_mystic_number_token::PARAM_NAMES), &[], &[ Some(get_mystic_number_token::PARAM_NAMES), &[], &[
@ -445,7 +453,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_mystic_number_token(); pub struct get_mystic_number_token();
#[doc(hidden)]
impl get_mystic_number_token { impl get_mystic_number_token {
pub const PARAM_NAMES: &'static [&'static str] = &["INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] } #[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] }
@ -484,6 +494,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -491,6 +502,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("add_one_to", FnNamespace::Global, FnAccess::Public, m.set_fn("add_one_to", FnNamespace::Global, FnAccess::Public,
Some(add_one_to_token::PARAM_NAMES), &[TypeId::of::<INT>()], Some(add_one_to_token::PARAM_NAMES), &[TypeId::of::<INT>()],
@ -498,7 +510,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_one_to_token(); pub struct add_one_to_token();
#[doc(hidden)]
impl add_one_to_token { impl add_one_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] }
@ -537,6 +551,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -544,6 +559,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("add_one_to", FnNamespace::Internal, FnAccess::Public, Some(add_one_to_token::PARAM_NAMES), m.set_fn("add_one_to", FnNamespace::Internal, FnAccess::Public, Some(add_one_to_token::PARAM_NAMES),
&[TypeId::of::<INT>()], &[TypeId::of::<INT>()],
@ -551,7 +567,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_one_to_token(); pub struct add_one_to_token();
#[doc(hidden)]
impl add_one_to_token { impl add_one_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] }
@ -601,6 +619,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -608,6 +627,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(add_one_to_token::PARAM_NAMES), m.set_fn("add_n", FnNamespace::Internal, FnAccess::Public, Some(add_one_to_token::PARAM_NAMES),
&[TypeId::of::<INT>()], &[TypeId::of::<INT>()],
@ -618,7 +638,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_one_to_token(); pub struct add_one_to_token();
#[doc(hidden)]
impl add_one_to_token { impl add_one_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<INT>()] }
@ -634,7 +656,9 @@ mod generate_tests {
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_n_to_token(); pub struct add_n_to_token();
#[doc(hidden)]
impl add_n_to_token { impl add_n_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] }
@ -674,6 +698,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -681,6 +706,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(add_together_token::PARAM_NAMES), m.set_fn("add_together", FnNamespace::Internal, FnAccess::Public, Some(add_together_token::PARAM_NAMES),
&[TypeId::of::<INT>(), TypeId::of::<INT>()], &[TypeId::of::<INT>(), TypeId::of::<INT>()],
@ -688,7 +714,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_together_token(); pub struct add_together_token();
#[doc(hidden)]
impl add_together_token { impl add_together_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] }
@ -729,6 +757,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -736,6 +765,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("add", FnNamespace::Internal, FnAccess::Public, Some(add_together_token::PARAM_NAMES), m.set_fn("add", FnNamespace::Internal, FnAccess::Public, Some(add_together_token::PARAM_NAMES),
&[TypeId::of::<INT>(), TypeId::of::<INT>()], &[TypeId::of::<INT>(), TypeId::of::<INT>()],
@ -749,7 +779,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct add_together_token(); pub struct add_together_token();
#[doc(hidden)]
impl add_together_token { impl add_together_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: INT", "y: INT", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<INT>(), TypeId::of::<INT>()] }
@ -803,6 +835,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -810,6 +843,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public,
Some(get_mystic_number_token::PARAM_NAMES), &[TypeId::of::<Hello>()], Some(get_mystic_number_token::PARAM_NAMES), &[TypeId::of::<Hello>()],
@ -820,7 +854,9 @@ mod generate_tests {
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_mystic_number_token(); pub struct get_mystic_number_token();
#[doc(hidden)]
impl get_mystic_number_token { impl get_mystic_number_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut Hello", "INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut Hello", "INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<Hello>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<Hello>()] }
@ -858,6 +894,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -865,6 +902,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER); m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER);
if flatten {} else {} if flatten {} else {}
@ -892,6 +930,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -899,6 +938,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER); m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER);
if flatten {} else {} if flatten {} else {}
@ -928,6 +968,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -935,6 +976,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten {} else {} if flatten {} else {}
} }
@ -964,6 +1006,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -971,6 +1014,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten {} else {} if flatten {} else {}
} }
@ -1006,6 +1050,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1013,6 +1058,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public, m.set_fn("get_mystic_number", FnNamespace::Internal, FnAccess::Public,
Some(get_mystic_number_token::PARAM_NAMES), &[], Some(get_mystic_number_token::PARAM_NAMES), &[],
@ -1020,7 +1066,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_mystic_number_token(); pub struct get_mystic_number_token();
#[doc(hidden)]
impl get_mystic_number_token { impl get_mystic_number_token {
pub const PARAM_NAMES: &'static [&'static str] = &["INT"]; pub const PARAM_NAMES: &'static [&'static str] = &["INT"];
#[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] } #[inline(always)] pub fn param_types() -> [TypeId; 0usize] { [] }
@ -1054,6 +1102,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1061,6 +1110,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten {} else {} if flatten {} else {}
} }
@ -1089,6 +1139,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1096,6 +1147,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public, Some(print_out_to_token::PARAM_NAMES), m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public, Some(print_out_to_token::PARAM_NAMES),
&[TypeId::of::<ImmutableString>()], &[TypeId::of::<ImmutableString>()],
@ -1103,7 +1155,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct print_out_to_token(); pub struct print_out_to_token();
#[doc(hidden)]
impl print_out_to_token { impl print_out_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &str", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &str", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] }
@ -1142,6 +1196,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1149,6 +1204,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public, Some(print_out_to_token::PARAM_NAMES), m.set_fn("print_out_to", FnNamespace::Internal, FnAccess::Public, Some(print_out_to_token::PARAM_NAMES),
&[TypeId::of::<ImmutableString>()], &[TypeId::of::<ImmutableString>()],
@ -1156,7 +1212,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct print_out_to_token(); pub struct print_out_to_token();
#[doc(hidden)]
impl print_out_to_token { impl print_out_to_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: String", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: String", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<ImmutableString>()] }
@ -1196,6 +1254,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1203,6 +1262,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("foo", FnNamespace::Internal, FnAccess::Public, Some(foo_token::PARAM_NAMES), m.set_fn("foo", FnNamespace::Internal, FnAccess::Public, Some(foo_token::PARAM_NAMES),
&[TypeId::of::<FLOAT>(), TypeId::of::<INT>()], &[TypeId::of::<FLOAT>(), TypeId::of::<INT>()],
@ -1210,7 +1270,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct foo_token(); pub struct foo_token();
#[doc(hidden)]
impl foo_token { impl foo_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "y: INT", "FLOAT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "y: INT", "FLOAT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<FLOAT>(), TypeId::of::<INT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<FLOAT>(), TypeId::of::<INT>()] }
@ -1250,6 +1312,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1257,6 +1320,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES), m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES),
&[TypeId::of::<FLOAT>()], &[TypeId::of::<FLOAT>()],
@ -1264,7 +1328,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct increment_token(); pub struct increment_token();
#[doc(hidden)]
impl increment_token { impl increment_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] }
@ -1309,6 +1375,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1316,6 +1383,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES), m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES),
&[TypeId::of::<FLOAT>()], &[TypeId::of::<FLOAT>()],
@ -1323,7 +1391,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct increment_token(); pub struct increment_token();
#[doc(hidden)]
impl increment_token { impl increment_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] }
@ -1344,6 +1414,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1351,6 +1422,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten { if flatten {
{ self::it_is::rhai_generate_into_module(m, flatten); } { self::it_is::rhai_generate_into_module(m, flatten); }
@ -1389,6 +1461,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1396,6 +1469,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES), m.set_fn("increment", FnNamespace::Internal, FnAccess::Public, Some(increment_token::PARAM_NAMES),
&[TypeId::of::<FLOAT>()], &[TypeId::of::<FLOAT>()],
@ -1403,7 +1477,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct increment_token(); pub struct increment_token();
#[doc(hidden)]
impl increment_token { impl increment_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut FLOAT", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<FLOAT>()] }
@ -1424,6 +1500,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1431,6 +1508,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten { if flatten {
{ {
@ -1470,6 +1548,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1477,6 +1556,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("get$square", FnNamespace::Global, FnAccess::Public, Some(int_foo_token::PARAM_NAMES), m.set_fn("get$square", FnNamespace::Global, FnAccess::Public, Some(int_foo_token::PARAM_NAMES),
&[TypeId::of::<u64>()], &[TypeId::of::<u64>()],
@ -1484,7 +1564,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct int_foo_token(); pub struct int_foo_token();
#[doc(hidden)]
impl int_foo_token { impl int_foo_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "u64"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "u64"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<u64>()] }
@ -1527,6 +1609,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1534,6 +1617,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("square", FnNamespace::Internal, FnAccess::Public, Some(int_foo_token::PARAM_NAMES), m.set_fn("square", FnNamespace::Internal, FnAccess::Public, Some(int_foo_token::PARAM_NAMES),
&[TypeId::of::<u64>()], &[TypeId::of::<u64>()],
@ -1544,7 +1628,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct int_foo_token(); pub struct int_foo_token();
#[doc(hidden)]
impl int_foo_token { impl int_foo_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "u64"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "u64"];
#[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 1usize] { [TypeId::of::<u64>()] }
@ -1587,6 +1673,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1594,6 +1681,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("set$squared", FnNamespace::Global, FnAccess::Public, Some(int_foo_token::PARAM_NAMES), m.set_fn("set$squared", FnNamespace::Global, FnAccess::Public, Some(int_foo_token::PARAM_NAMES),
&[TypeId::of::<u64>(), TypeId::of::<u64>()], &[TypeId::of::<u64>(), TypeId::of::<u64>()],
@ -1601,7 +1689,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct int_foo_token(); pub struct int_foo_token();
#[doc(hidden)]
impl int_foo_token { impl int_foo_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "y: u64", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "y: u64", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<u64>(), TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<u64>(), TypeId::of::<u64>()] }
@ -1645,6 +1735,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1652,6 +1743,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("set_sq", FnNamespace::Internal, FnAccess::Public, Some(int_foo_token::PARAM_NAMES), m.set_fn("set_sq", FnNamespace::Internal, FnAccess::Public, Some(int_foo_token::PARAM_NAMES),
&[TypeId::of::<u64>(), TypeId::of::<u64>()], &[TypeId::of::<u64>(), TypeId::of::<u64>()],
@ -1662,7 +1754,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct int_foo_token(); pub struct int_foo_token();
#[doc(hidden)]
impl int_foo_token { impl int_foo_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "y: u64", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut u64", "y: u64", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<u64>(), TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<u64>(), TypeId::of::<u64>()] }
@ -1706,6 +1800,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1713,6 +1808,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES), m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES),
&[TypeId::of::<MyCollection>(), TypeId::of::<u64>()], &[TypeId::of::<MyCollection>(), TypeId::of::<u64>()],
@ -1720,7 +1816,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_by_index_token(); pub struct get_by_index_token();
#[doc(hidden)]
impl get_by_index_token { impl get_by_index_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] }
@ -1768,6 +1866,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1775,6 +1874,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
#[cfg(hello)] #[cfg(hello)]
m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES), m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES),
@ -1784,8 +1884,10 @@ mod generate_tests {
} }
#[cfg(hello)] #[cfg(hello)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_by_index_token(); pub struct get_by_index_token();
#[cfg(hello)] #[cfg(hello)]
#[doc(hidden)]
impl get_by_index_token { impl get_by_index_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] }
@ -1830,6 +1932,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1837,6 +1940,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("get", FnNamespace::Internal, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES), m.set_fn("get", FnNamespace::Internal, FnAccess::Public, Some(get_by_index_token::PARAM_NAMES),
&[TypeId::of::<MyCollection>(), TypeId::of::<u64>()], &[TypeId::of::<MyCollection>(), TypeId::of::<u64>()],
@ -1847,7 +1951,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct get_by_index_token(); pub struct get_by_index_token();
#[doc(hidden)]
impl get_by_index_token { impl get_by_index_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "FLOAT"];
#[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] } #[inline(always)] pub fn param_types() -> [TypeId; 2usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>()] }
@ -1891,6 +1997,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1898,6 +2005,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("index$set$", FnNamespace::Global, FnAccess::Public, Some(set_by_index_token::PARAM_NAMES), m.set_fn("index$set$", FnNamespace::Global, FnAccess::Public, Some(set_by_index_token::PARAM_NAMES),
&[TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()], &[TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()],
@ -1905,7 +2013,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct set_by_index_token(); pub struct set_by_index_token();
#[doc(hidden)]
impl set_by_index_token { impl set_by_index_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 3usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 3usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()] }
@ -1950,6 +2060,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -1957,6 +2068,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_fn("set", FnNamespace::Internal, FnAccess::Public, Some(set_by_index_token::PARAM_NAMES), m.set_fn("set", FnNamespace::Internal, FnAccess::Public, Some(set_by_index_token::PARAM_NAMES),
&[TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()], &[TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()],
@ -1967,7 +2079,9 @@ mod generate_tests {
if flatten {} else {} if flatten {} else {}
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[doc(hidden)]
pub struct set_by_index_token(); pub struct set_by_index_token();
#[doc(hidden)]
impl set_by_index_token { impl set_by_index_token {
pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]; pub const PARAM_NAMES: &'static [&'static str] = &["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"];
#[inline(always)] pub fn param_types() -> [TypeId; 3usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()] } #[inline(always)] pub fn param_types() -> [TypeId; 3usize] { [TypeId::of::<MyCollection>(), TypeId::of::<u64>(), TypeId::of::<FLOAT>()] }
@ -2010,6 +2124,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2017,6 +2132,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER); m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER);
if flatten {} else {} if flatten {} else {}
@ -2025,6 +2141,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2032,6 +2149,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten { if flatten {
{ self::it_is::rhai_generate_into_module(m, flatten); } { self::it_is::rhai_generate_into_module(m, flatten); }
@ -2067,6 +2185,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2074,6 +2193,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER); m.set_var("MYSTIC_NUMBER", MYSTIC_NUMBER);
if flatten {} else {} if flatten {} else {}
@ -2085,6 +2205,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2092,6 +2213,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
#[cfg(hello)] #[cfg(hello)]
m.set_var("SPECIAL_CPU_NUMBER", SPECIAL_CPU_NUMBER); m.set_var("SPECIAL_CPU_NUMBER", SPECIAL_CPU_NUMBER);
@ -2101,6 +2223,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2108,6 +2231,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten { if flatten {
{ self::first_is::rhai_generate_into_module(m, flatten); } { self::first_is::rhai_generate_into_module(m, flatten); }
@ -2168,6 +2292,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2175,6 +2300,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
if flatten {} else {} if flatten {} else {}
@ -2185,6 +2311,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2192,6 +2319,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
if flatten {} else {} if flatten {} else {}
@ -2200,6 +2328,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2207,6 +2336,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
@ -2224,6 +2354,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2231,6 +2362,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
if flatten {} else {} if flatten {} else {}
@ -2239,6 +2371,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2246,6 +2379,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
@ -2265,6 +2399,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2272,6 +2407,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
if flatten {} else {} if flatten {} else {}
@ -2282,6 +2418,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2289,6 +2426,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
if flatten {} else {} if flatten {} else {}
@ -2297,6 +2435,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2304,6 +2443,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);
@ -2319,6 +2459,7 @@ mod generate_tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[doc(hidden)]
pub fn rhai_module_generate() -> Module { pub fn rhai_module_generate() -> Module {
let mut m = Module::new(); let mut m = Module::new();
rhai_generate_into_module(&mut m, false); rhai_generate_into_module(&mut m, false);
@ -2326,6 +2467,7 @@ mod generate_tests {
m m
} }
#[allow(unused_mut)] #[allow(unused_mut)]
#[doc(hidden)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
m.set_var("VALUE", VALUE); m.set_var("VALUE", VALUE);

View File

@ -27,5 +27,7 @@ pub use stmt::{
#[cfg(not(feature = "no_float"))] #[cfg(not(feature = "no_float"))]
pub use expr::FloatWrapper; pub use expr::FloatWrapper;
/// _(internals)_ Placeholder for a script-defined function.
/// Exported under the `internals` feature only.
#[cfg(feature = "no_function")] #[cfg(feature = "no_function")]
pub struct ScriptFnDef; pub type ScriptFnDef = ();

View File

@ -20,20 +20,20 @@ use std::{
/// ///
/// This type may hold a straight assignment (i.e. not an op-assignment). /// This type may hold a straight assignment (i.e. not an op-assignment).
#[derive(Clone, Copy, Eq, PartialEq, Hash)] #[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct OpAssignment<'a> { pub struct OpAssignment {
/// Hash of the op-assignment call. /// Hash of the op-assignment call.
pub hash_op_assign: u64, pub hash_op_assign: u64,
/// Hash of the underlying operator call (for fallback). /// Hash of the underlying operator call (for fallback).
pub hash_op: u64, pub hash_op: u64,
/// Op-assignment operator. /// Op-assignment operator.
pub op_assign: &'a str, pub op_assign: &'static str,
/// Underlying operator. /// Underlying operator.
pub op: &'a str, pub op: &'static str,
/// [Position] of the op-assignment operator. /// [Position] of the op-assignment operator.
pub pos: Position, pub pos: Position,
} }
impl OpAssignment<'_> { impl OpAssignment {
/// Create a new [`OpAssignment`] that is only a straight assignment. /// Create a new [`OpAssignment`] that is only a straight assignment.
#[must_use] #[must_use]
#[inline(always)] #[inline(always)]
@ -106,7 +106,7 @@ impl OpAssignment<'_> {
} }
} }
impl fmt::Debug for OpAssignment<'_> { impl fmt::Debug for OpAssignment {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_op_assignment() { if self.is_op_assignment() {
f.debug_struct("OpAssignment") f.debug_struct("OpAssignment")
@ -194,7 +194,10 @@ pub type StmtBlockContainer = StaticVec<Stmt>;
/// _(internals)_ A scoped block of statements. /// _(internals)_ A scoped block of statements.
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
#[derive(Clone, Hash, Default)] #[derive(Clone, Hash, Default)]
pub struct StmtBlock(StmtBlockContainer, Span); pub struct StmtBlock {
block: StmtBlockContainer,
span: Span,
}
impl StmtBlock { impl StmtBlock {
/// A [`StmtBlock`] that does not exist. /// A [`StmtBlock`] that does not exist.
@ -215,61 +218,67 @@ impl StmtBlock {
pub fn new_with_span(statements: impl IntoIterator<Item = Stmt>, span: Span) -> Self { pub fn new_with_span(statements: impl IntoIterator<Item = Stmt>, span: Span) -> Self {
let mut statements: smallvec::SmallVec<_> = statements.into_iter().collect(); let mut statements: smallvec::SmallVec<_> = statements.into_iter().collect();
statements.shrink_to_fit(); statements.shrink_to_fit();
Self(statements, span) Self {
block: statements,
span,
}
} }
/// Create an empty [`StmtBlock`]. /// Create an empty [`StmtBlock`].
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn empty(pos: Position) -> Self { pub const fn empty(pos: Position) -> Self {
Self(StmtBlockContainer::new_const(), Span::new(pos, pos)) Self {
block: StmtBlockContainer::new_const(),
span: Span::new(pos, pos),
}
} }
/// Is this statements block empty? /// Is this statements block empty?
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.0.is_empty() self.block.is_empty()
} }
/// Number of statements in this statements block. /// Number of statements in this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.0.len() self.block.len()
} }
/// Get the statements of this statements block. /// Get the statements of this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn statements(&self) -> &[Stmt] { pub fn statements(&self) -> &[Stmt] {
&self.0 &self.block
} }
/// Extract the statements. /// Extract the statements.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub(crate) fn take_statements(&mut self) -> StmtBlockContainer { pub(crate) fn take_statements(&mut self) -> StmtBlockContainer {
mem::take(&mut self.0) mem::take(&mut self.block)
} }
/// Get an iterator over the statements of this statements block. /// Get an iterator over the statements of this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn iter(&self) -> impl Iterator<Item = &Stmt> { pub fn iter(&self) -> impl Iterator<Item = &Stmt> {
self.0.iter() self.block.iter()
} }
/// Get the start position (location of the beginning `{`) of this statements block. /// Get the start position (location of the beginning `{`) of this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn position(&self) -> Position { pub const fn position(&self) -> Position {
(self.1).start() (self.span).start()
} }
/// Get the end position (location of the ending `}`) of this statements block. /// Get the end position (location of the ending `}`) of this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn end_position(&self) -> Position { pub const fn end_position(&self) -> Position {
(self.1).end() (self.span).end()
} }
/// Get the positions (locations of the beginning `{` and ending `}`) of this statements block. /// Get the positions (locations of the beginning `{` and ending `}`) of this statements block.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn span(&self) -> Span { pub const fn span(&self) -> Span {
self.1 self.span
} }
/// Get the positions (locations of the beginning `{` and ending `}`) of this statements block /// Get the positions (locations of the beginning `{` and ending `}`) of this statements block
/// or a default. /// or a default.
@ -277,14 +286,14 @@ impl StmtBlock {
#[must_use] #[must_use]
pub const fn span_or_else(&self, def_start_pos: Position, def_end_pos: Position) -> Span { pub const fn span_or_else(&self, def_start_pos: Position, def_end_pos: Position) -> Span {
Span::new( Span::new(
(self.1).start().or_else(def_start_pos), (self.span).start().or_else(def_start_pos),
(self.1).end().or_else(def_end_pos), (self.span).end().or_else(def_end_pos),
) )
} }
/// Set the positions of this statements block. /// Set the positions of this statements block.
#[inline(always)] #[inline(always)]
pub fn set_position(&mut self, start_pos: Position, end_pos: Position) { pub fn set_position(&mut self, start_pos: Position, end_pos: Position) {
self.1 = Span::new(start_pos, end_pos); self.span = Span::new(start_pos, end_pos);
} }
} }
@ -293,37 +302,37 @@ impl Deref for StmtBlock {
#[inline(always)] #[inline(always)]
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.0 &self.block
} }
} }
impl DerefMut for StmtBlock { impl DerefMut for StmtBlock {
#[inline(always)] #[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0 &mut self.block
} }
} }
impl AsRef<[Stmt]> for StmtBlock { impl AsRef<[Stmt]> for StmtBlock {
#[inline(always)] #[inline(always)]
fn as_ref(&self) -> &[Stmt] { fn as_ref(&self) -> &[Stmt] {
&self.0 &self.block
} }
} }
impl AsMut<[Stmt]> for StmtBlock { impl AsMut<[Stmt]> for StmtBlock {
#[inline(always)] #[inline(always)]
fn as_mut(&mut self) -> &mut [Stmt] { fn as_mut(&mut self) -> &mut [Stmt] {
&mut self.0 &mut self.block
} }
} }
impl fmt::Debug for StmtBlock { impl fmt::Debug for StmtBlock {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Block")?; f.write_str("Block")?;
fmt::Debug::fmt(&self.0, f)?; fmt::Debug::fmt(&self.block, f)?;
if !self.1.is_none() { if !self.span.is_none() {
write!(f, " @ {:?}", self.1)?; write!(f, " @ {:?}", self.span())?;
} }
Ok(()) Ok(())
} }
@ -334,10 +343,16 @@ impl From<Stmt> for StmtBlock {
fn from(stmt: Stmt) -> Self { fn from(stmt: Stmt) -> Self {
match stmt { match stmt {
Stmt::Block(block) => *block, Stmt::Block(block) => *block,
Stmt::Noop(pos) => Self(StmtBlockContainer::new_const(), Span::new(pos, pos)), Stmt::Noop(pos) => Self {
block: StmtBlockContainer::new_const(),
span: Span::new(pos, pos),
},
_ => { _ => {
let pos = stmt.position(); let pos = stmt.position();
Self(vec![stmt].into(), Span::new(pos, Position::NONE)) Self {
block: vec![stmt].into(),
span: Span::new(pos, Position::NONE),
}
} }
} }
} }
@ -352,14 +367,14 @@ impl IntoIterator for StmtBlock {
#[inline(always)] #[inline(always)]
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.0.into_iter() self.block.into_iter()
} }
} }
impl Extend<Stmt> for StmtBlock { impl Extend<Stmt> for StmtBlock {
#[inline(always)] #[inline(always)]
fn extend<T: IntoIterator<Item = Stmt>>(&mut self, iter: T) { fn extend<T: IntoIterator<Item = Stmt>>(&mut self, iter: T) {
self.0.extend(iter) self.block.extend(iter)
} }
} }
@ -401,7 +416,7 @@ pub enum Stmt {
/// * [`CONSTANT`][ASTFlags::CONSTANT] = `const` /// * [`CONSTANT`][ASTFlags::CONSTANT] = `const`
Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlags, Position), Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlags, Position),
/// expr op`=` expr /// expr op`=` expr
Assignment(Box<(OpAssignment<'static>, BinaryExpr)>), Assignment(Box<(OpAssignment, BinaryExpr)>),
/// func `(` expr `,` ... `)` /// func `(` expr `,` ... `)`
/// ///
/// Note - this is a duplicate of [`Expr::FnCall`] to cover the very common pattern of a single /// Note - this is a duplicate of [`Expr::FnCall`] to cover the very common pattern of a single

View File

@ -2,9 +2,9 @@
use crate::func::CallableFunction; use crate::func::CallableFunction;
use crate::{Identifier, StaticVec}; use crate::{Identifier, StaticVec};
use std::collections::BTreeMap;
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
use std::{collections::BTreeMap, marker::PhantomData};
/// _(internals)_ An entry in a function resolution cache. /// _(internals)_ An entry in a function resolution cache.
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
@ -29,40 +29,48 @@ pub type FnResolutionCache = BTreeMap<u64, Option<FnResolutionCacheEntry>>;
/// The following caches are contained inside this type: /// The following caches are contained inside this type:
/// * A stack of [function resolution caches][FnResolutionCache] /// * A stack of [function resolution caches][FnResolutionCache]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Caches(StaticVec<FnResolutionCache>); pub struct Caches<'a> {
/// Stack of [function resolution caches][FnResolutionCache].
fn_resolution: StaticVec<FnResolutionCache>,
/// Take care of the lifetime parameter.
dummy: PhantomData<&'a ()>,
}
impl Caches { impl Caches<'_> {
/// Create an empty [`Caches`]. /// Create an empty [`Caches`].
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn new() -> Self { pub const fn new() -> Self {
Self(StaticVec::new_const()) Self {
fn_resolution: StaticVec::new_const(),
dummy: PhantomData,
}
} }
/// Get the number of function resolution cache(s) in the stack. /// Get the number of function resolution cache(s) in the stack.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn fn_resolution_caches_len(&self) -> usize { pub fn fn_resolution_caches_len(&self) -> usize {
self.0.len() self.fn_resolution.len()
} }
/// Get a mutable reference to the current function resolution cache. /// Get a mutable reference to the current function resolution cache.
#[inline] #[inline]
#[must_use] #[must_use]
pub fn fn_resolution_cache_mut(&mut self) -> &mut FnResolutionCache { pub fn fn_resolution_cache_mut(&mut self) -> &mut FnResolutionCache {
if self.0.is_empty() { if self.fn_resolution.is_empty() {
// Push a new function resolution cache if the stack is empty // Push a new function resolution cache if the stack is empty
self.push_fn_resolution_cache(); self.push_fn_resolution_cache();
} }
self.0.last_mut().unwrap() self.fn_resolution.last_mut().unwrap()
} }
/// Push an empty function resolution cache onto the stack and make it current. /// Push an empty function resolution cache onto the stack and make it current.
#[allow(dead_code)] #[allow(dead_code)]
#[inline(always)] #[inline(always)]
pub fn push_fn_resolution_cache(&mut self) { pub fn push_fn_resolution_cache(&mut self) {
self.0.push(BTreeMap::new()); self.fn_resolution.push(BTreeMap::new());
} }
/// Rewind the function resolution caches stack to a particular size. /// Rewind the function resolution caches stack to a particular size.
#[inline(always)] #[inline(always)]
pub fn rewind_fn_resolution_caches(&mut self, len: usize) { pub fn rewind_fn_resolution_caches(&mut self, len: usize) {
self.0.truncate(len); self.fn_resolution.truncate(len);
} }
} }

View File

@ -34,15 +34,15 @@ pub type OnDebuggerCallback = dyn Fn(EvalContext, DebuggerEvent, ASTNode, Option
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[non_exhaustive] #[non_exhaustive]
pub enum DebuggerCommand { pub enum DebuggerCommand {
// Continue normal execution. /// Continue normal execution.
Continue, Continue,
// Step into the next expression, diving into functions. /// Step into the next expression, diving into functions.
StepInto, StepInto,
// Run to the next expression or statement, stepping over functions. /// Run to the next expression or statement, stepping over functions.
StepOver, StepOver,
// Run to the next statement, skipping over functions. /// Run to the next statement, skipping over functions.
Next, Next,
// Run to the end of the current function call. /// Run to the end of the current function call.
FunctionExit, FunctionExit,
} }
@ -78,17 +78,17 @@ impl DebuggerStatus {
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[non_exhaustive] #[non_exhaustive]
pub enum DebuggerEvent<'a> { pub enum DebuggerEvent<'a> {
// Script evaluation starts. /// Script evaluation starts.
Start, Start,
// Break on next step. /// Break on next step.
Step, Step,
// Break on break-point. /// Break on break-point.
BreakPoint(usize), BreakPoint(usize),
// Return from a function with a value. /// Return from a function with a value.
FunctionExitWithValue(&'a Dynamic), FunctionExitWithValue(&'a Dynamic),
// Return from a function with a value. /// Return from a function with a value.
FunctionExitWithError(&'a EvalAltResult), FunctionExitWithError(&'a EvalAltResult),
// Script evaluation ends. /// Script evaluation ends.
End, End,
} }
@ -103,23 +103,39 @@ pub enum BreakPoint {
/// Source is empty if not available. /// Source is empty if not available.
#[cfg(not(feature = "no_position"))] #[cfg(not(feature = "no_position"))]
AtPosition { AtPosition {
/// Source (empty if not available) of the break-point.
source: Identifier, source: Identifier,
/// [Position] of the break-point.
pos: Position, pos: Position,
/// Is the break-point enabled?
enabled: bool, enabled: bool,
}, },
/// Break at a particular function call. /// Break at a particular function call.
AtFunctionName { name: Identifier, enabled: bool }, AtFunctionName {
/// Function name.
name: Identifier,
/// Is the break-point enabled?
enabled: bool,
},
/// Break at a particular function call with a particular number of arguments. /// Break at a particular function call with a particular number of arguments.
AtFunctionCall { AtFunctionCall {
/// Function name.
name: Identifier, name: Identifier,
/// Number of arguments.
args: usize, args: usize,
/// Is the break-point enabled?
enabled: bool, enabled: bool,
}, },
/// Break at a particular property . /// Break at a particular property .
/// ///
/// Not available under `no_object`. /// Not available under `no_object`.
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
AtProperty { name: Identifier, enabled: bool }, AtProperty {
/// Property name.
name: Identifier,
/// Is the break-point enabled?
enabled: bool,
},
} }
impl fmt::Display for BreakPoint { impl fmt::Display for BreakPoint {

View File

@ -7,7 +7,7 @@ use std::prelude::v1::*;
/// Context of a script evaluation process. /// Context of a script evaluation process.
#[derive(Debug)] #[derive(Debug)]
pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> { pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> {
/// The current [`Engine`]. /// The current [`Engine`].
engine: &'a Engine, engine: &'a Engine,
/// The current [`Scope`]. /// The current [`Scope`].
@ -15,7 +15,7 @@ pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
/// The current [`GlobalRuntimeState`]. /// The current [`GlobalRuntimeState`].
global: &'g mut GlobalRuntimeState<'pg>, global: &'g mut GlobalRuntimeState<'pg>,
/// The current [caches][Caches], if available. /// The current [caches][Caches], if available.
caches: Option<&'c mut Caches>, caches: Option<&'c mut Caches<'pc>>,
/// The current stack of imported [modules][Module]. /// The current stack of imported [modules][Module].
lib: &'a [&'a Module], lib: &'a [&'a Module],
/// The current bound `this` pointer, if any. /// The current bound `this` pointer, if any.
@ -24,7 +24,7 @@ pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
level: usize, level: usize,
} }
impl<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> { impl<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> {
/// Create a new [`EvalContext`]. /// Create a new [`EvalContext`].
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
@ -32,7 +32,7 @@ impl<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't
engine: &'a Engine, engine: &'a Engine,
scope: &'s mut Scope<'ps>, scope: &'s mut Scope<'ps>,
global: &'g mut GlobalRuntimeState<'pg>, global: &'g mut GlobalRuntimeState<'pg>,
caches: Option<&'c mut Caches>, caches: Option<&'c mut Caches<'pc>>,
lib: &'a [&'a Module], lib: &'a [&'a Module],
this_ptr: &'t mut Option<&'pt mut Dynamic>, this_ptr: &'t mut Option<&'pt mut Dynamic>,
level: usize, level: usize,

View File

@ -13,6 +13,7 @@ use std::prelude::v1::*;
/// ///
/// Not available under `no_function`. /// Not available under `no_function`.
pub trait Func<ARGS, RET> { pub trait Func<ARGS, RET> {
/// The closure's output type.
type Output; type Output;
/// Create a Rust closure from an [`AST`]. /// Create a Rust closure from an [`AST`].

View File

@ -10,6 +10,7 @@ pub use crate::{
use std::prelude::v1::*; use std::prelude::v1::*;
pub use std::{any::TypeId, mem}; pub use std::{any::TypeId, mem};
/// Result of a Rhai function.
pub type RhaiResult = crate::RhaiResult; pub type RhaiResult = crate::RhaiResult;
#[cfg(not(features = "no_module"))] #[cfg(not(features = "no_module"))]

View File

@ -57,6 +57,7 @@
//! See [The Rhai Book](https://rhai.rs/book) for details on the Rhai scripting engine and language. //! See [The Rhai Book](https://rhai.rs/book) for details on the Rhai scripting engine and language.
#![cfg_attr(feature = "no_std", no_std)] #![cfg_attr(feature = "no_std", no_std)]
#![deny(missing_docs)]
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
extern crate alloc; extern crate alloc;

View File

@ -55,7 +55,7 @@ struct OptimizerState<'a> {
/// The global runtime state. /// The global runtime state.
global: GlobalRuntimeState<'a>, global: GlobalRuntimeState<'a>,
/// Function resolution caches. /// Function resolution caches.
caches: Caches, caches: Caches<'a>,
/// [Module][crate::Module] containing script-defined functions. /// [Module][crate::Module] containing script-defined functions.
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
lib: &'a [&'a crate::Module], lib: &'a [&'a crate::Module],

View File

@ -97,6 +97,7 @@ macro_rules! def_package {
} }
impl $package { impl $package {
#[doc=concat!("Create a new `", stringify!($package), "`")]
pub fn new() -> Self { pub fn new() -> Self {
let mut module = $crate::Module::new(); let mut module = $crate::Module::new();
<Self as $crate::packages::Package>::init(&mut module); <Self as $crate::packages::Package>::init(&mut module);

View File

@ -46,7 +46,7 @@ pub struct ParseState<'e> {
/// Input stream buffer containing the next character to read. /// Input stream buffer containing the next character to read.
pub tokenizer_control: TokenizerControl, pub tokenizer_control: TokenizerControl,
/// Interned strings. /// Interned strings.
interned_strings: StringsInterner, interned_strings: StringsInterner<'e>,
/// External [scope][Scope] with constants. /// External [scope][Scope] with constants.
pub scope: &'e Scope<'e>, pub scope: &'e Scope<'e>,
/// Global runtime state. /// Global runtime state.

View File

@ -292,6 +292,7 @@ pub struct Span {
} }
impl Span { impl Span {
/// Empty [`Span`].
pub const NONE: Self = Self::new(Position::NONE, Position::NONE); pub const NONE: Self = Self::new(Position::NONE, Position::NONE);
/// Create a new [`Span`]. /// Create a new [`Span`].
@ -862,15 +863,15 @@ impl Token {
}) })
} }
// Is this token [`EOF`][Token::EOF]? /// Is this token [`EOF`][Token::EOF]?
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn is_eof(&self) -> bool { pub const fn is_eof(&self) -> bool {
matches!(self, Self::EOF) matches!(self, Self::EOF)
} }
// If another operator is after these, it's probably an unary operator /// If another operator is after these, it's probably a unary operator
// (not sure about `fn` name). /// (not sure about `fn` name).
#[must_use] #[must_use]
pub const fn is_next_unary(&self) -> bool { pub const fn is_next_unary(&self) -> bool {
use Token::*; use Token::*;

View File

@ -17,16 +17,19 @@ use std::{
/// A general function pointer, which may carry additional (i.e. curried) argument values /// A general function pointer, which may carry additional (i.e. curried) argument values
/// to be passed onto a function during a call. /// to be passed onto a function during a call.
#[derive(Clone, Hash)] #[derive(Clone, Hash)]
pub struct FnPtr(Identifier, StaticVec<Dynamic>); pub struct FnPtr {
name: Identifier,
curry: StaticVec<Dynamic>,
}
impl fmt::Debug for FnPtr { impl fmt::Debug for FnPtr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if !self.is_curried() { if !self.is_curried() {
write!(f, "Fn({})", self.fn_name()) write!(f, "Fn({})", self.fn_name())
} else { } else {
self.1 self.curry
.iter() .iter()
.fold(f.debug_tuple("Fn").field(&self.0), |f, curry| { .fold(f.debug_tuple("Fn").field(&self.name), |f, curry| {
f.field(curry) f.field(curry)
}) })
.finish() .finish()
@ -44,7 +47,10 @@ impl FnPtr {
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub(crate) fn new_unchecked(name: impl Into<Identifier>, curry: StaticVec<Dynamic>) -> Self { pub(crate) fn new_unchecked(name: impl Into<Identifier>, curry: StaticVec<Dynamic>) -> Self {
Self(name.into(), curry) Self {
name: name.into(),
curry,
}
} }
/// Get the name of the function. /// Get the name of the function.
#[inline(always)] #[inline(always)]
@ -56,37 +62,37 @@ impl FnPtr {
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub(crate) const fn fn_name_raw(&self) -> &Identifier { pub(crate) const fn fn_name_raw(&self) -> &Identifier {
&self.0 &self.name
} }
/// Get the underlying data of the function pointer. /// Get the underlying data of the function pointer.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub(crate) fn take_data(self) -> (Identifier, StaticVec<Dynamic>) { pub(crate) fn take_data(self) -> (Identifier, StaticVec<Dynamic>) {
(self.0, self.1) (self.name, self.curry)
} }
/// Get the curried arguments. /// Get the curried arguments.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn curry(&self) -> &[Dynamic] { pub fn curry(&self) -> &[Dynamic] {
self.1.as_ref() self.curry.as_ref()
} }
/// Add a new curried argument. /// Add a new curried argument.
#[inline(always)] #[inline(always)]
pub fn add_curry(&mut self, value: Dynamic) -> &mut Self { pub fn add_curry(&mut self, value: Dynamic) -> &mut Self {
self.1.push(value); self.curry.push(value);
self self
} }
/// Set curried arguments to the function pointer. /// Set curried arguments to the function pointer.
#[inline] #[inline]
pub fn set_curry(&mut self, values: impl IntoIterator<Item = Dynamic>) -> &mut Self { pub fn set_curry(&mut self, values: impl IntoIterator<Item = Dynamic>) -> &mut Self {
self.1 = values.into_iter().collect(); self.curry = values.into_iter().collect();
self self
} }
/// Is the function pointer curried? /// Is the function pointer curried?
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn is_curried(&self) -> bool { pub fn is_curried(&self) -> bool {
!self.1.is_empty() !self.curry.is_empty()
} }
/// Does the function pointer refer to an anonymous function? /// Does the function pointer refer to an anonymous function?
/// ///
@ -95,7 +101,7 @@ impl FnPtr {
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn is_anonymous(&self) -> bool { pub fn is_anonymous(&self) -> bool {
self.0.starts_with(crate::engine::FN_ANONYMOUS) self.name.starts_with(crate::engine::FN_ANONYMOUS)
} }
/// Call the function pointer with curried arguments (if any). /// Call the function pointer with curried arguments (if any).
/// The function may be script-defined (not available under `no_function`) or native Rust. /// The function may be script-defined (not available under `no_function`) or native Rust.
@ -234,7 +240,7 @@ impl FnPtr {
impl fmt::Display for FnPtr { impl fmt::Display for FnPtr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Fn({})", self.0) write!(f, "Fn({})", self.fn_name())
} }
} }
@ -244,7 +250,10 @@ impl TryFrom<Identifier> for FnPtr {
#[inline] #[inline]
fn try_from(value: Identifier) -> RhaiResultOf<Self> { fn try_from(value: Identifier) -> RhaiResultOf<Self> {
if is_valid_identifier(value.chars()) { if is_valid_identifier(value.chars()) {
Ok(Self(value, StaticVec::new_const())) Ok(Self {
name: value,
curry: StaticVec::new_const(),
})
} else { } else {
Err(ERR::ErrorFunctionNotFound(value.to_string(), Position::NONE).into()) Err(ERR::ErrorFunctionNotFound(value.to_string(), Position::NONE).into())
} }

View File

@ -1,14 +1,14 @@
use crate::{Identifier, ImmutableString}; use crate::{Identifier, ImmutableString};
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
use std::{collections::BTreeMap, ops::AddAssign}; use std::{collections::BTreeMap, marker::PhantomData, ops::AddAssign};
/// _(internals)_ A factory of identifiers from text strings. /// _(internals)_ A factory of identifiers from text strings.
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
/// ///
/// Normal identifiers, property getters and setters are interned separately. /// Normal identifiers, property getters and setters are interned separately.
#[derive(Debug, Clone, Default, Hash)] #[derive(Debug, Clone, Default, Hash)]
pub struct StringsInterner { pub struct StringsInterner<'a> {
/// Normal strings. /// Normal strings.
strings: BTreeMap<Identifier, ImmutableString>, strings: BTreeMap<Identifier, ImmutableString>,
/// Property getters. /// Property getters.
@ -17,9 +17,11 @@ pub struct StringsInterner {
/// Property setters. /// Property setters.
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
setters: BTreeMap<Identifier, ImmutableString>, setters: BTreeMap<Identifier, ImmutableString>,
/// Take care of the lifetime parameter.
dummy: PhantomData<&'a ()>,
} }
impl StringsInterner { impl StringsInterner<'_> {
/// Create a new [`StringsInterner`]. /// Create a new [`StringsInterner`].
#[inline] #[inline]
#[must_use] #[must_use]
@ -30,6 +32,7 @@ impl StringsInterner {
getters: BTreeMap::new(), getters: BTreeMap::new(),
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
setters: BTreeMap::new(), setters: BTreeMap::new(),
dummy: PhantomData,
} }
} }
/// Get an identifier from a text string and prefix, adding it to the interner if necessary. /// Get an identifier from a text string and prefix, adding it to the interner if necessary.
@ -69,7 +72,7 @@ impl StringsInterner {
} }
} }
impl AddAssign<Self> for StringsInterner { impl AddAssign<Self> for StringsInterner<'_> {
#[inline(always)] #[inline(always)]
fn add_assign(&mut self, rhs: Self) { fn add_assign(&mut self, rhs: Self) {
self.strings.extend(rhs.strings.into_iter()); self.strings.extend(rhs.strings.into_iter());
@ -80,7 +83,7 @@ impl AddAssign<Self> for StringsInterner {
} }
} }
impl AddAssign<&Self> for StringsInterner { impl AddAssign<&Self> for StringsInterner<'_> {
#[inline(always)] #[inline(always)]
fn add_assign(&mut self, rhs: &Self) { fn add_assign(&mut self, rhs: &Self) {
self.strings self.strings

View File

@ -69,7 +69,7 @@ pub struct Scope<'a> {
/// Aliases of the entry. /// Aliases of the entry.
aliases: SmallVec<[Vec<Identifier>; SCOPE_ENTRIES_INLINED]>, aliases: SmallVec<[Vec<Identifier>; SCOPE_ENTRIES_INLINED]>,
/// Phantom to keep the lifetime parameter in order not to break existing code. /// Phantom to keep the lifetime parameter in order not to break existing code.
phantom: PhantomData<&'a ()>, dummy: PhantomData<&'a ()>,
} }
impl fmt::Display for Scope<'_> { impl fmt::Display for Scope<'_> {
@ -112,7 +112,7 @@ impl Clone for Scope<'_> {
.collect(), .collect(),
names: self.names.clone(), names: self.names.clone(),
aliases: self.aliases.clone(), aliases: self.aliases.clone(),
phantom: self.phantom.clone(), dummy: self.dummy.clone(),
} }
} }
} }
@ -152,7 +152,7 @@ impl Scope<'_> {
values: SmallVec::new_const(), values: SmallVec::new_const(),
names: SmallVec::new_const(), names: SmallVec::new_const(),
aliases: SmallVec::new_const(), aliases: SmallVec::new_const(),
phantom: PhantomData, dummy: PhantomData,
} }
} }
/// Empty the [`Scope`]. /// Empty the [`Scope`].
@ -511,9 +511,33 @@ impl Scope<'_> {
} }
self self
} }
/// Get a reference to an entry in the [`Scope`].
///
/// If the entry by the specified name is not found, [`None`] is returned.
///
/// # Example
///
/// ```
/// use rhai::Scope;
///
/// let mut my_scope = Scope::new();
///
/// my_scope.push("x", 42_i64);
///
/// let value = my_scope.get("x").expect("x should exist");
///
/// assert_eq!(value.as_int().unwrap(), 42);
///
/// assert!(my_scope.get("z").is_none());
/// ```
#[inline(always)]
#[must_use]
pub fn get(&self, name: &str) -> Option<&Dynamic> {
self.get_index(name).map(|(index, _)| &self.values[index])
}
/// Get a mutable reference to an entry in the [`Scope`]. /// Get a mutable reference to an entry in the [`Scope`].
/// ///
/// If the entry by the specified name is not found, of if it is read-only, /// If the entry by the specified name is not found, or if it is read-only,
/// [`None`] is returned. /// [`None`] is returned.
/// ///
/// # Example /// # Example
@ -531,8 +555,8 @@ impl Scope<'_> {
/// ///
/// assert_eq!(my_scope.get_value::<i64>("x").expect("x should exist"), 123); /// assert_eq!(my_scope.get_value::<i64>("x").expect("x should exist"), 123);
/// ///
/// my_scope.push_constant("Z", 1_i64); /// my_scope.push_constant("z", 1_i64);
/// assert!(my_scope.get_mut("Z").is_none()); /// assert!(my_scope.get_mut("z").is_none());
/// ``` /// ```
#[inline] #[inline]
#[must_use] #[must_use]

View File

@ -121,8 +121,6 @@ fn test_plugins_package() -> Result<(), Box<EvalAltResult>> {
fn test_plugins_parameters() -> Result<(), Box<EvalAltResult>> { fn test_plugins_parameters() -> Result<(), Box<EvalAltResult>> {
#[export_module] #[export_module]
mod rhai_std { mod rhai_std {
use rhai::*;
pub fn noop(_: &str) {} pub fn noop(_: &str) {}
} }