OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 #define Uint8Array_h | 28 #define Uint8Array_h |
29 | 29 |
30 #include "wtf/IntegralTypedArrayBase.h" | 30 #include "wtf/IntegralTypedArrayBase.h" |
31 | 31 |
32 namespace WTF { | 32 namespace WTF { |
33 | 33 |
34 class ArrayBuffer; | 34 class ArrayBuffer; |
35 | 35 |
36 class Uint8Array : public IntegralTypedArrayBase<unsigned char> { | 36 class Uint8Array : public IntegralTypedArrayBase<unsigned char> { |
37 public: | 37 public: |
38 static inline PassRefPtr<Uint8Array> create(unsigned length); | 38 static inline PassRefPtr<Uint8Array> createOrNull(unsigned length); |
39 static inline PassRefPtr<Uint8Array> create(const unsigned char* array, unsi
gned length); | 39 static inline PassRefPtr<Uint8Array> createOrNull(const unsigned char* array
, unsigned length); |
| 40 static inline PassRefPtr<Uint8Array> deprecatedCreateOrCrash(const unsigned
char* array, unsigned length); |
40 static inline PassRefPtr<Uint8Array> create(PassRefPtr<ArrayBuffer>, unsigne
d byteOffset, unsigned length); | 41 static inline PassRefPtr<Uint8Array> create(PassRefPtr<ArrayBuffer>, unsigne
d byteOffset, unsigned length); |
41 | 42 |
42 using TypedArrayBase<unsigned char>::set; | 43 using TypedArrayBase<unsigned char>::set; |
43 using IntegralTypedArrayBase<unsigned char>::set; | 44 using IntegralTypedArrayBase<unsigned char>::set; |
44 | 45 |
45 ViewType type() const override | 46 ViewType type() const override |
46 { | 47 { |
47 return TypeUint8; | 48 return TypeUint8; |
48 } | 49 } |
49 | 50 |
50 protected: | 51 protected: |
51 inline Uint8Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned len
gth); | 52 inline Uint8Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned len
gth); |
52 // Make constructor visible to superclass. | 53 // Make constructor visible to superclass. |
53 friend class TypedArrayBase<unsigned char>; | 54 friend class TypedArrayBase<unsigned char>; |
54 }; | 55 }; |
55 | 56 |
56 PassRefPtr<Uint8Array> Uint8Array::create(unsigned length) | 57 PassRefPtr<Uint8Array> Uint8Array::createOrNull(unsigned length) |
57 { | 58 { |
58 return TypedArrayBase<unsigned char>::create<Uint8Array>(length); | 59 return TypedArrayBase<unsigned char>::createOrNull<Uint8Array>(length); |
59 } | 60 } |
60 | 61 |
61 PassRefPtr<Uint8Array> Uint8Array::create(const unsigned char* array, unsigned l
ength) | 62 PassRefPtr<Uint8Array> Uint8Array::createOrNull(const unsigned char* array, unsi
gned length) |
62 { | 63 { |
63 return TypedArrayBase<unsigned char>::create<Uint8Array>(array, length); | 64 return TypedArrayBase<unsigned char>::createOrNull<Uint8Array>(array, length
); |
| 65 } |
| 66 |
| 67 PassRefPtr<Uint8Array> Uint8Array::deprecatedCreateOrCrash(const unsigned char*
array, unsigned length) |
| 68 { |
| 69 return TypedArrayBase<unsigned char>::deprecatedCreateOrCrash<Uint8Array>(ar
ray, length); |
64 } | 70 } |
65 | 71 |
66 PassRefPtr<Uint8Array> Uint8Array::create(PassRefPtr<ArrayBuffer> buffer, unsign
ed byteOffset, unsigned length) | 72 PassRefPtr<Uint8Array> Uint8Array::create(PassRefPtr<ArrayBuffer> buffer, unsign
ed byteOffset, unsigned length) |
67 { | 73 { |
68 return TypedArrayBase<unsigned char>::create<Uint8Array>(buffer, byteOffset,
length); | 74 return TypedArrayBase<unsigned char>::create<Uint8Array>(buffer, byteOffset,
length); |
69 } | 75 } |
70 | 76 |
71 Uint8Array::Uint8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsi
gned length) | 77 Uint8Array::Uint8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsi
gned length) |
72 : IntegralTypedArrayBase<unsigned char>(buffer, byteOffset, length) | 78 : IntegralTypedArrayBase<unsigned char>(buffer, byteOffset, length) |
73 { | 79 { |
74 } | 80 } |
75 | 81 |
76 } // namespace WTF | 82 } // namespace WTF |
77 | 83 |
78 using WTF::Uint8Array; | 84 using WTF::Uint8Array; |
79 | 85 |
80 #endif // Uint8Array_h | 86 #endif // Uint8Array_h |
OLD | NEW |