| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // mojo::WTFArray is move-only and can be null. | 21 // mojo::WTFArray is move-only and can be null. |
| 22 // It is easy to convert between WTF::Vector<T> and mojo::WTFArray<T>: | 22 // It is easy to convert between WTF::Vector<T> and mojo::WTFArray<T>: |
| 23 // - constructor WTFArray(WTF::Vector<T>&&) takes the contents of a | 23 // - constructor WTFArray(WTF::Vector<T>&&) takes the contents of a |
| 24 // WTF::Vector<T>; | 24 // WTF::Vector<T>; |
| 25 // - method PassStorage() passes the underlying WTF::Vector. | 25 // - method PassStorage() passes the underlying WTF::Vector. |
| 26 template <typename T> | 26 template <typename T> |
| 27 class WTFArray { | 27 class WTFArray { |
| 28 MOVE_ONLY_TYPE_FOR_CPP_03(WTFArray); | 28 MOVE_ONLY_TYPE_FOR_CPP_03(WTFArray); |
| 29 | 29 |
| 30 public: | 30 public: |
| 31 using Data_ = internal::Array_Data< | |
| 32 typename internal::GetDataTypeAsArrayElement<T>::Data>; | |
| 33 using Element = T; | |
| 34 | |
| 35 // Constructs an empty array. | 31 // Constructs an empty array. |
| 36 WTFArray() : is_null_(false) {} | 32 WTFArray() : is_null_(false) {} |
| 37 // Constructs a null array. | 33 // Constructs a null array. |
| 38 WTFArray(std::nullptr_t null_pointer) : is_null_(true) {} | 34 WTFArray(std::nullptr_t null_pointer) : is_null_(true) {} |
| 39 | 35 |
| 40 // Constructs a new non-null array of the specified size. The elements will | 36 // Constructs a new non-null array of the specified size. The elements will |
| 41 // be value-initialized (meaning that they will be initialized by their | 37 // be value-initialized (meaning that they will be initialized by their |
| 42 // default constructor, if any, or else zero-initialized). | 38 // default constructor, if any, or else zero-initialized). |
| 43 explicit WTFArray(size_t size) : vec_(size), is_null_(false) {} | 39 explicit WTFArray(size_t size) : vec_(size), is_null_(false) {} |
| 44 ~WTFArray() {} | 40 ~WTFArray() {} |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 Swap(other); | 194 Swap(other); |
| 199 } | 195 } |
| 200 | 196 |
| 201 WTF::Vector<T> vec_; | 197 WTF::Vector<T> vec_; |
| 202 bool is_null_; | 198 bool is_null_; |
| 203 }; | 199 }; |
| 204 | 200 |
| 205 } // namespace mojo | 201 } // namespace mojo |
| 206 | 202 |
| 207 #endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ | 203 #endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ |
| OLD | NEW |