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_BINDINGS_INTERNAL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
7 | 7 |
8 #include "mojo/public/cpp/bindings/lib/template_util.h" | 8 #include "mojo/public/cpp/bindings/lib/template_util.h" |
9 #include "mojo/public/cpp/bindings/struct_ptr.h" | 9 #include "mojo/public/cpp/bindings/struct_ptr.h" |
10 #include "mojo/public/cpp/system/core.h" | 10 #include "mojo/public/cpp/system/core.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 class String; | 13 class String; |
14 | 14 |
| 15 template <typename T> |
| 16 class Array; |
| 17 |
| 18 template <typename K, typename V> |
| 19 class Map; |
| 20 |
15 namespace internal { | 21 namespace internal { |
16 template <typename T> | 22 template <typename T> |
17 class Array_Data; | 23 class Array_Data; |
18 | 24 |
19 #pragma pack(push, 1) | 25 #pragma pack(push, 1) |
20 | 26 |
21 struct StructHeader { | 27 struct StructHeader { |
22 uint32_t num_bytes; | 28 uint32_t num_bytes; |
23 uint32_t num_fields; | 29 uint32_t num_fields; |
24 }; | 30 }; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 }; | 93 }; |
88 template <typename S> | 94 template <typename S> |
89 struct WrapperTraits<InlinedStructPtr<S>, true> { | 95 struct WrapperTraits<InlinedStructPtr<S>, true> { |
90 typedef typename S::Data_* DataType; | 96 typedef typename S::Data_* DataType; |
91 }; | 97 }; |
92 template <typename S> | 98 template <typename S> |
93 struct WrapperTraits<S, true> { | 99 struct WrapperTraits<S, true> { |
94 typedef typename S::Data_* DataType; | 100 typedef typename S::Data_* DataType; |
95 }; | 101 }; |
96 | 102 |
| 103 template <typename T, typename Enable = void> |
| 104 struct ValueTraits { |
| 105 static bool Equals(const T& a, const T& b) { return a == b; } |
| 106 }; |
| 107 |
| 108 template <typename T> |
| 109 struct ValueTraits< |
| 110 T, |
| 111 typename EnableIf<IsSpecializationOf<Array, T>::value || |
| 112 IsSpecializationOf<Map, T>::value || |
| 113 IsSpecializationOf<StructPtr, T>::value || |
| 114 IsSpecializationOf<InlinedStructPtr, T>::value>::type> { |
| 115 static bool Equals(const T& a, const T& b) { return a.Equals(b); } |
| 116 }; |
| 117 |
| 118 template <typename T> |
| 119 struct ValueTraits<ScopedHandleBase<T>> { |
| 120 static bool Equals(const ScopedHandleBase<T>& a, |
| 121 const ScopedHandleBase<T>& b) { |
| 122 return a.get().value() == b.get().value(); |
| 123 } |
| 124 }; |
| 125 |
97 } // namespace internal | 126 } // namespace internal |
98 } // namespace mojo | 127 } // namespace mojo |
99 | 128 |
100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 129 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |