OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef TypedFlexibleArrayBufferView_h | |
6 #define TypedFlexibleArrayBufferView_h | |
7 | |
8 #include "core/CoreExport.h" | |
9 #include "core/dom/FlexibleArrayBufferView.h" | |
10 #include "wtf/Noncopyable.h" | |
11 | |
12 namespace blink { | |
13 | |
14 template<typename WTFTypedArray> | |
15 class CORE_TEMPLATE_CLASS_EXPORT TypedFlexibleArrayBufferView final : public Fle xibleArrayBufferView { | |
16 STACK_ALLOCATED(); | |
17 WTF_MAKE_NONCOPYABLE(TypedFlexibleArrayBufferView); | |
18 public: | |
19 using ValueType = typename WTFTypedArray::ValueType; | |
20 | |
21 TypedFlexibleArrayBufferView() : FlexibleArrayBufferView() {} | |
22 | |
23 ValueType* dataMaybeOnStack() const { return static_cast<ValueType*>(baseAdd ressMaybeOnStack()); } | |
24 unsigned length() const { return byteLength() / sizeof(ValueType); } | |
haraken
2015/07/30 20:34:44
Shall we add:
ASSERT(byteLength() % sizeof(Valu
Michael Lippautz
2015/07/31 07:53:38
Good idea, done.
| |
25 }; | |
26 | |
27 using FlexibleInt32ArrayView = TypedFlexibleArrayBufferView<WTF::Int32Array>; | |
28 using FlexibleFloat32ArrayView = TypedFlexibleArrayBufferView<WTF::Float32Array> ; | |
29 | |
30 } // namespace blink | |
31 | |
32 #endif // TypedFlexibleArrayBufferView_h | |
OLD | NEW |