ArrayBufferViewImpl

clay.buffers.ArrayBufferViewImpl (Class)

Instance Members


buffer: ArrayBuffer

byteOffset: Int

byteLength: Int

length: Int

unsafeBytePointer(): cpp.Pointer<cpp.UInt8>

Raw byte pointer to this view's data (native targets only).

Opt-in escape hatch for hot loops: the per-element accessors are already inline typed stores, but they re-pay a double indirection (view -> buffer -> data) on every access, which prevents the C++ optimizer from hoisting and vectorizing. Holding this pointer for the duration of a tight loop removes that cost.

Safety contract (the caller is responsible for all of these):

  • acquire right before use; never cache across frames or in fields. Data blocks of at least 4000 bytes are malloc'd by the GC and never move, but smaller ones may move if a moving/generational GC is enabled, so a cached pointer is only safe for large, field-referenced buffers;
  • keep this view (or its buffer) referenced somewhere for as long as the pointer is used - a raw pointer keeps nothing alive;
  • no allocation between acquisition and last use (a collection can only happen at allocation points). | Returns | |---------| | cpp.Pointer<cpp.UInt8> |

set(?view: Null<ArrayBufferView>, ?array: Array<Float>, ?offset: Int = 0): Void
Name Type Default
view Null<ArrayBufferView> (optional)
array Array<Float> (optional)
offset Int 0

Private Members

bytesPerElement: Int

fromElements(_type: TypedArrayType, _elements: Int): ArrayBufferView
Name Type
_type TypedArrayType
_elements Int
Returns
ArrayBufferView

Name Type
_type TypedArrayType
_other ArrayBufferView
Returns
ArrayBufferView

fromBuffer(_type: TypedArrayType, _buffer: ArrayBuffer, _byte_offset: Int, _byte_length: Int, ?_view: Null<ArrayBufferView>): ArrayBufferView
Name Type Default
_type TypedArrayType
_buffer ArrayBuffer
_byte_offset Int
_byte_length Int
_view Null<ArrayBufferView> (optional)
Returns
ArrayBufferView

fromArray(_type: TypedArrayType, _array: Array<Float>): ArrayBufferView
Name Type
_type TypedArrayType
_array Array<Float>
Returns
ArrayBufferView

cloneBuffer(src: ArrayBuffer, ?srcByteOffset: Int = 0): Void
Name Type Default
src ArrayBuffer
srcByteOffset Int 0

subarray(begin: Int, ?end: Int = null): subarray.T_subarray
Name Type Default
begin Int
end Int null
Returns
subarray.T_subarray

bytesForType(type: TypedArrayType): Int
Name Type
type TypedArrayType
Returns
Int

toString(): String
Returns
String

toByteLength(elemCount: Int): Int
Name Type
elemCount Int
Returns
Int

copyFromArray(array: Array<Float>, ?offset: Int = 0): Void
Name Type Default
array Array<Float>
offset Int 0

new(in_type: TypedArrayType): Void
Name Type
in_type TypedArrayType