#bindgen #macros #macro #attribute #internal #wasm-bindgen #modules #implementation #definition #high-level

macro wasm-bindgen-macro

Definition of the #[wasm_bindgen] attribute, an internal dependency

63 releases

✓ Uses Rust 2018 edition

new 0.2.60 Mar 26, 2020
0.2.58 Jan 7, 2020
0.2.56 Dec 20, 2019
0.2.55 Nov 19, 2019
0.1.1 Mar 6, 2018

#248 in WebAssembly

Download history 37996/week @ 2019-12-02 38257/week @ 2019-12-09 38212/week @ 2019-12-16 20927/week @ 2019-12-23 27649/week @ 2019-12-30 48462/week @ 2020-01-06 51522/week @ 2020-01-13 56979/week @ 2020-01-20 57678/week @ 2020-01-27 48669/week @ 2020-02-03 43860/week @ 2020-02-10 41823/week @ 2020-02-17 42905/week @ 2020-02-24 55349/week @ 2020-03-02 50681/week @ 2020-03-09 45879/week @ 2020-03-16

203,931 downloads per month
Used in 2,154 crates (via wasm-bindgen)

MIT/Apache

62KB
1.5K SLoC

wasm-bindgen-macro

Implementation of the #[wasm_bindgen] attribute. See the wasm-bindgen documentation for more information about what this macro does.

Testing

Testing of this macro is done through "ui tests" in the ui-tests subdirectory of this crate. Each Rust file in this folder is compiled with the wasm_bindgen crate, and the *.stderr file sitting next to it is the asserted output of the compiler. If the output matches, the test passes, and if the output doesn't match the test fails. Note that it is also considered a failure if a test actually compiles successfully.

To add a test:

  • Create ui-tests/my-awesome-test.rs
  • Write an invalid #[wasm_bindgen] invocation, testing the error you're generating
  • Execute cargo test -p ui-tests, the test will fail
  • From within the ui-tests folder, execute ./update-all-references.sh. This should create a my-awesome-test.stderr file.
  • Inspect my-awesome-test.stderr to make sure it looks ok
  • Rerun cargo test -p ui-tests and your tests should pass!

Testing here is a work in progress, see #601 for more information.

Dependencies

~0.8–1.2MB
~24K SLoC