| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "mojo/public/c/system/macros.h" | 11 #include "mojo/public/c/system/macros.h" |
| 12 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 12 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| 13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" | 13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" |
| 14 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" | 14 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" |
| 15 #include "mojo/public/cpp/bindings/lib/buffer.h" | 15 #include "mojo/public/cpp/bindings/lib/buffer.h" |
| 16 #include "mojo/public/cpp/bindings/lib/template_util.h" | 16 #include "mojo/public/cpp/bindings/lib/template_util.h" |
| 17 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 17 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| 18 #include "mojo/public/cpp/environment/logging.h" | 18 #include "mojo/public/cpp/environment/logging.h" |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 template <typename T> class Array; | 21 template <typename T> class Array; |
| 22 class String; | 22 class String; |
| 23 | 23 |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 // std::numeric_limits<uint32_t>::max() is not a compile-time constant (until | 26 // std::numeric_limits<uint32_t>::max() is not a compile-time constant (until |
| 27 // C++11). | 27 // C++11). |
| 28 const uint32_t kMaxUint32 = 0xFFFFFFFF; | 28 const uint32_t kMaxUint32 = 0xFFFFFFFF; |
| 29 | 29 |
| 30 std::string MakeMessageWithArrayIndex(const char* message, |
| 31 size_t size, |
| 32 size_t index); |
| 33 |
| 34 std::string MakeMessageWithExpectedArraySize(const char* message, |
| 35 size_t size, |
| 36 size_t expected_size); |
| 37 |
| 30 template <typename T> | 38 template <typename T> |
| 31 struct ArrayDataTraits { | 39 struct ArrayDataTraits { |
| 32 typedef T StorageType; | 40 typedef T StorageType; |
| 33 typedef T& Ref; | 41 typedef T& Ref; |
| 34 typedef T const& ConstRef; | 42 typedef T const& ConstRef; |
| 35 | 43 |
| 36 static const uint32_t kMaxNumElements = | 44 static const uint32_t kMaxNumElements = |
| 37 (kMaxUint32 - sizeof(ArrayHeader)) / sizeof(StorageType); | 45 (kMaxUint32 - sizeof(ArrayHeader)) / sizeof(StorageType); |
| 38 | 46 |
| 39 static uint32_t GetStorageSize(uint32_t num_elements) { | 47 static uint32_t GetStorageSize(uint32_t num_elements) { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 }; | 490 }; |
| 483 | 491 |
| 484 template <> struct WrapperTraits<String, false> { | 492 template <> struct WrapperTraits<String, false> { |
| 485 typedef String_Data* DataType; | 493 typedef String_Data* DataType; |
| 486 }; | 494 }; |
| 487 | 495 |
| 488 } // namespace internal | 496 } // namespace internal |
| 489 } // namespace mojo | 497 } // namespace mojo |
| 490 | 498 |
| 491 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 499 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
| OLD | NEW |