Fix builds.
This commit is contained in:
parent
1f815f995f
commit
2c55c248fb
@ -271,6 +271,14 @@ impl<'a> NativeCallContext<'a> {
|
|||||||
pub const fn global_runtime_state(&self) -> &GlobalRuntimeState {
|
pub const fn global_runtime_state(&self) -> &GlobalRuntimeState {
|
||||||
self.global
|
self.global
|
||||||
}
|
}
|
||||||
|
/// _(internals)_ The current [`GlobalRuntimeState`], if any.
|
||||||
|
#[cfg(not(feature = "internals"))]
|
||||||
|
#[inline(always)]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) const fn global_runtime_state(&self) -> &GlobalRuntimeState {
|
||||||
|
self.global
|
||||||
|
}
|
||||||
/// Get an iterator over the namespaces containing definitions of all script-defined functions
|
/// Get an iterator over the namespaces containing definitions of all script-defined functions
|
||||||
/// in reverse order (i.e. parent namespaces are iterated after child namespaces).
|
/// in reverse order (i.e. parent namespaces are iterated after child namespaces).
|
||||||
///
|
///
|
||||||
|
@ -35,16 +35,20 @@ fn make_dual_arity_fn_ptr_call<const N: usize>(
|
|||||||
items: [Dynamic; N],
|
items: [Dynamic; N],
|
||||||
number: usize,
|
number: usize,
|
||||||
) -> RhaiResult {
|
) -> RhaiResult {
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
|
{
|
||||||
let arity = fn_ptr.fn_def().map(|f| f.params.len()).unwrap_or(0);
|
let arity = fn_ptr.fn_def().map(|f| f.params.len()).unwrap_or(0);
|
||||||
|
|
||||||
if arity == N {
|
if arity == N {
|
||||||
fn_ptr.call_raw(&ctx, None, items)
|
return fn_ptr.call_raw(&ctx, None, items);
|
||||||
} else if arity == N + 1 {
|
} else if arity == N + 1 {
|
||||||
let mut items2 = crate::StaticVec::new_const();
|
let mut items2 = crate::StaticVec::new_const();
|
||||||
items2.extend(IntoIterator::into_iter(items));
|
items2.extend(IntoIterator::into_iter(items));
|
||||||
items2.push((number as INT).into());
|
items2.push((number as INT).into());
|
||||||
fn_ptr.call_raw(&ctx, None, items2)
|
return fn_ptr.call_raw(&ctx, None, items2);
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn_ptr
|
fn_ptr
|
||||||
.call_raw(&ctx, None, items.clone())
|
.call_raw(&ctx, None, items.clone())
|
||||||
.or_else(|err| match *err {
|
.or_else(|err| match *err {
|
||||||
@ -64,7 +68,6 @@ fn make_dual_arity_fn_ptr_call<const N: usize>(
|
|||||||
Position::NONE,
|
Position::NONE,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[export_module]
|
#[export_module]
|
||||||
@ -1590,7 +1593,13 @@ pub mod array_functions {
|
|||||||
.rev()
|
.rev()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.try_fold(initial, |result, (i, item)| {
|
.try_fold(initial, |result, (i, item)| {
|
||||||
make_dual_arity_fn_ptr_call("reduce_rev", &reducer, &ctx, [result, item.clone()], array.len() - 1 - i)
|
make_dual_arity_fn_ptr_call(
|
||||||
|
"reduce_rev",
|
||||||
|
&reducer,
|
||||||
|
&ctx,
|
||||||
|
[result, item.clone()],
|
||||||
|
array.len() - 1 - i,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/// Reduce an array by iterating through all elements, in _reverse_ order,
|
/// Reduce an array by iterating through all elements, in _reverse_ order,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! The `FnPtr` type.
|
//! The `FnPtr` type.
|
||||||
|
|
||||||
use crate::eval::{Caches, GlobalRuntimeState};
|
use crate::eval::GlobalRuntimeState;
|
||||||
use crate::tokenizer::is_valid_function_name;
|
use crate::tokenizer::is_valid_function_name;
|
||||||
use crate::types::dynamic::Variant;
|
use crate::types::dynamic::Variant;
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -282,7 +282,7 @@ impl FnPtr {
|
|||||||
let global = &mut context.global_runtime_state().clone();
|
let global = &mut context.global_runtime_state().clone();
|
||||||
global.level += 1;
|
global.level += 1;
|
||||||
|
|
||||||
let caches = &mut Caches::new();
|
let caches = &mut crate::eval::Caches::new();
|
||||||
let mut null_ptr = Dynamic::NULL;
|
let mut null_ptr = Dynamic::NULL;
|
||||||
|
|
||||||
return context.engine().call_script_fn(
|
return context.engine().call_script_fn(
|
||||||
|
Loading…
Reference in New Issue
Block a user