| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (c) 2010, Google Inc. All rights reserved. | 3 * Copyright (c) 2010, 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (a) | 77 if (a) |
| 78 for (unsigned i = 0; i < length; ++i) | 78 for (unsigned i = 0; i < length; ++i) |
| 79 a->set(i, array[i]); | 79 a->set(i, array[i]); |
| 80 return a; | 80 return a; |
| 81 } | 81 } |
| 82 | 82 |
| 83 template <class Subclass> | 83 template <class Subclass> |
| 84 static PassRefPtr<Subclass> create(PassRefPtr<ArrayBuffer> buffer, | 84 static PassRefPtr<Subclass> create(PassRefPtr<ArrayBuffer> buffer, |
| 85 unsigned byteOffset, | 85 unsigned byteOffset, |
| 86 unsigned length) { | 86 unsigned length) { |
| 87 RefPtr<ArrayBuffer> buf(buffer); | 87 RefPtr<ArrayBuffer> buf(std::move(buffer)); |
| 88 RELEASE_ASSERT(verifySubRange<T>(buf, byteOffset, length)); | 88 RELEASE_ASSERT(verifySubRange<T>(buf, byteOffset, length)); |
| 89 return adoptRef(new Subclass(buf.release(), byteOffset, length)); | 89 return adoptRef(new Subclass(buf.release(), byteOffset, length)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 template <class Subclass> | 92 template <class Subclass> |
| 93 static PassRefPtr<Subclass> createOrNull(unsigned length) { | 93 static PassRefPtr<Subclass> createOrNull(unsigned length) { |
| 94 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T)); | 94 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T)); |
| 95 if (!buffer) | 95 if (!buffer) |
| 96 return nullptr; | 96 return nullptr; |
| 97 return create<Subclass>(buffer.release(), 0, length); | 97 return create<Subclass>(buffer.release(), 0, length); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void neuter() final { | 100 void neuter() final { |
| 101 ArrayBufferView::neuter(); | 101 ArrayBufferView::neuter(); |
| 102 m_length = 0; | 102 m_length = 0; |
| 103 } | 103 } |
| 104 | 104 |
| 105 // We do not want to have to access this via a virtual function in subclasses, | 105 // We do not want to have to access this via a virtual function in subclasses, |
| 106 // which is why it is protected rather than private. | 106 // which is why it is protected rather than private. |
| 107 unsigned m_length; | 107 unsigned m_length; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace WTF | 110 } // namespace WTF |
| 111 | 111 |
| 112 using WTF::TypedArrayBase; | 112 using WTF::TypedArrayBase; |
| 113 | 113 |
| 114 #endif // TypedArrayBase_h | 114 #endif // TypedArrayBase_h |
| OLD | NEW |