mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 06:21:29 +00:00
Add a .data pointer on ArrayBuffers for convenience, see #291
This commit is contained in:
@ -9,6 +9,9 @@ export class ArrayBuffer {
|
||||
|
||||
readonly byteLength: i32; // capped to [0, MAX_LENGTH]
|
||||
|
||||
// @unsafe
|
||||
get data(): usize { return changetype<usize>(this) + HEADER_SIZE; }
|
||||
|
||||
constructor(length: i32, unsafe: bool = false) {
|
||||
if (<u32>length > <u32>MAX_BLENGTH) throw new RangeError("Invalid array buffer length");
|
||||
var buffer = allocateUnsafe(length);
|
||||
|
2
std/assembly/index.d.ts
vendored
2
std/assembly/index.d.ts
vendored
@ -372,6 +372,8 @@ declare namespace table {
|
||||
declare class ArrayBuffer {
|
||||
/** The size, in bytes, of the array. */
|
||||
readonly byteLength: i32;
|
||||
/** Unsafe pointer to the start of the data in memory. */
|
||||
readonly data: usize;
|
||||
/** Constructs a new array buffer of the given length in bytes. */
|
||||
constructor(length: i32, unsafe?: bool);
|
||||
/** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */
|
||||
|
Reference in New Issue
Block a user