Index: Source/core/dom/TypedFlexibleArrayBufferView.h |
diff --git a/Source/core/dom/TypedFlexibleArrayBufferView.h b/Source/core/dom/TypedFlexibleArrayBufferView.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..73a3020c0b97e9c7921b0b74cc039550cc2a3956 |
--- /dev/null |
+++ b/Source/core/dom/TypedFlexibleArrayBufferView.h |
@@ -0,0 +1,32 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef TypedFlexibleArrayBufferView_h |
+#define TypedFlexibleArrayBufferView_h |
+ |
+#include "core/CoreExport.h" |
+#include "core/dom/FlexibleArrayBufferView.h" |
+#include "wtf/Noncopyable.h" |
+ |
+namespace blink { |
+ |
+template<typename WTFTypedArray> |
+class CORE_TEMPLATE_CLASS_EXPORT TypedFlexibleArrayBufferView final : public FlexibleArrayBufferView { |
+ DISALLOW_ALLOCATION(); |
+ WTF_MAKE_NONCOPYABLE(TypedFlexibleArrayBufferView); |
haraken
2015/07/30 14:54:57
Add WTF_MAKE_FAST_ALLOCATED.
Michael Lippautz
2015/07/30 17:06:15
STACK_ALLOCATED() (?)
|
+public: |
+ typedef typename WTFTypedArray::ValueType ValueType; |
haraken
2015/07/30 14:54:57
Use 'using'.
Michael Lippautz
2015/07/30 17:06:15
Done.
|
+ |
+ TypedFlexibleArrayBufferView() : FlexibleArrayBufferView() {} |
+ |
+ ValueType* data() const { return static_cast<ValueType*>(baseAddress()); } |
haraken
2015/07/30 14:54:57
I'd rename this to dataMaybeOnStack() or something
Michael Lippautz
2015/07/30 17:06:15
Done.
|
+ unsigned length() const { return byteLength() / sizeof(ValueType); } |
+}; |
+ |
+typedef TypedFlexibleArrayBufferView<WTF::Float32Array> FlexibleFloat32ArrayView; |
+typedef TypedFlexibleArrayBufferView<WTF::Int32Array> FlexibleInt32ArrayView; |
haraken
2015/07/30 14:54:57
Blink prefers 'using' in the new coding style.
Michael Lippautz
2015/07/30 17:06:15
Done.
|
+ |
+} // namespace blink |
+ |
+#endif // TypedFlexibleArrayBufferView_h |