Open taylorh140 opened 1 year ago
You are right. I reproduced this issue with nodejs, but I'm not yet able to identify the cause of the problem.
const fs = require('fs')
const wasmBuffer = fs.readFileSync('/tmp/pikchrNoImp.wasm')
WebAssembly.instantiate(wasmBuffer).then(wasmModule => {
const { stackAlloc, pikchr, memory } = wasmModule.instance.exports
const dataView = new Uint8Array(memory.buffer)
write_c_string = (s) => {
let ptr = stackAlloc(s.length + 1)
let idx = ptr
for (let i in s.slice()) {
dataView[idx] = s[i].charCodeAt(0)
idx += 1
}
dataView[idx] = 0
return ptr
}
get_c_string = (ptr) => {
let idx = ptr
let buf = []
while (dataView[idx] !== undefined && dataView[idx] !== 0) {
buf.push(String.fromCharCode(dataView[idx]))
idx += 1
}
return buf.join('')
}
in1 = write_c_string(`arrow right 200% "Markdown" "Source"
box rad 10px "Markdown" "Formatter" "(markdown.c)" fit
arrow right 200% "HTML+SVG" "Output"
arrow <-> down 70% from last box.s
box same "Pikchr" "Formatter" "(pikchr.c)" fit`)
console.log('in1 =', in1)
console.log('raw =', get_c_string(in1))
let in2 = pikchr(in1, 0, 0, 0, 0)
console.log('in2 =', in2)
console.log('out =', get_c_string(in2))
});
I was playing around with wasmer and saw this implmentation I like portable stuff so i tried it. but for some reason it doesnt behave quite the same as wasmer. I get different images.
pikchrNoImp.zip
wasmer setup
pywasm setup
I have no idea why they would have different results? maybe math issue?