WebAssemblyでScratchプラグインを作ろう!
ブラウザから呼び出す
const obj = {};
WebAssembly.instantiateStreaming(fetch("./string1.wasm"), obj).then(
(wasm) => {
let offset = wasm.instance.exports.__heap_base;
let length = 12;
let memory = wasm.instance.exports.memory;
let buffer = new Uint8Array(memory.buffer, offset, length);
wasm.instance.exports.hello_by_buflen(offset, length);
let msg = String.fromCharCode.apply(null, buffer);
console.log(msg);
},
);