Fix no_function.
This commit is contained in:
parent
4be8062924
commit
257991ca31
@ -304,7 +304,7 @@ impl Engine {
|
||||
};
|
||||
|
||||
// Add the global namespace module
|
||||
let mut global_namespace = Module::new();
|
||||
let mut global_namespace = Module::with_capacity(0);
|
||||
global_namespace.internal = true;
|
||||
engine.global_modules.push(global_namespace.into());
|
||||
|
||||
|
@ -270,27 +270,10 @@ impl Module {
|
||||
/// module.set_var("answer", 42_i64);
|
||||
/// assert_eq!(module.get_var_value::<i64>("answer").expect("answer should exist"), 42);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
id: Identifier::new_const(),
|
||||
#[cfg(feature = "metadata")]
|
||||
doc: crate::SmartString::new_const(),
|
||||
internal: false,
|
||||
standard: false,
|
||||
custom_types: None,
|
||||
modules: None,
|
||||
variables: None,
|
||||
all_variables: None,
|
||||
functions: StraightHashMap::default(),
|
||||
all_functions: None,
|
||||
dynamic_functions: BloomFilterU64::new(),
|
||||
type_iterators: None,
|
||||
all_type_iterators: None,
|
||||
indexed: true,
|
||||
contains_indexed_global_functions: false,
|
||||
}
|
||||
Self::with_capacity(16)
|
||||
}
|
||||
/// Create a new [`Module`] with a pre-sized capacity for functions.
|
||||
///
|
||||
@ -486,7 +469,7 @@ impl Module {
|
||||
#[inline(always)]
|
||||
pub fn set_custom_type<T>(&mut self, name: &str) -> &mut Self {
|
||||
self.custom_types
|
||||
.get_or_insert_with(|| Default::default())
|
||||
.get_or_insert_with(CustomTypesCollection::new)
|
||||
.add_type::<T>(name);
|
||||
self
|
||||
}
|
||||
@ -512,7 +495,7 @@ impl Module {
|
||||
name: impl Into<Identifier>,
|
||||
) -> &mut Self {
|
||||
self.custom_types
|
||||
.get_or_insert_with(|| Default::default())
|
||||
.get_or_insert_with(CustomTypesCollection::new)
|
||||
.add(type_name, name);
|
||||
self
|
||||
}
|
||||
@ -1752,7 +1735,7 @@ impl Module {
|
||||
if let Some(ref mut m) = self.modules {
|
||||
m.extend(modules.iter().map(|(k, v)| (k.clone(), v.clone())));
|
||||
} else {
|
||||
m = modules.clone();
|
||||
self.modules = Some(modules.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::def_package;
|
||||
use crate::plugin::*;
|
||||
use crate::types::dynamic::Tag;
|
||||
use crate::{Dynamic, RhaiResultOf, ERR, INT, MAX_USIZE_INT};
|
||||
use crate::{Dynamic, RhaiResultOf, ERR, INT};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
@ -113,7 +113,7 @@ mod reflection_functions {
|
||||
}
|
||||
#[rhai_fn(name = "get_fn_metadata_list")]
|
||||
pub fn get_fn_metadata2(ctx: NativeCallContext, name: &str, params: INT) -> crate::Array {
|
||||
if params < 0 || params > MAX_USIZE_INT {
|
||||
if params < 0 || params > crate::MAX_USIZE_INT {
|
||||
crate::Array::new()
|
||||
} else {
|
||||
collect_fn_metadata(ctx, |_, _, n, p, _| p == (params as usize) && n == name)
|
||||
|
@ -29,11 +29,6 @@ impl CustomTypesCollection {
|
||||
pub fn new() -> Self {
|
||||
Self(BTreeMap::new())
|
||||
}
|
||||
/// Clear the [`CustomTypesCollection`].
|
||||
#[inline(always)]
|
||||
pub fn clear(&mut self) {
|
||||
self.0.clear();
|
||||
}
|
||||
/// Register a custom type.
|
||||
#[inline(always)]
|
||||
pub fn add(&mut self, type_name: impl Into<Identifier>, name: impl Into<Identifier>) {
|
||||
|
Loading…
Reference in New Issue
Block a user