From eda80488d5973ec02dce76495d8ed61d0f128082 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 15 Dec 2021 12:46:25 +0800 Subject: [PATCH] Fix builds. --- src/engine.rs | 40 ++++++++++++++++++++++++-------------- src/packages/iter_basic.rs | 18 +++++++++++------ 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index b5be3a7e..2795bf0c 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -13,8 +13,8 @@ use crate::r#unsafe::unsafe_cast_var_name_to_lifetime; use crate::tokenizer::Token; use crate::types::dynamic::{map_std_type_name, AccessMode, Union, Variant}; use crate::{ - calc_fn_params_hash, combine_hashes, Dynamic, EvalAltResult, ExclusiveRange, Identifier, - ImmutableString, InclusiveRange, Module, Position, RhaiResult, Scope, Shared, StaticVec, INT, + calc_fn_params_hash, combine_hashes, Dynamic, EvalAltResult, Identifier, ImmutableString, + Module, Position, RhaiResult, Scope, Shared, StaticVec, INT, }; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -517,8 +517,10 @@ impl<'a> Target<'a> { Self::LockGuard(_) => true, Self::TempValue(_) => false, #[cfg(not(feature = "no_index"))] - Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, - Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, + Self::Bit(_, _, _) + | Self::BitField(_, _, _, _) + | Self::BlobByte(_, _, _) + | Self::StringChar(_, _, _) => false, } } /// Is the `Target` a temp value? @@ -531,8 +533,10 @@ impl<'a> Target<'a> { Self::LockGuard(_) => false, Self::TempValue(_) => true, #[cfg(not(feature = "no_index"))] - Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, - Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, + Self::Bit(_, _, _) + | Self::BitField(_, _, _, _) + | Self::BlobByte(_, _, _) + | Self::StringChar(_, _, _) => false, } } /// Is the `Target` a shared value? @@ -546,8 +550,10 @@ impl<'a> Target<'a> { Self::LockGuard(_) => true, Self::TempValue(r) => r.is_shared(), #[cfg(not(feature = "no_index"))] - Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, - Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, + Self::Bit(_, _, _) + | Self::BitField(_, _, _, _) + | Self::BlobByte(_, _, _) + | Self::StringChar(_, _, _) => false, } } /// Is the `Target` a specific type? @@ -729,8 +735,10 @@ impl Deref for Target<'_> { Self::LockGuard((r, _)) => &**r, Self::TempValue(ref r) => r, #[cfg(not(feature = "no_index"))] - Self::Bit(_, ref r, _) | Self::BitField(_, _, ref r, _) => r, - Self::BlobByte(_, _, ref r) | Self::StringChar(_, _, ref r) => r, + Self::Bit(_, ref r, _) + | Self::BitField(_, _, ref r, _) + | Self::BlobByte(_, _, ref r) + | Self::StringChar(_, _, ref r) => r, } } } @@ -751,8 +759,10 @@ impl DerefMut for Target<'_> { Self::LockGuard((r, _)) => r.deref_mut(), Self::TempValue(ref mut r) => r, #[cfg(not(feature = "no_index"))] - Self::Bit(_, ref mut r, _) | Self::BitField(_, _, ref mut r, _) => r, - Self::BlobByte(_, _, ref mut r) | Self::StringChar(_, _, ref mut r) => r, + Self::Bit(_, ref mut r, _) + | Self::BitField(_, _, ref mut r, _) + | Self::BlobByte(_, _, ref mut r) + | Self::StringChar(_, _, ref mut r) => r, } } } @@ -2111,7 +2121,7 @@ impl Engine { #[cfg(not(feature = "no_index"))] Dynamic(Union::Int(value, _, _)) - if idx.is::() || idx.is::() => + if idx.is::() || idx.is::() => { #[cfg(not(feature = "only_i32"))] type BASE = u64; @@ -2121,7 +2131,7 @@ impl Engine { // val_int[range] const BITS: usize = std::mem::size_of::() * 8; - let (shift, mask) = if let Some(range) = idx.read_lock::() { + let (shift, mask) = if let Some(range) = idx.read_lock::() { let start = range.start; let end = range.end; @@ -2141,7 +2151,7 @@ impl Engine { (((2 as BASE).pow((end - start) as u32) - 1) as INT) << start, ) } - } else if let Some(range) = idx.read_lock::() { + } else if let Some(range) = idx.read_lock::() { let start = *range.start(); let end = *range.end(); diff --git a/src/packages/iter_basic.rs b/src/packages/iter_basic.rs index 8372d603..1b4e1e97 100644 --- a/src/packages/iter_basic.rs +++ b/src/packages/iter_basic.rs @@ -479,9 +479,12 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, { #[cfg(feature = "metadata")] lib.update_fn_metadata(_hash, &["string: &str", "Iterator"]); - let _hash = lib.set_getter_fn("chars", |string: &mut ImmutableString| Ok(CharsStream::new(string, 0, INT::MAX))); - #[cfg(feature = "metadata")] - lib.update_fn_metadata(_hash, &["string: &mut ImmutableString", "Iterator"]); + #[cfg(not(feature = "no_object"))] + { + let _hash = lib.set_getter_fn("chars", |string: &mut ImmutableString| Ok(CharsStream::new(string, 0, INT::MAX))); + #[cfg(feature = "metadata")] + lib.update_fn_metadata(_hash, &["string: &mut ImmutableString", "Iterator"]); + } // Register bit-field iterator lib.set_iterator::(); @@ -514,9 +517,12 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, { #[cfg(feature = "metadata")] lib.update_fn_metadata(_hash, &["value: INT", "Iterator"]); - let _hash = lib.set_getter_fn("bits", |value: &mut INT| BitRange::new(*value, 0, INT::MAX) ); - #[cfg(feature = "metadata")] - lib.update_fn_metadata(_hash, &["value: &mut INT", "range: Range", "Iterator"]); + #[cfg(not(feature = "no_object"))] + { + let _hash = lib.set_getter_fn("bits", |value: &mut INT| BitRange::new(*value, 0, INT::MAX) ); + #[cfg(feature = "metadata")] + lib.update_fn_metadata(_hash, &["value: &mut INT", "range: Range", "Iterator"]); + } combine_with_exported_module!(lib, "range", range_functions); });