From 9cc2841cf49a6180dc9426892d11e957142e88ea Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Wed, 22 May 2019 20:55:43 +0200 Subject: Play around with wasm --- WebInterface/wasm/asm-paint/loader.js | 5 +++-- WebInterface/wasm/asm-paint/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WebInterface/wasm/asm-paint/loader.js b/WebInterface/wasm/asm-paint/loader.js index 8348c35..7313fa0 100644 --- a/WebInterface/wasm/asm-paint/loader.js +++ b/WebInterface/wasm/asm-paint/loader.js @@ -1,5 +1,6 @@ console.log('js> create import object'); -let importObject = { imports: { imported_func: arg => console.log(arg) } }; +let importObject = { imports: { my_alert: arg => alert(arg) } }; +//let importObject = {}; console.log('js> create fetch object'); @@ -9,7 +10,7 @@ console.log('js> instantiate streaming'); function and_then(obj) { console.log('js> reached instantiate streaming\'s then'); - return obj.instance.exports.exported_func(); + return obj.instance.exports.greet(); } WebAssembly.instantiateStreaming(asm_paint_bg, importObject) diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs index 908b857..a4f4f54 100644 --- a/WebInterface/wasm/asm-paint/src/lib.rs +++ b/WebInterface/wasm/asm-paint/src/lib.rs @@ -10,10 +10,10 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] extern { - fn log(s: &str); + fn my_alert(s: &str); } #[wasm_bindgen] pub fn greet() { - log("Hello, asm-paint!"); + my_alert("Hello, asm-paint!"); } -- cgit v1.2.3-54-g00ecf