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

Side by Side Diff: mojo/public/cpp/bindings/lib/array_internal.h

Issue 1395533005: Use <type_traits> in the C++ bindings library wherever possible. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « mojo/public/cpp/bindings/callback.h ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_LIB_ARRAY_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
7 7
8 #include <new> 8 #include <new>
9 #include <type_traits>
9 #include <vector> 10 #include <vector>
10 11
11 #include "mojo/public/c/system/macros.h" 12 #include "mojo/public/c/system/macros.h"
12 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 13 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" 14 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
14 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" 15 #include "mojo/public/cpp/bindings/lib/bounds_checker.h"
15 #include "mojo/public/cpp/bindings/lib/buffer.h" 16 #include "mojo/public/cpp/bindings/lib/buffer.h"
16 #include "mojo/public/cpp/bindings/lib/map_data_internal.h" 17 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
17 #include "mojo/public/cpp/bindings/lib/template_util.h"
18 #include "mojo/public/cpp/bindings/lib/validate_params.h" 18 #include "mojo/public/cpp/bindings/lib/validate_params.h"
19 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 19 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
20 #include "mojo/public/cpp/environment/logging.h" 20 #include "mojo/public/cpp/environment/logging.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 template <typename T> 23 template <typename T>
24 class Array; 24 class Array;
25 class String; 25 class String;
26 26
27 namespace internal { 27 namespace internal {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 template <typename T> 382 template <typename T>
383 class Array_Data { 383 class Array_Data {
384 public: 384 public:
385 typedef ArrayDataTraits<T> Traits; 385 typedef ArrayDataTraits<T> Traits;
386 typedef typename Traits::StorageType StorageType; 386 typedef typename Traits::StorageType StorageType;
387 typedef typename Traits::Ref Ref; 387 typedef typename Traits::Ref Ref;
388 typedef typename Traits::ConstRef ConstRef; 388 typedef typename Traits::ConstRef ConstRef;
389 typedef ArraySerializationHelper< 389 typedef ArraySerializationHelper<
390 T, 390 T,
391 IsHandle<T>::value, 391 IsHandle<T>::value,
392 IsUnionDataType<typename RemovePointer<T>::type>::value> Helper; 392 IsUnionDataType<typename std::remove_pointer<T>::type>::value> Helper;
393 393
394 // Returns null if |num_elements| or the corresponding storage size cannot be 394 // Returns null if |num_elements| or the corresponding storage size cannot be
395 // stored in uint32_t. 395 // stored in uint32_t.
396 static Array_Data<T>* New(size_t num_elements, Buffer* buf) { 396 static Array_Data<T>* New(size_t num_elements, Buffer* buf) {
397 if (num_elements > Traits::kMaxNumElements) 397 if (num_elements > Traits::kMaxNumElements)
398 return nullptr; 398 return nullptr;
399 399
400 uint32_t num_bytes = 400 uint32_t num_bytes =
401 Traits::GetStorageSize(static_cast<uint32_t>(num_elements)); 401 Traits::GetStorageSize(static_cast<uint32_t>(num_elements));
402 return new (buf->Allocate(num_bytes)) 402 return new (buf->Allocate(num_bytes))
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 574
575 template <> 575 template <>
576 struct WrapperTraits<String, false> { 576 struct WrapperTraits<String, false> {
577 typedef String_Data* DataType; 577 typedef String_Data* DataType;
578 }; 578 };
579 579
580 } // namespace internal 580 } // namespace internal
581 } // namespace mojo 581 } // namespace mojo
582 582
583 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 583 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/callback.h ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698