diff --git a/src/fn_call.rs b/src/fn_call.rs index 437a86dc..62c2ca28 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -193,11 +193,9 @@ impl Engine { // Search for the native function // First search registered functions (can override packages) // Then search packages - let func = self - .global_module - .get_fn(hash_fn, pub_only) - .or_else(|| lib.get_fn(hash_fn, pub_only)) - .or_else(|| self.packages.get_fn(hash_fn, pub_only)); + let func = //lib.get_fn(hash_fn, pub_only) + self.global_module.get_fn(hash_fn, pub_only) + .or_else(|| self.packages.get_fn(hash_fn, pub_only)); if let Some(func) = func { assert!(func.is_native()); @@ -462,9 +460,9 @@ impl Engine { // First check script-defined functions lib.contains_fn(hash_script, pub_only) - || lib.contains_fn(hash_fn, pub_only) + //|| lib.contains_fn(hash_fn, pub_only) // Then check registered functions - || self.global_module.contains_fn(hash_script, pub_only) + //|| self.global_module.contains_fn(hash_script, pub_only) || self.global_module.contains_fn(hash_fn, pub_only) // Then check packages || self.packages.contains_fn(hash_script, pub_only) @@ -547,15 +545,14 @@ impl Engine { // Script-like function found #[cfg(not(feature = "no_function"))] - _ if self.global_module.contains_fn(hash_script, pub_only) - || lib.contains_fn(hash_script, pub_only) + _ if lib.contains_fn(hash_script, pub_only) + //|| self.global_module.contains_fn(hash_script, pub_only) || self.packages.contains_fn(hash_script, pub_only) => { // Get function - let func = self - .global_module + let func = lib .get_fn(hash_script, pub_only) - .or_else(|| lib.get_fn(hash_script, pub_only)) + //.or_else(|| self.global_module.get_fn(hash_script, pub_only)) .or_else(|| self.packages.get_fn(hash_script, pub_only)) .unwrap(); diff --git a/src/module/mod.rs b/src/module/mod.rs index afa82cfe..566b678d 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -549,36 +549,6 @@ impl Module { ) } - /// Set a raw function but with a signature that is a scripted function (meaning that the types - /// are not determined), but the implementation is in Rust. - #[cfg(not(feature = "no_function"))] - #[cfg(not(feature = "no_module"))] - #[inline] - #[allow(dead_code)] - pub(crate) fn set_raw_fn_as_scripted( - &mut self, - name: impl Into, - num_params: usize, - func: impl Fn(&Engine, &Module, &mut [&mut Dynamic]) -> FuncReturn + SendSync + 'static, - ) -> u64 { - // None + function name + number of arguments. - let name = name.into(); - let hash_script = calc_fn_hash(empty(), &name, num_params, empty()); - let f = move |engine: &Engine, lib: &Module, args: &mut FnCallArgs| func(engine, lib, args); - self.functions.insert( - hash_script, - ( - name, - FnAccess::Public, - num_params, - None, - CallableFunction::from_pure(Box::new(f)), - ), - ); - self.indexed = false; - hash_script - } - /// Set a Rust function taking no parameters into the module, returning a hash key. /// /// If there is a similar existing Rust function, it is replaced.