Support 8 argument closures.

This commit is contained in:
Richard Diamond 2019-02-17 11:00:52 -06:00
parent befefe0da6
commit 03218d9d3c
4 changed files with 21 additions and 0 deletions

View File

@ -695,6 +695,7 @@ doit! {
(A B C D E)
(A B C D E F)
(A B C D E F G)
(A B C D E F G H)
}
// Copy the above impls down here for where there's only one argument and it's a

View File

@ -117,6 +117,7 @@ stack_closures! {
(5 invoke5 invoke5_mut A B C D E)
(6 invoke6 invoke6_mut A B C D E F)
(7 invoke7 invoke7_mut A B C D E F G)
(8 invoke8 invoke8_mut A B C D E F G H)
}
impl<'a, 'b, A, R> IntoWasmAbi for &'a (Fn(&A) -> R + 'b)

View File

@ -47,6 +47,9 @@ exports.many_arity_call7 = a => {
exports.many_arity_call8 = a => {
a(1, 2, 3, 4, 5, 6, 7);
};
exports.many_arity_call9 = a => {
a(1, 2, 3, 4, 5, 6, 7, 8);
};
let LONG_LIVED_DROPPING_CACHE = null;

View File

@ -25,6 +25,7 @@ extern "C" {
fn many_arity_call6(a: &Closure<Fn(u32, u32, u32, u32, u32)>);
fn many_arity_call7(a: &Closure<Fn(u32, u32, u32, u32, u32, u32)>);
fn many_arity_call8(a: &Closure<Fn(u32, u32, u32, u32, u32, u32, u32)>);
fn many_arity_call9(a: &Closure<Fn(u32, u32, u32, u32, u32, u32, u32, u32)>);
#[wasm_bindgen(js_name = many_arity_call1)]
fn many_arity_call_mut1(a: &Closure<FnMut()>);
@ -42,6 +43,8 @@ extern "C" {
fn many_arity_call_mut7(a: &Closure<FnMut(u32, u32, u32, u32, u32, u32)>);
#[wasm_bindgen(js_name = many_arity_call8)]
fn many_arity_call_mut8(a: &Closure<FnMut(u32, u32, u32, u32, u32, u32, u32)>);
#[wasm_bindgen(js_name = many_arity_call9)]
fn many_arity_call_mut9(a: &Closure<FnMut(u32, u32, u32, u32, u32, u32, u32, u32)>);
#[wasm_bindgen(js_name = many_arity_call1)]
fn many_arity_stack1(a: &Fn());
@ -59,6 +62,8 @@ extern "C" {
fn many_arity_stack7(a: &Fn(u32, u32, u32, u32, u32, u32));
#[wasm_bindgen(js_name = many_arity_call8)]
fn many_arity_stack8(a: &Fn(u32, u32, u32, u32, u32, u32, u32));
#[wasm_bindgen(js_name = many_arity_call9)]
fn many_arity_stack9(a: &Fn(u32, u32, u32, u32, u32, u32, u32, u32));
fn long_lived_dropping_cache(a: &Closure<Fn()>);
#[wasm_bindgen(catch)]
@ -164,6 +169,9 @@ fn many_arity() {
many_arity_call8(&Closure::new(|a, b, c, d, e, f, g| {
assert_eq!((a, b, c, d, e, f, g), (1, 2, 3, 4, 5, 6, 7))
}));
many_arity_call9(&Closure::new(|a, b, c, d, e, f, g, h| {
assert_eq!((a, b, c, d, e, f, g, h), (1, 2, 3, 4, 5, 6, 7, 8))
}));
let s = String::new();
many_arity_call_mut1(&Closure::once(move || drop(s)));
@ -202,6 +210,11 @@ fn many_arity() {
drop(s);
assert_eq!((a, b, c, d, e, f, g), (1, 2, 3, 4, 5, 6, 7));
}));
let s = String::new();
many_arity_call_mut9(&Closure::once(move |a, b, c, d, e, f, g, h| {
drop(s);
assert_eq!((a, b, c, d, e, f, g, h), (1, 2, 3, 4, 5, 6, 7, 8));
}));
many_arity_stack1(&(|| {}));
many_arity_stack2(&(|a| assert_eq!(a, 1)));
@ -213,6 +226,9 @@ fn many_arity() {
many_arity_stack8(
&(|a, b, c, d, e, f, g| assert_eq!((a, b, c, d, e, f, g), (1, 2, 3, 4, 5, 6, 7))),
);
many_arity_stack9(
&(|a, b, c, d, e, f, g, h| assert_eq!((a, b, c, d, e, f, g, h), (1, 2, 3, 4, 5, 6, 7, 8))),
);
}
struct Dropper(Rc<Cell<bool>>);