Fix builds
This commit is contained in:
parent
a0979d0c35
commit
36546c7325
@ -151,6 +151,7 @@ impl AST {
|
||||
&mut self.0
|
||||
}
|
||||
/// Get the internal shared [`Module`] containing all script-defined functions.
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[inline(always)]
|
||||
pub(crate) fn shared_lib(&self) -> Shared<Module> {
|
||||
|
@ -37,11 +37,11 @@ pub type Shared<T> = Rc<T>;
|
||||
pub type Shared<T> = Arc<T>;
|
||||
|
||||
/// Synchronized shared object.
|
||||
#[cfg(any(not(feature = "no_closure"), not(feature = "no_module")))]
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
#[cfg(not(feature = "sync"))]
|
||||
pub type Locked<T> = crate::stdlib::cell::RefCell<T>;
|
||||
/// Synchronized shared object.
|
||||
#[cfg(any(not(feature = "no_closure"), not(feature = "no_module")))]
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
#[cfg(feature = "sync")]
|
||||
pub type Locked<T> = crate::stdlib::sync::RwLock<T>;
|
||||
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -118,7 +118,7 @@ pub type FLOAT = f32;
|
||||
pub use ast::{FnAccess, AST};
|
||||
pub use dynamic::Dynamic;
|
||||
pub use engine::{Engine, EvalContext};
|
||||
pub use fn_native::{FnPtr, NativeCallContext};
|
||||
pub use fn_native::{FnPtr, NativeCallContext, Shared};
|
||||
pub use fn_register::{RegisterFn, RegisterResultFn};
|
||||
pub use module::{FnNamespace, Module};
|
||||
pub use parse_error::{LexError, ParseError, ParseErrorType};
|
||||
@ -128,8 +128,8 @@ pub use syntax::Expression;
|
||||
pub use token::Position;
|
||||
pub use utils::ImmutableString;
|
||||
|
||||
#[allow(dead_code)]
|
||||
use fn_native::{Locked, Shared};
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
use fn_native::Locked;
|
||||
|
||||
#[cfg(feature = "internals")]
|
||||
pub use utils::{calc_native_fn_hash, calc_script_fn_hash};
|
||||
@ -185,7 +185,11 @@ pub use ast::{
|
||||
|
||||
#[cfg(feature = "internals")]
|
||||
#[deprecated(note = "this type is volatile and may change")]
|
||||
pub use engine::{Imports, Limits, State as EvalState};
|
||||
pub use engine::{Imports, State as EvalState};
|
||||
|
||||
#[cfg(feature = "internals")]
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
pub use engine::Limits;
|
||||
|
||||
#[cfg(feature = "internals")]
|
||||
#[deprecated(note = "this type is volatile and may change")]
|
||||
|
@ -9,7 +9,7 @@ use crate::stdlib::{
|
||||
boxed::Box,
|
||||
collections::HashMap,
|
||||
fmt, format,
|
||||
iter::{empty, once},
|
||||
iter::empty,
|
||||
num::NonZeroUsize,
|
||||
ops::{Add, AddAssign, Deref, DerefMut},
|
||||
string::{String, ToString},
|
||||
@ -363,6 +363,8 @@ impl Module {
|
||||
// None + function name + number of arguments.
|
||||
let num_params = fn_def.params.len();
|
||||
let hash_script = crate::calc_script_fn_hash(empty(), &fn_def.name, num_params);
|
||||
let mut param_names: StaticVec<_> = fn_def.params.iter().cloned().collect();
|
||||
param_names.push("Dynamic".into());
|
||||
self.functions.insert(
|
||||
hash_script,
|
||||
FuncInfo {
|
||||
@ -371,14 +373,7 @@ impl Module {
|
||||
access: fn_def.access,
|
||||
params: num_params,
|
||||
param_types: None,
|
||||
param_names: Some(
|
||||
fn_def
|
||||
.params
|
||||
.iter()
|
||||
.cloned()
|
||||
.chain(once("Dynamic".into()))
|
||||
.collect(),
|
||||
),
|
||||
param_names: Some(param_names),
|
||||
func: fn_def.into(),
|
||||
},
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::stdlib::{
|
||||
boxed::Box, collections::HashMap, io::Error as IoError, path::PathBuf, string::String,
|
||||
};
|
||||
use crate::{Engine, EvalAltResult, Locked, Module, ModuleResolver, Position, Shared};
|
||||
use crate::{Engine, EvalAltResult, Module, ModuleResolver, Position, Shared};
|
||||
|
||||
/// Module resolution service that loads module script files from the file system.
|
||||
///
|
||||
@ -37,7 +37,11 @@ use crate::{Engine, EvalAltResult, Locked, Module, ModuleResolver, Position, Sha
|
||||
pub struct FileModuleResolver {
|
||||
path: PathBuf,
|
||||
extension: String,
|
||||
cache: Locked<HashMap<PathBuf, Shared<Module>>>,
|
||||
|
||||
#[cfg(not(feature = "sync"))]
|
||||
cache: crate::stdlib::cell::RefCell<HashMap<PathBuf, Shared<Module>>>,
|
||||
#[cfg(feature = "sync")]
|
||||
cache: crate::stdlib::sync::RwLock<HashMap<PathBuf, Shared<Module>>>,
|
||||
}
|
||||
|
||||
impl Default for FileModuleResolver {
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::plugin::*;
|
||||
use crate::stdlib::iter::empty;
|
||||
use crate::{calc_script_fn_hash, def_package, FnPtr, ImmutableString, NativeCallContext, INT};
|
||||
use crate::{def_package, FnPtr, ImmutableString, NativeCallContext};
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
@ -20,6 +19,8 @@ mod fn_ptr_functions {
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub mod functions {
|
||||
use crate::{calc_script_fn_hash, stdlib::iter::empty, INT};
|
||||
|
||||
#[rhai_fn(name = "is_anonymous", get = "is_anonymous")]
|
||||
pub fn is_anonymous(f: &mut FnPtr) -> bool {
|
||||
f.is_anonymous()
|
||||
|
@ -25,13 +25,16 @@ use crate::syntax::CustomSyntax;
|
||||
use crate::token::{is_keyword_function, is_valid_identifier, Token, TokenStream};
|
||||
use crate::utils::{get_hasher, StraightHasherBuilder};
|
||||
use crate::{
|
||||
calc_script_fn_hash, Dynamic, Engine, FnAccess, ImmutableString, LexError, ParseError,
|
||||
ParseErrorType, Position, Scope, StaticVec, AST,
|
||||
calc_script_fn_hash, Dynamic, Engine, ImmutableString, LexError, ParseError, ParseErrorType,
|
||||
Position, Scope, StaticVec, AST,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::FLOAT;
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
use crate::FnAccess;
|
||||
|
||||
type PERR = ParseErrorType;
|
||||
|
||||
type FunctionsLib = HashMap<u64, ScriptFnDef, StraightHasherBuilder>;
|
||||
|
Loading…
Reference in New Issue
Block a user