Fix all features.
This commit is contained in:
parent
930abb8b5c
commit
adc96e24bd
@ -7,10 +7,10 @@ Version 0.17.0
|
|||||||
This version adds:
|
This version adds:
|
||||||
|
|
||||||
* [`serde`](https://crates.io/crates/serde) support for working with `Dynamic` values (particularly _object maps_).
|
* [`serde`](https://crates.io/crates/serde) support for working with `Dynamic` values (particularly _object maps_).
|
||||||
|
* Low-level API to register functions.
|
||||||
* Surgically disable keywords and/or operators in the language.
|
* Surgically disable keywords and/or operators in the language.
|
||||||
* Define custom operators.
|
* Define custom operators.
|
||||||
* Extend the language via custom syntax.
|
* Extend the language via custom syntax.
|
||||||
* Low-level API to register functions.
|
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
---------
|
---------
|
||||||
@ -41,6 +41,7 @@ New features
|
|||||||
* Many configuration/setting API's now returns `&mut Self` so that the calls can be chained.
|
* Many configuration/setting API's now returns `&mut Self` so that the calls can be chained.
|
||||||
* `String` parameters in functions are supported (but inefficiently).
|
* `String` parameters in functions are supported (but inefficiently).
|
||||||
|
|
||||||
|
|
||||||
Version 0.16.1
|
Version 0.16.1
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
@ -212,9 +212,11 @@ pub(crate) fn map_std_type_name(name: &str) -> &str {
|
|||||||
"string"
|
"string"
|
||||||
} else if name == type_name::<FnPtr>() {
|
} else if name == type_name::<FnPtr>() {
|
||||||
"Fn"
|
"Fn"
|
||||||
} else if name == type_name::<Instant>() {
|
|
||||||
"timestamp"
|
|
||||||
} else {
|
} else {
|
||||||
|
#[cfg(not(feature = "no_std"))]
|
||||||
|
if name == type_name::<Instant>() {
|
||||||
|
return "timestamp";
|
||||||
|
}
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
if name == type_name::<Array>() {
|
if name == type_name::<Array>() {
|
||||||
return "array";
|
return "array";
|
||||||
|
@ -26,7 +26,7 @@ use crate::stdlib::{
|
|||||||
boxed::Box,
|
boxed::Box,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
format,
|
fmt, format,
|
||||||
iter::{empty, once},
|
iter::{empty, once},
|
||||||
mem,
|
mem,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
@ -96,6 +96,7 @@ pub const MARKER_BLOCK: &str = "$block$";
|
|||||||
pub const MARKER_IDENT: &str = "$ident$";
|
pub const MARKER_IDENT: &str = "$ident$";
|
||||||
|
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Expression<'a>(&'a Expr);
|
pub struct Expression<'a>(&'a Expr);
|
||||||
|
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
@ -346,6 +347,15 @@ pub struct Engine {
|
|||||||
pub(crate) max_map_size: usize,
|
pub(crate) max_map_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Engine {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self.id.as_ref() {
|
||||||
|
Some(id) => write!(f, "Engine({})", id),
|
||||||
|
None => f.write_str("Engine"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Engine {
|
impl Default for Engine {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// Create the new scripting Engine
|
// Create the new scripting Engine
|
||||||
@ -1095,6 +1105,7 @@ impl Engine {
|
|||||||
let mut hash = *hash;
|
let mut hash = *hash;
|
||||||
|
|
||||||
// Check if it is a map method call in OOP style
|
// Check if it is a map method call in OOP style
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
if let Some(map) = obj.downcast_ref::<Map>() {
|
if let Some(map) = obj.downcast_ref::<Map>() {
|
||||||
if let Some(val) = map.get(fn_name) {
|
if let Some(val) = map.get(fn_name) {
|
||||||
if let Some(f) = val.downcast_ref::<FnPtr>() {
|
if let Some(f) = val.downcast_ref::<FnPtr>() {
|
||||||
|
@ -7,7 +7,7 @@ use crate::result::EvalAltResult;
|
|||||||
use crate::token::{is_valid_identifier, Position};
|
use crate::token::{is_valid_identifier, Position};
|
||||||
use crate::utils::ImmutableString;
|
use crate::utils::ImmutableString;
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, convert::TryFrom, fmt, rc::Rc, sync::Arc};
|
use crate::stdlib::{boxed::Box, convert::TryFrom, fmt, rc::Rc, string::String, sync::Arc};
|
||||||
|
|
||||||
/// Trait that maps to `Send + Sync` only under the `sync` feature.
|
/// Trait that maps to `Send + Sync` only under the `sync` feature.
|
||||||
#[cfg(feature = "sync")]
|
#[cfg(feature = "sync")]
|
||||||
@ -86,7 +86,7 @@ impl TryFrom<ImmutableString> for FnPtr {
|
|||||||
Ok(Self(value))
|
Ok(Self(value))
|
||||||
} else {
|
} else {
|
||||||
Err(Box::new(EvalAltResult::ErrorFunctionNotFound(
|
Err(Box::new(EvalAltResult::ErrorFunctionNotFound(
|
||||||
value.to_string(),
|
value.into(),
|
||||||
Position::none(),
|
Position::none(),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,12 @@ use crate::r#unsafe::unsafe_cast_box;
|
|||||||
use crate::result::EvalAltResult;
|
use crate::result::EvalAltResult;
|
||||||
use crate::utils::ImmutableString;
|
use crate::utils::ImmutableString;
|
||||||
|
|
||||||
use crate::stdlib::{any::TypeId, boxed::Box, mem};
|
use crate::stdlib::{
|
||||||
|
any::TypeId,
|
||||||
|
boxed::Box,
|
||||||
|
mem,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
|
|
||||||
/// Trait to register custom functions with the `Engine`.
|
/// Trait to register custom functions with the `Engine`.
|
||||||
pub trait RegisterFn<FN, ARGS, RET> {
|
pub trait RegisterFn<FN, ARGS, RET> {
|
||||||
|
@ -25,11 +25,13 @@ use crate::stdlib::{
|
|||||||
num::NonZeroUsize,
|
num::NonZeroUsize,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
sync::RwLock,
|
|
||||||
vec,
|
vec,
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_std"))]
|
||||||
|
use crate::stdlib::sync::RwLock;
|
||||||
|
|
||||||
/// Return type of module-level Rust function.
|
/// Return type of module-level Rust function.
|
||||||
pub type FuncReturn<T> = Result<T, Box<EvalAltResult>>;
|
pub type FuncReturn<T> = Result<T, Box<EvalAltResult>>;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub type PackageLibrary = Shared<Module>;
|
|||||||
|
|
||||||
/// Type containing a collection of `PackageLibrary` instances.
|
/// Type containing a collection of `PackageLibrary` instances.
|
||||||
/// All function and type iterator keys in the loaded packages are indexed for fast access.
|
/// All function and type iterator keys in the loaded packages are indexed for fast access.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub(crate) struct PackagesCollection(StaticVec<PackageLibrary>);
|
pub(crate) struct PackagesCollection(StaticVec<PackageLibrary>);
|
||||||
|
|
||||||
impl PackagesCollection {
|
impl PackagesCollection {
|
||||||
|
@ -4,6 +4,8 @@ use crate::optimize::OptimizationLevel;
|
|||||||
use crate::packages::PackageLibrary;
|
use crate::packages::PackageLibrary;
|
||||||
use crate::token::is_valid_identifier;
|
use crate::token::is_valid_identifier;
|
||||||
|
|
||||||
|
use crate::stdlib::{boxed::Box, format, string::String};
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
/// Load a new package into the `Engine`.
|
/// Load a new package into the `Engine`.
|
||||||
///
|
///
|
||||||
|
@ -16,7 +16,7 @@ mod inner {
|
|||||||
pub use core_error as error;
|
pub use core_error as error;
|
||||||
|
|
||||||
pub mod collections {
|
pub mod collections {
|
||||||
pub use hashbrown::HashMap;
|
pub use hashbrown::{HashMap, HashSet};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ impl Engine {
|
|||||||
) -> Result<Dynamic, Box<EvalAltResult>>
|
) -> Result<Dynamic, Box<EvalAltResult>>
|
||||||
+ SendSync
|
+ SendSync
|
||||||
+ 'static,
|
+ 'static,
|
||||||
) -> Result<self, Box<LexError>> {
|
) -> Result<&mut Self, Box<LexError>> {
|
||||||
if value.is_empty() {
|
if value.is_empty() {
|
||||||
return Err(Box::new(LexError::ImproperSymbol("".to_string())));
|
return Err(Box::new(LexError::ImproperSymbol("".to_string())));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use crate::stdlib::{
|
|||||||
boxed::Box,
|
boxed::Box,
|
||||||
char,
|
char,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt,
|
fmt, format,
|
||||||
iter::Peekable,
|
iter::Peekable,
|
||||||
str::{Chars, FromStr},
|
str::{Chars, FromStr},
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
|
@ -115,6 +115,7 @@ fn test_anonymous_fn() -> Result<(), Box<EvalAltResult>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
fn test_fn_ptr() -> Result<(), Box<EvalAltResult>> {
|
fn test_fn_ptr() -> Result<(), Box<EvalAltResult>> {
|
||||||
let mut engine = Engine::new();
|
let mut engine = Engine::new();
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ fn test_tokens_custom_operator() -> Result<(), Box<EvalAltResult>> {
|
|||||||
15
|
15
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
engine.eval::<INT>(
|
engine.eval::<INT>(
|
||||||
r"
|
r"
|
||||||
|
Loading…
Reference in New Issue
Block a user