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> |
| 104 struct ValueTraits { |
| 105 static bool Equals(const T& a, const T& b) { return a == b; } |
| 106 }; |
| 107 |
| 108 // TODO(aa): It would be cool to have IsSpecializationOf<> template helper, but |
| 109 // got lost in the goop when I tried. |
| 110 template <typename T> |
| 111 struct ValueTraits<Array<T>> { |
| 112 static bool Equals(const Array<T>& a, const Array<T>& b) { |
| 113 return a.Equals(b); |
| 114 } |
| 115 }; |
| 116 |
| 117 template <typename T, typename U> |
| 118 struct ValueTraits<Map<T, U>> { |
| 119 static bool Equals(const Map<T, U>& a, const Map<T, U>& b) { |
| 120 return a.Equals(b); |
| 121 } |
| 122 }; |
| 123 |
| 124 template <typename T> |
| 125 struct ValueTraits<StructPtr<T>> { |
| 126 static bool Equals(const StructPtr<T>& a, const StructPtr<T>& b) { |
| 127 return a.Equals(b); |
| 128 } |
| 129 }; |
| 130 |
| 131 template <typename T> |
| 132 struct ValueTraits<InlinedStructPtr<T>> { |
| 133 static bool Equals(const InlinedStructPtr<T>& a, |
| 134 const InlinedStructPtr<T>& b) { |
| 135 return a.Equals(b); |
| 136 } |
| 137 }; |
| 138 |
| 139 template <typename T> |
| 140 struct ValueTraits<ScopedHandleBase<T>> { |
| 141 static bool Equals(const ScopedHandleBase<T>& a, |
| 142 const ScopedHandleBase<T>& b) { |
| 143 return a.get().value() == b.get().value(); |
| 144 } |
| 145 }; |
| 146 |
97 } // namespace internal | 147 } // namespace internal |
98 } // namespace mojo | 148 } // namespace mojo |
99 | 149 |
100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 150 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |