Description
As per Gilles'/@barbibulle 's request on the mailing list:
Do you have any expectations of the interface? Which abilities are urgent in your application? Those feedbacks will help us design the API.
what I'd expect from the public interface is to be able to:
1/ get to the underlying memory buffer of an ArrayBuffer and TypedArray, using something equivalent to what's in ecma-arraybuffer-object.h and:
- ecma_arraybuffer_get_buffer (ecma_object_t *obj_p);
- ecma_arraybuffer_get_length (ecma_object_t *obj_p);
- ecma_typedarray_get_buffer (ecma_object_t *typedarray_p);
- ecma_typedarray_get_length (ecma_object_t *typedarray_p);
- ecma_typedarray_get_element_size_shift (ecma_object_t *typedarray_p);
2/ Ability to query whether a jerry_value_t is an instance of ArrayBuffer or is a TypedArray. Something equivalent to:
- ecma_is_arraybuffer (ecma_value_t val);
- ecma_is_typedarray (ecma_value_t target);
3/ Maybe also a convenience function for creating an ArrayBuffer with a single call (probably not necessary for TypedArrays). Something equivalent to:
- ecma_arraybuffer_new_object (ecma_length_t lengh);
4/ It would be nice to also have DataView implemented, since Uint32Array is always with the > platform's endianness, it makes it hard to parse external data structures that are big endian when running on little-endian platforms.
When interfacing with native APIs, including filesystems, network interfaces, etc, ArrayBuffers are very convenient, and the ability to easily exchange buffers with JS code is extremely useful.