From 864ce16bf2158cfe087c1f70cc18c9740c9a3a75 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 8 Jul 2021 00:32:54 +0100 Subject: [PATCH] jstest: wip, it runs, with the runes in the comments, as a bodge Signed-off-by: Ian Jackson --- wasmtest.nodejs | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/wasmtest.nodejs b/wasmtest.nodejs index 8bedc295..a0d93e4f 100644 --- a/wasmtest.nodejs +++ b/wasmtest.nodejs @@ -1,26 +1,23 @@ +// +// nailing-cargo --just-run -q --- /home/ian/Rustup/Game/Build/server/target/debug/wasm-bindgen --remove-name-section --remove-producers-section --typescript --nodejs --out-dir target/packed-wasm target/wasm32-unknown-unknown/release/otter_wasm.wasm + +//// +// rustcargo@zealot:/home/ian/Rustup/Game/Build/server$ NODE_PATH=$PWD/target/packed-wasm sh -xec "cd target/packed-wasm && cp ~ian/Rustup/Game/server/wasmtest.nodejs . && nodejs wasmtest.nodejs" +// g000000000 + const fs = require('fs'); +//eval(fs.readFileSync('./otter_wasm.js')+''); +let wasm_bindgen = require('otter_wasm.js'); //var source = fs.readFileSync('./target/packed-wasm/otter_wasm_bg.wasm'); -var source = fs.readFileSync('./target/wasm32-unknown-unknown/release/otter_wasm.wasm'); -var typedArray = new Uint8Array(source); -const env = { - memoryBase: 0, - tableBase: 0, - memory: new WebAssembly.Memory({ - initial: 256 - }), - table: new WebAssembly.Table({ - initial: 0, - element: 'anyfunc' - }) - } - -WebAssembly.instantiate(typedArray, { - env: env -}).then(result => { - console.log(util.inspect(result, true, 0)); - console.log(result.instance.exports._add(9, 9)); -}).catch(e => { - // error caught - console.log(e); - console.log(e.stack); -}); +//var source = fs.readFileSync('./target/wasm32-unknown-unknown/release/otter_wasm.wasm'); +//var source = fs.readFileSync('./otter_wasm_bg.wasm'); +//wasm_bindgen(source).then(result => { +// console.log(util.inspect(result, true, 0)); +// console.log(result.instance.exports._add(9, 9)); +//}).catch(e => { +// // error caught +// console.log(e); +// console.log(e.stack); +//}); +let dc = wasm_bindgen.def_zcoord(); +console.log(dc); -- 2.30.2