Skip to content

Latest commit

 

History

History
79 lines (70 loc) · 23.6 KB

File metadata and controls

79 lines (70 loc) · 23.6 KB

DataView

Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: SpawnJSObject
Source: JSObjects/DataView.cs
MDN Reference: DataView on MDN

The DataView view provides a low-level interface for reading and writing multiple number types in a binary ArrayBuffer, without having to care about the platform's endianness. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView

Constructors

Signature Description
DataView(ArrayBuffer arrayBuffer) The DataView() constructor creates DataView objects.
DataView(ArrayBuffer arrayBuffer, long byteOffset) The DataView() constructor creates DataView objects. An existing ArrayBuffer or SharedArrayBuffer to use as the storage backing the new DataView object. The offset, in bytes, to the first byte in the above buffer for the new view to reference. If unspecified, the buffer view starts with the first byte.
DataView(ArrayBuffer arrayBuffer, long byteOffset, long byteLength) The DataView() constructor creates DataView objects. An existing ArrayBuffer or SharedArrayBuffer to use as the storage backing the new DataView object. The offset, in bytes, to the first byte in the above buffer for the new view to reference. If unspecified, the buffer view starts with the first byte. The number of bytes in the byte array. If unspecified, the view's length will match the buffer's length.
DataView(SharedArrayBuffer arrayBuffer) The DataView() constructor creates DataView objects.
DataView(SharedArrayBuffer arrayBuffer, long byteOffset) The DataView() constructor creates DataView objects. An existing ArrayBuffer or SharedArrayBuffer to use as the storage backing the new DataView object. The offset, in bytes, to the first byte in the above buffer for the new view to reference. If unspecified, the buffer view starts with the first byte.
DataView(SharedArrayBuffer arrayBuffer, long byteOffset, long byteLength) The DataView() constructor creates DataView objects. An existing ArrayBuffer or SharedArrayBuffer to use as the storage backing the new DataView object. The offset, in bytes, to the first byte in the above buffer for the new view to reference. If unspecified, the buffer view starts with the first byte. The number of bytes in the byte array. If unspecified, the view's length will match the buffer's length.
DataView(SpawnJSObjectReference _ref) Deserialization constructor

Properties

Property Type Access Description
Buffer ArrayBuffer get The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
ByteLength long get The length (in bytes) of this view. Fixed at construction time and thus read only.
ByteOffset long get The offset (in bytes) of this view from the start of its ArrayBuffer. Fixed at construction time and thus read only.

Methods

Method Return Type Description
GetBigInt64(long byteOffset) long The getBigInt64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. A BigInt from -263 to 263-1, inclusive.
GetBigInt64(long byteOffset, bool littleEndian) long The getBigInt64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. A BigInt from -263 to 263-1, inclusive.
GetBigUint64(long byteOffset) ulong The getBigUint64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. A BigInt from 0 to 264-1, inclusive.
GetBigUint64(long byteOffset, bool littleEndian) ulong The getBigUint64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. A BigInt from 0 to 264-1, inclusive.
GetFloat16(long byteOffset) Half The getFloat16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. A floating point number from -65504 to 65504.
GetFloat16(long byteOffset, bool littleEndian) Half The getFloat16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. A floating point number from -65504 to 65504.
GetFloat32(long byteOffset) float The getFloat32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. A floating point number from -3.4e38 to 3.4e38.
GetFloat32(long byteOffset, bool littleEndian) float The getFloat32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. A floating point number from -3.4e38 to 3.4e38.
GetFloat64(long byteOffset) double The getFloat64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Any number value.
GetFloat64(long byteOffset, bool littleEndian) double The getFloat64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. Any number value.
GetInt16(long byteOffset) short The getInt16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. An integer from -32768 to 32767, inclusive.
GetInt16(long byteOffset, bool littleEndian) short The getInt16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. An integer from -32768 to 32767, inclusive.
GetInt32(long byteOffset) int The getInt32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. An integer from -2147483648 to 2147483647, inclusive.
GetInt32(long byteOffset, bool littleEndian) int The getInt32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. An integer from -2147483648 to 2147483647, inclusive.
GetInt8(long byteOffset) sbyte The getInt8() method of DataView instances reads 1 byte at the specified byte offset of this DataView and interprets it as an 8-bit signed integer. The offset, in bytes, from the start of the view to read the data from. An integer from -128 to 127, inclusive.
GetUint16(long byteOffset) ushort The getUint16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. An integer from 0 to 65535, inclusive.
GetUint16(long byteOffset, bool littleEndian) ushort The getUint16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. An integer from 0 to 65535, inclusive.
GetUint32(long byteOffset) uint The getUint32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. An integer from 0 to 4294967295, inclusive.
GetUint32(long byteOffset, bool littleEndian) uint The getUint32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. The offset, in bytes, from the start of the view to read the data from. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is read. An integer from 0 to 4294967295, inclusive.
GetUint8(long byteOffset) byte The getUint8() method of DataView instances reads 1 byte at the specified byte offset of this DataView and interprets it as an 8-bit unsigned integer. The offset, in bytes, from the start of the view to read the data from. An integer from 0 to 255, inclusive.
SetBigInt64(long byteOffset, long value) void The setBigInt64() method of DataView instances takes a BigInt and stores it as a 64-bit signed integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set as a BigInt. For how the value is encoded in bytes, see Value encoding and normalization.
SetBigInt64(long byteOffset, long value, bool littleEndian) void The setBigInt64() method of DataView instances takes a BigInt and stores it as a 64-bit signed integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set as a BigInt. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetBigUint64(long byteOffset, ulong value) void The setBigUint64() method of DataView instances takes a BigInt and stores it as a 64-bit unsigned integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set as a BigInt. For how the value is encoded in bytes, see Value encoding and normalization.
SetBigUint64(long byteOffset, ulong value, bool littleEndian) void The setBigUint64() method of DataView instances takes a BigInt and stores it as a 64-bit unsigned integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set as a BigInt. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetFloat16(long byteOffset, Half value) void The setFloat16() method of DataView instances takes a number and stores it as a 16-bit floating point number in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetFloat16(long byteOffset, Half value, bool littleEndian) void The setFloat16() method of DataView instances takes a number and stores it as a 16-bit floating point number in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetFloat32(long byteOffset, float value) void The setFloat32() method of DataView instances takes a number and stores it as a 32-bit floating point number in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetFloat32(long byteOffset, float value, bool littleEndian) void The setFloat32() method of DataView instances takes a number and stores it as a 32-bit floating point number in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetFloat64(long byteOffset, double value) void The setFloat64() method of DataView instances takes a number and stores it as a 64-bit floating point number in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetFloat64(long byteOffset, double value, bool littleEndian) void The setFloat64() method of DataView instances takes a number and stores it as a 64-bit floating point number in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetInt16(long byteOffset, short value) void The setInt16() method of DataView instances takes a number and stores it as a 16-bit signed integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetInt16(long byteOffset, short value, bool littleEndian) void The setInt16() method of DataView instances takes a number and stores it as a 16-bit signed integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetInt32(long byteOffset, int value) void The setInt32() method of DataView instances takes a number and stores it as a 32-bit signed integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetInt32(long byteOffset, int value, bool littleEndian) void The setInt32() method of DataView instances takes a number and stores it as a 32-bit signed integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetInt8(long byteOffset, sbyte value) void The setInt8() method of DataView instances takes a number and stores it as an 8-bit signed integer in the byte at the specified byte offset of this DataView. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetUint16(long byteOffset, ushort value) void The setUint16() method of DataView instances takes a number and stores it as a 16-bit unsigned integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetUint16(long byteOffset, ushort value, bool littleEndian) void The setUint16() method of DataView instances takes a number and stores it as a 16-bit unsigned integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetUint32(long byteOffset, uint value) void The setUint32() method of DataView instances takes a number and stores it as a 32-bit unsigned integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
SetUint32(long byteOffset, uint value, bool littleEndian) void The setUint32() method of DataView instances takes a number and stores it as a 32-bit unsigned integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization. Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.
SetUint8(long byteOffset, byte value) void The setUint8() method of DataView instances takes a number and stores it as an 8-bit unsigned integer in the byte at the specified byte offset of this DataView. The offset, in bytes, from the start of the view to store the data in. The value to set. For how the value is encoded in bytes, see Value encoding and normalization.
ReadBytes() byte[] Read bytes from the underlying ArrayBuffer starting at this DataView's byteOffset
ReadBytes(long byteOffset) byte[] Read bytes from the underlying ArrayBuffer starting at this DataView's byteOffset
ReadBytes(long byteOffset, long byteLength) byte[] Read bytes from the underlying ArrayBuffer starting at this DataView's byteOffset
Create(T[] data, long offset) DataView Returns a copy of the struct array as a new DataView
Create(T[] data, long offset, long length) DataView Returns a copy of the struct array as a new DataView