Skip to content

Commit 553d426

Browse files
committed
WIP assert_no_shims on more signatures
1 parent 7428b73 commit 553d426

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ wasm-bindgen = { path = '.' }
9090
wasm-bindgen-futures = { path = 'crates/futures' }
9191
js-sys = { path = 'crates/js-sys' }
9292
web-sys = { path = 'crates/web-sys' }
93+
94+
# TODO FITZGEN
95+
wasm-webidl-bindings = { path = '../wasm-webidl-bindings' }

crates/cli-support/src/js/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,8 @@ impl<'a> Context<'a> {
20012001
if assert_no_shim {
20022002
panic!(
20032003
"imported function was annotated with `#[wasm_bindgen(assert_no_shim)]` \
2004-
but we need to generate a JS shim for it"
2004+
but we need to generate a JS shim for it: {:?}",
2005+
import,
20052006
);
20062007
}
20072008

tests/wasm/no_shims.rs

+21
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ use wasm_bindgen_test::*;
3333
assert_eq(v, 'hello');
3434
return v;
3535
};
36+
37+
module.exports.MyNamespace = {};
38+
module.exports.MyNamespace.incoming_namespaced = function () { return 3.14; };
39+
module.exports.MyNamespace.outgoing_namespaced = function (pi) { assert_eq(3.14, pi); };
40+
41+
module.exports.incoming_bool = function () { return true; };
3642
")]
3743
extern "C" {
3844
#[wasm_bindgen(assert_no_shim)]
@@ -55,6 +61,14 @@ extern "C" {
5561
#[wasm_bindgen(assert_no_shim)]
5662
fn many(x: i32, y: f32, z: f64) -> i32;
5763

64+
#[wasm_bindgen(assert_no_shim, js_namespace = MyNamespace)]
65+
fn incoming_namespaced() -> f64;
66+
#[wasm_bindgen(assert_no_shim, js_namespace = MyNamespace)]
67+
fn outgoing_namespaced(x: f64);
68+
69+
#[wasm_bindgen(assert_no_shim)]
70+
fn incoming_bool() -> bool;
71+
5872
// Note that this should only skip the JS shim if we have anyref support
5973
// enabled.
6074
//
@@ -80,6 +94,13 @@ fn no_shims() {
8094
let w = many(x, y, z);
8195
assert_eq!(w, 42);
8296

97+
let pi = incoming_namespaced();
98+
assert_eq!(pi, 3.14);
99+
outgoing_namespaced(pi);
100+
101+
let b = incoming_bool();
102+
assert!(b);
103+
83104
let v = JsValue::from("hello");
84105
let vv = works_when_anyref_support_is_enabled(v.clone());
85106
assert_eq!(v, vv);

0 commit comments

Comments
 (0)