Open Tadeuchi opened 3 months ago
Hi, I'm also seeing the same thing. When I log the length of the arraybuffer created using vm.newArrayBuffer, it shows as undefined in the output of vm.evalCode.
It can be easily recreated in the browser like so:
<!doctype html>
<script type="module">
import { getQuickJS } from "https://esm.sh/quickjs-emscripten@0.29.1"
const QuickJS = await getQuickJS()
const vm = QuickJS.newContext()
const string = '12'
const arrayBuffer = new Uint8Array([1, 2]).buffer
console.log('string.length', string.length)
console.log('arrayBuffer.length', arrayBuffer.byteLength)
const vmString = vm.newString(string)
const vmArrayBuffer = vm.newArrayBuffer(arrayBuffer)
vm.setProp(vm.global, 'vmString', vmString)
vm.setProp(vm.global, 'vmArrayBuffer', vmArrayBuffer)
console.log('vmString.length', vm.dump(vm.evalCode('vmString.length').value))
console.log('vmArrayBuffer.length', vm.dump(vm.evalCode('vmArrayBuffer.length').value))
vmString.dispose()
vmArrayBuffer.dispose()
vm.dispose()
</script>
Output:
string.length 2
arrayBuffer.length 2
vmString.length 2
vmArrayBuffer.length undefined
Hi,
I'm having troubles with passing array buffer. I followed the first example in the readme, but with additional code to handle array buffer. And then tried doing some modifications, but... every time the results are mostly undefined... That leads me to conclusion that I must be doing something wrong (very likely) or there may be an implementation issue?
Following code
produces following result