| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |