no_std = no_time.

This commit is contained in:
Stephen Chung
2022-10-15 15:11:51 +08:00
parent a6a570131a
commit 45f0fdcbe0
12 changed files with 6 additions and 34 deletions

View File

@@ -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");

View File

@@ -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" };

View File

@@ -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::{

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,4 +1,3 @@
#![cfg(not(feature = "no_std"))]
#![cfg(not(feature = "no_time"))]
use super::arithmetic::make_err as make_arithmetic_err;

View File

@@ -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(),

View File

@@ -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()),

View File

@@ -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)]

View File

@@ -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;