I need to create an ArrayBufferView (exactly Uint8Array) on an existing ArrayBuffer. I couldn’t find the type in RemObjects.Elements.WebAssembly.DOM (there is ArrayBufferView but it’s just an empty interface) so I attempted to create it “manually” using RemObjects.Elements.System.WebAssembly.ReflectConstruct. I pass ‘Uint8Array’ string and an array with the ArrayBuffer object as the constructor arguments. The object is created but the length is different from ArrayBuffer.byteLength (it’s just a big number e.g. 5604996) and all the elements are zeros.
namespace TestModule; type [Export] Program = public class public method Main; begin var len := 32; var buf := WebAssembly.ReflectConstruct('ArrayBuffer', [len]); assert(buf.byteLength = len); // OK var arr := WebAssembly.ReflectConstruct('Uint8Array', [buf]); assert(arr.length = len); // WRONG end; end; end.
So the question is - how to “manually” create an object that takes another object as an argument in the constructor?
What am I missing? Or is there another approach that I failed to discover?