diff options
Diffstat (limited to 'Source/WTF/wtf/Uint8Array.h')
| -rw-r--r-- | Source/WTF/wtf/Uint8Array.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/WTF/wtf/Uint8Array.h b/Source/WTF/wtf/Uint8Array.h index be91729d6..a23d1eb50 100644 --- a/Source/WTF/wtf/Uint8Array.h +++ b/Source/WTF/wtf/Uint8Array.h @@ -39,6 +39,10 @@ public: static inline PassRefPtr<Uint8Array> create(const unsigned char* array, unsigned length); static inline PassRefPtr<Uint8Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); + // Should only be used when it is known the entire array will be filled. Do + // not return these results directly to JavaScript without filling first. + static inline PassRefPtr<Uint8Array> createUninitialized(unsigned length); + // Can’t use "using" here due to a bug in the RVCT compiler. bool set(TypedArrayBase<unsigned char>* array, unsigned offset) { return TypedArrayBase<unsigned char>::set(array, offset); } void set(unsigned index, double value) { IntegralTypedArrayBase<unsigned char>::set(index, value); } @@ -46,15 +50,17 @@ public: inline PassRefPtr<Uint8Array> subarray(int start) const; inline PassRefPtr<Uint8Array> subarray(int start, int end) const; + virtual ViewType getType() const + { + return TypeUint8; + } + protected: inline Uint8Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); // Make constructor visible to superclass. friend class TypedArrayBase<unsigned char>; - - // Overridden from ArrayBufferView. - virtual bool isUnsignedByteArray() const { return true; } }; PassRefPtr<Uint8Array> Uint8Array::create(unsigned length) @@ -72,6 +78,11 @@ PassRefPtr<Uint8Array> Uint8Array::create(PassRefPtr<ArrayBuffer> buffer, unsign return TypedArrayBase<unsigned char>::create<Uint8Array>(buffer, byteOffset, length); } +PassRefPtr<Uint8Array> Uint8Array::createUninitialized(unsigned length) +{ + return TypedArrayBase<unsigned char>::createUninitialized<Uint8Array>(length); +} + Uint8Array::Uint8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length) : IntegralTypedArrayBase<unsigned char>(buffer, byteOffset, length) { |
