mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Rename namespace
to js_namespace
Along the way remove the namespace in Rust as this ended up causing too many problems, alas! The `js_namespace` attribute now almost exclusively modifies the JS bindings, hence the "js" in the name now.
This commit is contained in:
@ -6,21 +6,21 @@ use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
#[wasm_bindgen(namespace = Math)]
|
||||
#[wasm_bindgen(js_namespace = Math)]
|
||||
fn log2(a: f64) -> f64;
|
||||
#[wasm_bindgen(namespace = Math)]
|
||||
#[wasm_bindgen(js_namespace = Math)]
|
||||
fn sin(a: f64) -> f64;
|
||||
|
||||
#[wasm_bindgen(namespace = console)]
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(a: &str);
|
||||
}
|
||||
|
||||
macro_rules! println {
|
||||
($($t:tt)*) => (console::log(&format_args!($($t)*).to_string()))
|
||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() {
|
||||
println!("Math.log2(10.0) = {}", Math::log2(10.0));
|
||||
println!("Math.sin(1.2) = {}", Math::sin(1.2));
|
||||
println!("Math.log2(10.0) = {}", log2(10.0));
|
||||
println!("Math.sin(1.2) = {}", sin(1.2));
|
||||
}
|
||||
|
Reference in New Issue
Block a user