Allow exporting function pointers from modules.

This commit is contained in:
Stephen Chung
2022-12-12 18:31:02 +08:00
parent ec5ad320a1
commit d350a948e7
5 changed files with 72 additions and 66 deletions

View File

@@ -781,7 +781,7 @@ impl Engine {
caches,
&mut Scope::new(),
&mut this_ptr,
None,
fn_ptr.encapsulated_environ(),
fn_def,
args,
true,
@@ -834,15 +834,15 @@ impl Engine {
let fn_ptr = mem::take(&mut call_args[0]).cast::<FnPtr>();
#[cfg(not(feature = "no_function"))]
let (fn_name, is_anon, fn_curry, fn_def) = {
let (fn_name, is_anon, fn_curry, environ, fn_def) = {
let is_anon = fn_ptr.is_anonymous();
let (fn_name, fn_curry, fn_def) = fn_ptr.take_data();
(fn_name, is_anon, fn_curry, fn_def)
let (fn_name, fn_curry, environ, fn_def) = fn_ptr.take_data();
(fn_name, is_anon, fn_curry, environ, fn_def)
};
#[cfg(feature = "no_function")]
let (fn_name, is_anon, fn_curry) = {
let (fn_name, fn_curry) = fn_ptr.take_data();
(fn_name, false, fn_curry)
let (fn_name, is_anon, environ, fn_curry) = {
let (fn_name, fn_curry, environ) = fn_ptr.take_data();
(fn_name, false, fn_curry, environ)
};
// Replace the first argument with the object pointer, adding the curried arguments
@@ -868,7 +868,7 @@ impl Engine {
caches,
&mut Scope::new(),
target,
None,
environ.as_deref(),
&fn_def,
args,
true,
@@ -1043,15 +1043,15 @@ impl Engine {
let fn_ptr = arg_value.cast::<FnPtr>();
#[cfg(not(feature = "no_function"))]
let (fn_name, is_anon, fn_curry, fn_def) = {
let (fn_name, is_anon, fn_curry, environ, fn_def) = {
let is_anon = fn_ptr.is_anonymous();
let (fn_name, fn_curry, fn_def) = fn_ptr.take_data();
(fn_name, is_anon, fn_curry, fn_def)
let (fn_name, fn_curry, environ, fn_def) = fn_ptr.take_data();
(fn_name, is_anon, fn_curry, environ, fn_def)
};
#[cfg(feature = "no_function")]
let (fn_name, is_anon, fn_curry) = {
let (fn_name, fn_curry) = fn_ptr.take_data();
(fn_name, false, fn_curry)
let (fn_name, is_anon, fn_curry, environ) = {
let (fn_name, fn_curry, environ) = fn_ptr.take_data();
(fn_name, false, fn_curry, environ)
};
curry.extend(fn_curry.into_iter());
@@ -1077,7 +1077,7 @@ impl Engine {
caches,
&mut Scope::new(),
&mut this_ptr,
None,
environ.as_deref(),
&fn_def,
args,
true,