Removee debug_msgs feature.

This commit is contained in:
Stephen Chung 2020-03-18 22:03:50 +08:00
parent 019e73bc7e
commit 0dc51f8e59
8 changed files with 6 additions and 52 deletions

View File

@ -21,14 +21,13 @@ num-traits = "0.2.11"
[features] [features]
#default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"] #default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"]
default = [] default = []
debug_msgs = [] # print debug messages on function registrations and calls
unchecked = [] # unchecked arithmetic unchecked = [] # unchecked arithmetic
no_stdlib = [] # no standard library of utility functions no_stdlib = [] # no standard library of utility functions
no_index = [] # no arrays and indexing no_index = [] # no arrays and indexing
no_float = [] # no floating-point no_float = [] # no floating-point
no_function = [] # no script-defined functions no_function = [] # no script-defined functions
no_optimize = [] # no script optimizer no_optimize = [] # no script optimizer
optimize_full = [] # set optimization level to Full (default is Simple) - this is a feature used only to simply testing optimize_full = [] # set optimization level to Full (default is Simple) - this is a feature used only to simplify testing
only_i32 = [] # set INT=i32 (useful for 32-bit systems) only_i32 = [] # set INT=i32 (useful for 32-bit systems)
only_i64 = [] # set INT=i64 (default) and disable support for all other integer types only_i64 = [] # set INT=i64 (default) and disable support for all other integer types

View File

@ -44,7 +44,6 @@ Optional features
| Feature | Description | | Feature | Description |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `debug_msgs` | Print debug messages to stdout related to function registrations and calls. |
| `no_stdlib` | Exclude the standard library of utility functions in the build, and only include the minimum necessary functionalities. Standard types are not affected. | | `no_stdlib` | Exclude the standard library of utility functions in the build, and only include the minimum necessary functionalities. Standard types are not affected. |
| `unchecked` | Exclude arithmetic checking (such as overflows and division by zero). Beware that a bad script may panic the entire system! | | `unchecked` | Exclude arithmetic checking (such as overflows and division by zero). Beware that a bad script may panic the entire system! |
| `no_function` | Disable script-defined functions if not needed. | | `no_function` | Disable script-defined functions if not needed. |

View File

@ -29,20 +29,6 @@ impl<'e> Engine<'e> {
args: Option<Vec<TypeId>>, args: Option<Vec<TypeId>>,
f: Box<FnAny>, f: Box<FnAny>,
) { ) {
debug_println!(
"Register function: {} with {}",
fn_name,
if let Some(a) = &args {
format!(
"{} parameter{}",
a.len(),
if a.len() > 1 { "s" } else { "" }
)
} else {
"no parameter".to_string()
}
);
let spec = FnSpec { let spec = FnSpec {
name: fn_name.to_string().into(), name: fn_name.to_string().into(),
args, args,

View File

@ -3,11 +3,12 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use crate::any::{Any, Dynamic}; use crate::any::{Any, Dynamic};
use crate::stdlib::{string::String, vec, vec::Vec};
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
use crate::engine::Array; use crate::engine::Array;
use crate::stdlib::{string::String, vec, vec::Vec};
/// Trait that represent arguments to a function call. /// Trait that represent arguments to a function call.
pub trait FuncArgs { pub trait FuncArgs {
/// Convert to a `Vec` of `Dynamic` arguments. /// Convert to a `Vec` of `Dynamic` arguments.

View File

@ -165,16 +165,6 @@ impl Engine<'_> {
def_val: Option<&Dynamic>, def_val: Option<&Dynamic>,
pos: Position, pos: Position,
) -> Result<Dynamic, EvalAltResult> { ) -> Result<Dynamic, EvalAltResult> {
debug_println!(
"Calling function: {} ({})",
fn_name,
args.iter()
.map(|x| (*x).type_name())
.map(|name| self.map_type_name(name))
.collect::<Vec<_>>()
.join(", ")
);
// First search in script-defined functions (can override built-in) // First search in script-defined functions (can override built-in)
if let Ok(n) = self if let Ok(n) = self
.script_functions .script_functions

View File

@ -1,6 +1,7 @@
//! Module containing error definitions for the parsing process. //! Module containing error definitions for the parsing process.
use crate::parser::Position; use crate::parser::Position;
use crate::stdlib::{char, error::Error, fmt, string::String}; use crate::stdlib::{char, error::Error, fmt, string::String};
/// Error when tokenizing the script text. /// Error when tokenizing the script text.

View File

@ -6,6 +6,7 @@ use crate::any::{Any, Dynamic};
use crate::engine::{Engine, FnCallArgs}; use crate::engine::{Engine, FnCallArgs};
use crate::parser::Position; use crate::parser::Position;
use crate::result::EvalAltResult; use crate::result::EvalAltResult;
use crate::stdlib::{any::TypeId, boxed::Box, string::ToString, vec}; use crate::stdlib::{any::TypeId, boxed::Box, string::ToString, vec};
/// A trait to register custom functions with the `Engine`. /// A trait to register custom functions with the `Engine`.

View File

@ -43,30 +43,6 @@
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
extern crate alloc; extern crate alloc;
// needs to be here, because order matters for macros
macro_rules! debug_println {
() => (
#[cfg(feature = "debug_msgs")]
{
print!("\n");
}
);
($fmt:expr) => (
#[cfg(feature = "debug_msgs")]
{
print!(concat!($fmt, "\n"));
}
);
($fmt:expr, $($arg:tt)*) => (
#[cfg(feature = "debug_msgs")]
{
print!(concat!($fmt, "\n"), $($arg)*);
}
);
}
#[macro_use]
mod stdlib;
mod any; mod any;
mod api; mod api;
mod builtin; mod builtin;
@ -78,6 +54,7 @@ mod optimize;
mod parser; mod parser;
mod result; mod result;
mod scope; mod scope;
mod stdlib;
pub use any::{Any, AnyExt, Dynamic, Variant}; pub use any::{Any, AnyExt, Dynamic, Variant};
pub use call::FuncArgs; pub use call::FuncArgs;