mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-15 04:23:12 +03:00
3d43d6e5e8
Run exports through the same identifier generation as imports to ensure that everything gets a unique identifier and then just make sure all the appropriate wires are hooked up when dealing with exports and imports. Closes #1496
33 lines
655 B
Rust
33 lines
655 B
Rust
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen_test::*;
|
|
|
|
#[wasm_bindgen(module = "tests/wasm/structural.js")]
|
|
extern "C" {
|
|
fn js_works();
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
extern "C" {
|
|
pub type StructuralFoo;
|
|
|
|
#[wasm_bindgen(method, structural)]
|
|
fn bar(this: &StructuralFoo);
|
|
#[wasm_bindgen(method, getter, structural)]
|
|
fn baz(this: &StructuralFoo) -> u32;
|
|
#[wasm_bindgen(method, setter, structural)]
|
|
fn set_baz(this: &StructuralFoo, val: u32);
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn run(a: &StructuralFoo) {
|
|
a.bar();
|
|
assert_eq!(a.baz(), 1);
|
|
a.set_baz(2);
|
|
assert_eq!(a.baz(), 2);
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn works() {
|
|
js_works();
|
|
}
|