// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; namespace Microsoft.ClearScript.JavaScript { /// /// Represents a JavaScript /// ArrayBuffer. /// public interface IArrayBuffer { /// /// Gets the size of the ArrayBuffer in bytes. /// ulong Size { get; } /// /// Creates a byte array containing a copy of the ArrayBuffer's contents. /// /// A new byte array containing a copy of the ArrayBuffer's contents. byte[] GetBytes(); /// /// Copies bytes from the ArrayBuffer into the specified byte array. /// /// The offset within the ArrayBuffer of the first byte to copy. /// The maximum number of bytes to copy. /// The byte array into which to copy the bytes. /// The index within at which to store the first copied byte. /// The number of bytes copied. ulong ReadBytes(ulong offset, ulong count, byte[] destination, ulong destinationIndex); /// /// Copies bytes from the specified byte array into the ArrayBuffer. /// /// The byte array from which to copy the bytes. /// The index within of the first byte to copy. /// The maximum number of bytes to copy. /// The offset within the ArrayBuffer at which to store the first copied byte. /// The number of bytes copied. ulong WriteBytes(byte[] source, ulong sourceIndex, ulong count, ulong offset); /// /// Invokes a delegate that returns no value, giving it direct access to the ArrayBuffer's contents. /// /// The delegate to invoke. /// /// This method invokes the specified delegate, passing in the memory address of the /// ArrayBuffer's contents. This memory address is valid only while the delegate is /// executing. The delegate must not access memory outside the ArrayBuffer's range. /// void InvokeWithDirectAccess(Action action); /// /// Invokes a delegate that returns a value, giving it direct access to the ArrayBuffer's contents. /// /// The delegate's return type. /// The delegate to invoke. /// The delegate's return value. /// /// This method invokes the specified delegate, passing in the memory address of the /// ArrayBuffer's contents. This memory address is valid only while the delegate is /// executing. The delegate must not access memory outside the ArrayBuffer's range. /// T InvokeWithDirectAccess(Func func); } }