示例#1
0
        /// <summary>
        /// Creates an empty typed array instance for use as a prototype.
        /// </summary>
        /// <param name="constructor"> A reference to the constructor that owns the prototype. </param>
        internal TypedArray(TypedArrayStyle style, int length)
        {
            Style = style;
            int bytesPerElement;

            switch (style)
            {
            case TypedArrayStyle.Int8Array:
            case TypedArrayStyle.Uint8Array:
            case TypedArrayStyle.Uint8ClampedArray:
                bytesPerElement = 1;
                break;

            case TypedArrayStyle.Int16Array:
            case TypedArrayStyle.Uint16Array:
                bytesPerElement = 2;
                break;

            case TypedArrayStyle.Int32Array:
            case TypedArrayStyle.Uint32Array:
            case TypedArrayStyle.Float32Array:
                bytesPerElement = 4;
                break;

            case TypedArrayStyle.Float64Array:
                bytesPerElement = 8;
                break;

            default:
                throw new NotSupportedException("Unsupported TypedArray style '" + style + "'.");
            }

            BYTES_PER_ELEMENT = bytesPerElement;
            Length            = length;
            ByteLength        = length * BYTES_PER_ELEMENT;
        }
示例#2
0
 internal TypedArray(TypedArrayStyle style, TypedArray array) : this(style, (int)array.Length)
 {
 }
示例#3
0
        //	 INITIALIZATION
        //_________________________________________________________________________________________

        internal TypedArray(TypedArrayStyle style, object iterableObj) : this(style, GetLength(iterableObj))
        {
        }