Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: mojo/public/cpp/bindings/wtf_array.h

Issue 2034273002: Mojo C++ bindings: introduce mojo::WTFMap for blink bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed the code of adding enum key support to WTF::HashMap; which turned out to be non-trivial; wi… Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/wtf_types_unittest.cc ('k') | mojo/public/cpp/bindings/wtf_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698