The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. You can not directly manipulate the contents of an ArrayBuffer; instead, you create one of the typed array objects or a DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer.
Inheritance: ObjectInstance
Esempio n. 1
0
 //     INITIALIZATION
 //_________________________________________________________________________________________
 /// <summary>
 /// Creates a new DataView instance.
 /// </summary>
 /// <param name="prototype"> The next object in the prototype chain. </param>
 /// <param name="buffer"> An existing ArrayBuffer to use as the storage for the new
 /// DataView object. </param>
 /// <param name="byteOffset"> The offset, in bytes, to the first byte in the specified
 /// buffer for the new view to reference. If not specified, the view of the buffer will
 /// start with the first byte. </param>
 /// <param name="byteLength"> The number of elements in the byte array. If unspecified,
 /// length of the view will match the buffer's length. </param>
 internal DataViewInstance(ObjectInstance prototype, ArrayBufferInstance buffer, int byteOffset, int byteLength)
     : base(prototype)
 {
     this.buffer = buffer;
     this.byteOffset = byteOffset;
     this.byteLength = byteLength;
 }
Esempio n. 2
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Creates a new DataView instance.
        /// </summary>
        /// <param name="prototype"> The next object in the prototype chain. </param>
        /// <param name="buffer"> An existing ArrayBuffer to use as the storage for the new
        /// DataView object. </param>
        /// <param name="byteOffset"> The offset, in bytes, to the first byte in the specified
        /// buffer for the new view to reference. If not specified, the view of the buffer will
        /// start with the first byte. </param>
        /// <param name="byteLength"> The number of elements in the byte array. If unspecified,
        /// length of the view will match the buffer's length. </param>
        internal DataViewInstance(ObjectInstance prototype, ArrayBufferInstance buffer, int byteOffset, int byteLength)
            : base(prototype)
        {
            this.buffer     = buffer;
            this.byteOffset = byteOffset;
            this.byteLength = byteLength;
        }
Esempio n. 3
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Creates a new typed array instance.
        /// </summary>
        /// <param name="prototype"> The next object in the prototype chain. </param>
        /// <param name="type"> Defines the element type and behaviour of the typed array. </param>
        /// <param name="buffer"> An existing ArrayBuffer to use as the storage for the new
        /// TypedArray object. </param>
        /// <param name="byteOffset"> The offset, in bytes, to the first byte in the specified
        /// buffer for the new view to reference. If not specified, the TypedArray will start
        /// with the first byte. </param>
        /// <param name="length"> The length (in elements) of the typed array. </param>
        internal TypedArrayInstance(ObjectInstance prototype, TypedArrayType type, ArrayBufferInstance buffer, int byteOffset, int length)
            : base(prototype)
        {
            this.type       = type;
            this.buffer     = buffer;
            this.byteOffset = byteOffset;
            this.length     = length;
        }
Esempio n. 4
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Creates a new array buffer constructor.
        /// </summary>
        /// <param name="prototype"> The next object in the prototype chain. </param>
        internal ArrayBufferConstructor(ObjectInstance prototype)
            : base(prototype, __STUB__Construct, __STUB__Call)
        {
            // Initialize the constructor properties.
            var properties = GetDeclarativeProperties(Engine);

            InitializeConstructorProperties(properties, "ArrayBuffer", 1, ArrayBufferInstance.CreatePrototype(Engine, this));
            InitializeProperties(properties);
        }
 public DataViewInstance Construct(ArrayBufferInstance buffer = null, int byteOffset = 0, int? byteLength = null)
 {
     if (buffer == null)
         throw new JavaScriptException(Engine, ErrorType.TypeError, "First argument to DataView constructor must be an ArrayBuffer.");
     if (byteOffset >= buffer.ByteLength)
         throw new JavaScriptException(Engine, ErrorType.RangeError, "Start offset is outside the bounds of the buffer.");
     int byteLengthValue = byteLength ?? buffer.ByteLength - byteOffset;
     if (byteOffset + byteLengthValue > buffer.ByteLength)
         throw new JavaScriptException(Engine, ErrorType.RangeError, "Invalid data view length.");
     return new DataViewInstance(this.InstancePrototype, buffer, byteOffset, byteLengthValue);
 }
        public DataViewInstance Construct(ArrayBufferInstance buffer = null, int byteOffset = 0, int?byteLength = null)
        {
            if (buffer == null)
            {
                throw new JavaScriptException(Engine, ErrorType.TypeError, "First argument to DataView constructor must be an ArrayBuffer.");
            }
            if (byteOffset >= buffer.ByteLength)
            {
                throw new JavaScriptException(Engine, ErrorType.RangeError, "Start offset is outside the bounds of the buffer.");
            }
            int byteLengthValue = byteLength ?? buffer.ByteLength - byteOffset;

            if (byteOffset + byteLengthValue > buffer.ByteLength)
            {
                throw new JavaScriptException(Engine, ErrorType.RangeError, "Invalid data view length.");
            }
            return(new DataViewInstance(this.InstancePrototype, buffer, byteOffset, byteLengthValue));
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arrayBufferInstance">The displayed ArrayBufferInstance</param>
 public ArrayBufferInstanceDebugView(ArrayBufferInstance arrayBufferInstance)
 {
     this.arrayBufferInstance = arrayBufferInstance;
 }