no_std = no_time.
This commit is contained in:
parent
a6a570131a
commit
45f0fdcbe0
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@ -60,10 +60,11 @@ jobs:
|
||||
- "--features no_object,serde,metadata,internals,debugging"
|
||||
- "--features no_function,serde,metadata,internals,debugging"
|
||||
- "--features no_module,serde,metadata,internals,debugging"
|
||||
- "--features no_time,serde,metadata,internals,debugging"
|
||||
- "--features no_closure,serde,metadata,internals,debugging"
|
||||
- "--features unicode-xid-ident,serde,metadata,internals,debugging"
|
||||
- "--features sync,no_function,no_float,no_position,no_optimize,no_module,no_closure,no_custom_syntax,metadata,serde,unchecked,debugging"
|
||||
- "--features no_function,no_float,no_position,no_index,no_object,no_optimize,no_module,no_closure,no_custom_syntax,unchecked"
|
||||
- "--features sync,no_time,no_function,no_float,no_position,no_optimize,no_module,no_closure,no_custom_syntax,metadata,serde,unchecked,debugging"
|
||||
- "--features no_time,no_function,no_float,no_position,no_index,no_object,no_optimize,no_module,no_closure,no_custom_syntax,unchecked"
|
||||
toolchain: [stable]
|
||||
experimental: [false]
|
||||
include:
|
||||
|
@ -53,11 +53,11 @@ only_i64 = [] # set INT=i64 (default) and disable support for
|
||||
decimal = ["rust_decimal"] # add the Decimal number type
|
||||
no_index = [] # no arrays and indexing
|
||||
no_object = [] # no custom objects
|
||||
no_time = [] # no timestamps
|
||||
no_function = ["no_closure"] # no script-defined functions (meaning no closures)
|
||||
no_closure = [] # no automatic sharing and capture of anonymous functions to external variables
|
||||
no_module = [] # no modules
|
||||
no_custom_syntax = [] # no custom syntax or custom operators
|
||||
no_time = [] # no timestamps
|
||||
unicode-xid-ident = ["unicode-xid"] # allow Unicode Standard Annex #31 for identifiers.
|
||||
metadata = ["serde", "serde_json", "rhai_codegen/metadata", "smartstring/serde"] # enable exporting functions metadata
|
||||
internals = [] # expose internal data structures
|
||||
@ -65,7 +65,7 @@ debugging = ["internals"] # enable debugging
|
||||
serde = ["dep:serde", "smartstring/serde", "smallvec/serde"] # implement serde for rhai types
|
||||
|
||||
# compiling for no-std
|
||||
no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "hashbrown"]
|
||||
no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "hashbrown", "no_time"]
|
||||
|
||||
# compiling for WASM
|
||||
wasm-bindgen = ["instant/wasm-bindgen"]
|
||||
|
@ -555,7 +555,6 @@ fn def_type_name<'a>(ty: &'a str, engine: &'a Engine) -> Cow<'a, str> {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
let ty = ty.replace(type_name::<crate::Map>(), "Map");
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
let ty = ty.replace(type_name::<crate::Instant>(), "Instant");
|
||||
|
||||
|
@ -44,7 +44,6 @@ fn map_std_type_name(name: &str, shorthands: bool) -> &str {
|
||||
if name == type_name::<crate::Map>() || name == "Map" {
|
||||
return if shorthands { "map" } else { "Map" };
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
if name == type_name::<crate::Instant>() || name == "Instant" {
|
||||
return if shorthands { "timestamp" } else { "Instant" };
|
||||
|
@ -204,7 +204,6 @@ pub use eval::EvalContext;
|
||||
pub use func::{NativeCallContext, RegisterNativeFunction};
|
||||
pub use module::{FnNamespace, Module};
|
||||
pub use tokenizer::Position;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
pub use types::Instant;
|
||||
pub use types::{
|
||||
|
@ -38,7 +38,6 @@ pub use pkg_core::CorePackage;
|
||||
pub use pkg_std::StandardPackage;
|
||||
pub use string_basic::BasicStringPackage;
|
||||
pub use string_more::MoreStringPackage;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
pub use time_basic::BasicTimePackage;
|
||||
|
||||
|
@ -26,7 +26,7 @@ def_package! {
|
||||
#[cfg(not(feature = "no_index"))] BasicArrayPackage,
|
||||
#[cfg(not(feature = "no_index"))] BasicBlobPackage,
|
||||
#[cfg(not(feature = "no_object"))] BasicMapPackage,
|
||||
#[cfg(all(not(feature = "no_std"), not(feature = "no_time")))] BasicTimePackage,
|
||||
#[cfg(not(feature = "no_time"))] BasicTimePackage,
|
||||
MoreStringPackage
|
||||
{
|
||||
lib.standard = true;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![cfg(not(feature = "no_std"))]
|
||||
#![cfg(not(feature = "no_time"))]
|
||||
|
||||
use super::arithmetic::make_err as make_arithmetic_err;
|
||||
|
@ -156,7 +156,6 @@ impl<'de> Deserializer<'de> for DynamicDeserializer<'de> {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(..) => self.deserialize_map(visitor),
|
||||
Union::FnPtr(..) => self.type_error(),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => self.type_error(),
|
||||
|
||||
|
@ -9,7 +9,6 @@ use std::prelude::v1::*;
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
use serde::ser::SerializeMap;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
use crate::types::dynamic::Variant;
|
||||
|
||||
@ -66,7 +65,6 @@ impl Serialize for Dynamic {
|
||||
map.end()
|
||||
}
|
||||
Union::FnPtr(ref f, ..) => ser.serialize_str(f.fn_name()),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(ref x, ..) => ser.serialize_str(x.as_ref().type_name()),
|
||||
|
||||
|
@ -14,12 +14,10 @@ use std::{
|
||||
|
||||
pub use super::Variant;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub use std::time::Instant;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub use instant::Instant;
|
||||
@ -86,7 +84,6 @@ pub enum Union {
|
||||
/// A function pointer.
|
||||
FnPtr(Box<FnPtr>, Tag, AccessMode),
|
||||
/// A timestamp value.
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
TimeStamp(Box<Instant>, Tag, AccessMode),
|
||||
|
||||
@ -197,7 +194,6 @@ impl Dynamic {
|
||||
Union::Array(_, tag, _) | Union::Blob(_, tag, _) => tag,
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(_, tag, _) => tag,
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(_, tag, _) => tag,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
@ -223,7 +219,6 @@ impl Dynamic {
|
||||
Union::Array(_, ref mut tag, _) | Union::Blob(_, ref mut tag, _) => *tag = value,
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(_, ref mut tag, _) => *tag = value,
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(_, ref mut tag, _) => *tag = value,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
@ -296,7 +291,6 @@ impl Dynamic {
|
||||
if TypeId::of::<T>() == TypeId::of::<FnPtr>() {
|
||||
return matches!(self.0, Union::FnPtr(..));
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
if TypeId::of::<T>() == TypeId::of::<crate::Instant>() {
|
||||
return matches!(self.0, Union::TimeStamp(..));
|
||||
@ -329,7 +323,6 @@ impl Dynamic {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(..) => TypeId::of::<crate::Map>(),
|
||||
Union::FnPtr(..) => TypeId::of::<FnPtr>(),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => TypeId::of::<Instant>(),
|
||||
|
||||
@ -364,7 +357,6 @@ impl Dynamic {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(..) => "map",
|
||||
Union::FnPtr(..) => "Fn",
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => "timestamp",
|
||||
|
||||
@ -415,7 +407,6 @@ impl Hash for Dynamic {
|
||||
|
||||
Union::Variant(..) => unimplemented!("{} cannot be hashed", self.type_name()),
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => unimplemented!("{} cannot be hashed", self.type_name()),
|
||||
}
|
||||
@ -441,7 +432,6 @@ impl fmt::Display for Dynamic {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(..) => fmt::Debug::fmt(self, f),
|
||||
Union::FnPtr(ref v, ..) => fmt::Display::fmt(v, f),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => f.write_str("<timestamp>"),
|
||||
|
||||
@ -547,7 +537,6 @@ impl fmt::Debug for Dynamic {
|
||||
fmt::Debug::fmt(v, f)
|
||||
}
|
||||
Union::FnPtr(ref v, ..) => fmt::Debug::fmt(v, f),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(..) => write!(f, "<timestamp>"),
|
||||
|
||||
@ -646,7 +635,6 @@ impl Clone for Dynamic {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(ref v, tag, ..) => Self(Union::Map(v.clone(), tag, ReadWrite)),
|
||||
Union::FnPtr(ref v, tag, ..) => Self(Union::FnPtr(v.clone(), tag, ReadWrite)),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(ref v, tag, ..) => Self(Union::TimeStamp(v.clone(), tag, ReadWrite)),
|
||||
|
||||
@ -889,7 +877,6 @@ impl Dynamic {
|
||||
/// Create a new [`Dynamic`] from an [`Instant`].
|
||||
///
|
||||
/// Not available under `no-std` or `no_time`.
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
@ -917,7 +904,6 @@ impl Dynamic {
|
||||
Union::Array(.., access) | Union::Blob(.., access) => access,
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(.., access) => access,
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(.., access) => access,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
@ -955,7 +941,6 @@ impl Dynamic {
|
||||
v.set_access_mode(typ);
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(.., ref mut access) => *access = typ,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
@ -1090,7 +1075,6 @@ impl Dynamic {
|
||||
reify!(value, |v: crate::Map| return v.into());
|
||||
reify!(value, |v: FnPtr| return v.into());
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
reify!(value, |v: Instant| return v.into());
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
@ -1184,7 +1168,6 @@ impl Dynamic {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(v, ..) => reify!(*v => Option<T>),
|
||||
Union::FnPtr(v, ..) => reify!(*v => Option<T>),
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
Union::TimeStamp(v, ..) => reify!(*v => Option<T>),
|
||||
Union::Unit(v, ..) => reify!(v => Option<T>),
|
||||
@ -1484,7 +1467,6 @@ impl Dynamic {
|
||||
_ => None,
|
||||
};
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
if TypeId::of::<T>() == TypeId::of::<Instant>() {
|
||||
return match self.0 {
|
||||
@ -1583,7 +1565,6 @@ impl Dynamic {
|
||||
_ => None,
|
||||
};
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
if TypeId::of::<T>() == TypeId::of::<Instant>() {
|
||||
return match self.0 {
|
||||
@ -1978,7 +1959,6 @@ impl From<FnPtr> for Dynamic {
|
||||
Self(Union::FnPtr(value.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
impl From<Instant> for Dynamic {
|
||||
#[inline(always)]
|
||||
|
@ -14,7 +14,6 @@ pub mod variant;
|
||||
pub use bloom_filter::BloomFilterU64;
|
||||
pub use custom_types::{CustomTypeInfo, CustomTypesCollection};
|
||||
pub use dynamic::Dynamic;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
pub use dynamic::Instant;
|
||||
pub use error::EvalAltResult;
|
||||
|
Loading…
Reference in New Issue
Block a user