mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-01 23:04:36 +03:00
02b7021053
This commit leverages two new attributes in the Rust compiler, `#[wasm_custom_section]` and `#[wasm_import_module]`. These two attributes allow removing a lot of hacks found in wasm-bindgen and also allows removing the requirement of `wasm-opt` to remove the unused data sections. This does require two new nightly features but we already required the `proc_macro` nightly feature and these will hopefully be stabilized before that feature!
78 lines
2.1 KiB
Rust
78 lines
2.1 KiB
Rust
extern crate test_support;
|
|
|
|
#[test]
|
|
fn auto_bind_math() {
|
|
test_support::project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro, wasm_custom_section)]
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn math(a: f32, b: f64) -> f64 {
|
|
b.acos() +
|
|
b.asin() +
|
|
b.atan() +
|
|
b.atan2(b) +
|
|
b.cbrt() +
|
|
b.cosh() +
|
|
b.exp_m1() +
|
|
b.ln_1p() +
|
|
b.sinh() +
|
|
b.tan() +
|
|
b.tanh() +
|
|
b.hypot(b) +
|
|
b.cos() +
|
|
b.exp() +
|
|
b.exp2() +
|
|
b.mul_add(b, b) +
|
|
b.ln() +
|
|
b.log(b) +
|
|
b.log10() +
|
|
b.log2() +
|
|
b.powi(8) +
|
|
b.powf(b) +
|
|
b.round() +
|
|
b.sin() +
|
|
b.abs() +
|
|
b.signum() +
|
|
b.floor() +
|
|
b.ceil() +
|
|
b.trunc() +
|
|
b.sqrt() +
|
|
(b % (a as f64)) +
|
|
((a.cos() +
|
|
a.exp() +
|
|
a.exp2() +
|
|
a.mul_add(a, a) +
|
|
a.ln() +
|
|
a.log(a) +
|
|
a.log10() +
|
|
a.log2() +
|
|
a.powi(8) +
|
|
a.powf(a) +
|
|
a.round() +
|
|
a.sin() +
|
|
a.abs() +
|
|
a.signum() +
|
|
a.floor() +
|
|
a.ceil() +
|
|
a.trunc() +
|
|
a.sqrt() +
|
|
(a % (b as f32))) as f64) +
|
|
(b + 2.0f64.powf(a as f64))
|
|
}
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import { math } from "./out";
|
|
|
|
export function test() {
|
|
math(1.0, 2.0);
|
|
}
|
|
"#)
|
|
.test();
|
|
}
|
|
|