| // Copyright 2016 Google Inc. All Rights Reserved. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // https://www.khronos.org/registry/typedarray/specs/latest/#7 |
| [ |
| Constructor(unsigned long length), |
| Constructor(Uint16Array array), |
| Constructor(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long length), |
| ConstructorCallWith=EnvironmentSettings, |
| RaisesException=Constructor |
| ] |
| interface Uint16Array : ArrayBufferView { |
| const unsigned long BYTES_PER_ELEMENT = 2; |
| |
| readonly attribute unsigned long length; |
| |
| getter unsigned short get(unsigned long index); |
| setter void set(unsigned long index, unsigned short value); |
| |
| // TODO: When arrays or sequences are supported, support them here. |
| // void set(sequence<long> array, optional unsigned long offset); |
| |
| // Copy items into this array from source, starting at this[offset]. |
| [RaisesException] void set(Uint16Array source, optional unsigned long offset); |
| |
| // Return a new Uint16Array that is a view on top of this one. |
| // Contains this[start]..this[end]. end defaults to length if unspecified. |
| [CallWith=EnvironmentSettings] Uint16Array subarray(long start, optional long end); |
| }; |