Level up exports.
This commit is contained in:
parent
98707912e0
commit
2fffe31b59
@ -4,8 +4,8 @@ Rhai Release Notes
|
||||
Version 1.2.0
|
||||
=============
|
||||
|
||||
Breaking changes for scripts
|
||||
---------------------------
|
||||
Bug fixes with breaking script changes
|
||||
-------------------------------------
|
||||
|
||||
* As originally intended, function calls with a bang (`!`) now operates directly on the caller's scope, allowing variables inside the scope to be mutated.
|
||||
* As originally intended, `Engine::XXX_with_scope` API's now properly propagate constants within the provided scope also to _functions_ in the script.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Module that defines the public API of [`Engine`].
|
||||
|
||||
use crate::engine::{EvalContext, EvalState, Imports};
|
||||
use crate::func::{call::FnCallArgs, native::SendSync, register::RegisterNativeFunction};
|
||||
use crate::func::{FnCallArgs, RegisterNativeFunction, SendSync};
|
||||
use crate::parser::ParseState;
|
||||
use crate::types::dynamic::Variant;
|
||||
use crate::{
|
||||
|
@ -3,11 +3,9 @@
|
||||
use crate::ast::{Expr, FnCallExpr, Ident, OpAssignment, Stmt, AST_OPTION_FLAGS::*};
|
||||
use crate::custom_syntax::CustomSyntax;
|
||||
use crate::func::{
|
||||
hashing::get_hasher,
|
||||
native::{
|
||||
CallableFunction, IteratorFn, OnDebugCallback, OnParseTokenCallback, OnPrintCallback,
|
||||
OnVarCallback,
|
||||
},
|
||||
get_hasher,
|
||||
native::{OnDebugCallback, OnParseTokenCallback, OnPrintCallback, OnVarCallback},
|
||||
CallableFunction, IteratorFn,
|
||||
};
|
||||
use crate::module::NamespaceRef;
|
||||
use crate::packages::{Package, StandardPackage};
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Implement function-calling mechanism for [`Engine`].
|
||||
|
||||
use super::builtin::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
||||
use super::native::{CallableFunction, FnAny};
|
||||
use super::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
||||
use crate::ast::FnCallHashes;
|
||||
use crate::engine::{
|
||||
EvalState, FnResolutionCacheEntry, Imports, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR,
|
||||
|
@ -14,7 +14,7 @@ use std::{
|
||||
///
|
||||
/// Panics when hashing any data type other than a [`u64`].
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub struct StraightHasher(u64);
|
||||
struct StraightHasher(u64);
|
||||
|
||||
impl Hasher for StraightHasher {
|
||||
#[inline(always)]
|
||||
@ -34,7 +34,7 @@ impl Hasher for StraightHasher {
|
||||
|
||||
/// A hash builder for `StraightHasher`.
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
|
||||
pub struct StraightHasherBuilder;
|
||||
struct StraightHasherBuilder;
|
||||
|
||||
impl BuildHasher for StraightHasherBuilder {
|
||||
type Hasher = StraightHasher;
|
||||
@ -135,6 +135,6 @@ pub fn calc_fn_params_hash(params: impl Iterator<Item = TypeId>) -> u64 {
|
||||
/// Combine two [`u64`] hashes by taking the XOR of them.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) const fn combine_hashes(a: u64, b: u64) -> u64 {
|
||||
pub const fn combine_hashes(a: u64, b: u64) -> u64 {
|
||||
a ^ b
|
||||
}
|
||||
|
@ -8,3 +8,18 @@ pub mod hashing;
|
||||
pub mod native;
|
||||
pub mod plugin;
|
||||
pub mod register;
|
||||
|
||||
pub use args::FuncArgs;
|
||||
pub use builtin::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
||||
pub use call::FnCallArgs;
|
||||
pub use func::Func;
|
||||
pub use hashing::{
|
||||
calc_fn_hash, calc_fn_params_hash, calc_qualified_fn_hash, calc_qualified_var_hash,
|
||||
combine_hashes, get_hasher,
|
||||
};
|
||||
pub use native::{
|
||||
shared_make_mut, shared_take, shared_take_or_clone, shared_try_take, shared_write_lock,
|
||||
CallableFunction, FnAny, FnPlugin, IteratorFn, Locked, NativeCallContext, SendSync, Shared,
|
||||
};
|
||||
pub use plugin::PluginFunction;
|
||||
pub use register::RegisterNativeFunction;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Module defining macros for developing _plugins_.
|
||||
|
||||
use super::call::FnCallArgs;
|
||||
pub use super::native::CallableFunction;
|
||||
pub use super::CallableFunction;
|
||||
use super::FnCallArgs;
|
||||
pub use crate::{
|
||||
Dynamic, Engine, EvalAltResult, FnAccess, FnNamespace, ImmutableString, Module,
|
||||
NativeCallContext, Position,
|
||||
@ -9,6 +9,7 @@ pub use crate::{
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
pub use std::{any::TypeId, mem};
|
||||
|
||||
pub type RhaiResult = Result<Dynamic, Box<EvalAltResult>>;
|
||||
|
||||
#[cfg(not(features = "no_module"))]
|
||||
|
17
src/lib.rs
17
src/lib.rs
@ -119,16 +119,11 @@ pub type FLOAT = f32;
|
||||
pub use ast::{FnAccess, AST};
|
||||
pub use custom_syntax::Expression;
|
||||
pub use engine::{Engine, EvalContext, OP_CONTAINS, OP_EQUALS};
|
||||
pub use func::{native::NativeCallContext, register::RegisterNativeFunction};
|
||||
pub use func::{NativeCallContext, RegisterNativeFunction};
|
||||
pub use module::{FnNamespace, Module};
|
||||
pub use tokenizer::Position;
|
||||
pub use types::{
|
||||
dynamic::Dynamic,
|
||||
error::EvalAltResult,
|
||||
fn_ptr::FnPtr,
|
||||
immutable_string::ImmutableString,
|
||||
parse_error::{LexError, ParseError, ParseErrorType},
|
||||
scope::Scope,
|
||||
Dynamic, EvalAltResult, FnPtr, ImmutableString, LexError, ParseError, ParseErrorType, Scope,
|
||||
};
|
||||
|
||||
/// An identifier in Rhai. [`SmartString`](https://crates.io/crates/smartstring) is used because most
|
||||
@ -156,12 +151,12 @@ pub type Identifier = SmartString;
|
||||
pub type Identifier = ImmutableString;
|
||||
|
||||
/// Alias to [`Rc`][std::rc::Rc] or [`Arc`][std::sync::Arc] depending on the `sync` feature flag.
|
||||
pub use func::native::Shared;
|
||||
pub use func::Shared;
|
||||
|
||||
/// Alias to [`RefCell`][std::cell::RefCell] or [`RwLock`][std::sync::RwLock] depending on the `sync` feature flag.
|
||||
pub use func::native::Locked;
|
||||
pub use func::Locked;
|
||||
|
||||
pub(crate) use func::hashing::{
|
||||
pub(crate) use func::{
|
||||
calc_fn_hash, calc_fn_params_hash, calc_qualified_fn_hash, calc_qualified_var_hash,
|
||||
combine_hashes,
|
||||
};
|
||||
@ -171,7 +166,7 @@ pub use rhai_codegen::*;
|
||||
pub use func::plugin;
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use func::{args::FuncArgs, func::Func};
|
||||
pub use func::{Func, FuncArgs};
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use ast::ScriptFnMetadata;
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use crate::ast::{FnAccess, Ident};
|
||||
use crate::func::{
|
||||
call::FnCallArgs,
|
||||
native::{shared_take_or_clone, CallableFunction, IteratorFn, SendSync},
|
||||
register::RegisterNativeFunction,
|
||||
shared_take_or_clone, CallableFunction, FnCallArgs, IteratorFn, RegisterNativeFunction,
|
||||
SendSync,
|
||||
};
|
||||
use crate::parser::IdentifierBuilder;
|
||||
use crate::tokenizer::Token;
|
||||
|
@ -6,3 +6,10 @@ pub mod fn_ptr;
|
||||
pub mod immutable_string;
|
||||
pub mod parse_error;
|
||||
pub mod scope;
|
||||
|
||||
pub use dynamic::Dynamic;
|
||||
pub use error::EvalAltResult;
|
||||
pub use fn_ptr::FnPtr;
|
||||
pub use immutable_string::ImmutableString;
|
||||
pub use parse_error::{LexError, ParseError, ParseErrorType};
|
||||
pub use scope::Scope;
|
||||
|
Loading…
Reference in New Issue
Block a user