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 <type_traits> | 8 #include <type_traits> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/lib/template_util.h" | 10 #include "mojo/public/cpp/bindings/lib/template_util.h" |
11 #include "mojo/public/cpp/bindings/struct_ptr.h" | 11 #include "mojo/public/cpp/bindings/struct_ptr.h" |
12 #include "mojo/public/cpp/system/core.h" | 12 #include "mojo/public/cpp/system/core.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 class String; | 15 class String; |
16 | 16 |
17 template <typename T> | 17 template <typename T> |
18 class Array; | 18 class Array; |
19 | 19 |
20 template <typename Interface> | 20 template <typename Interface> |
21 class InterfacePtr; | 21 class InterfaceHandle; |
22 | 22 |
23 template <typename Interface> | 23 template <typename Interface> |
24 class InterfaceRequest; | 24 class InterfaceRequest; |
25 | 25 |
26 template <typename K, typename V> | 26 template <typename K, typename V> |
27 class Map; | 27 class Map; |
28 | 28 |
29 namespace internal { | 29 namespace internal { |
30 template <typename T> | 30 template <typename T> |
31 class Array_Data; | 31 class Array_Data; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 }; | 205 }; |
206 template <typename H> | 206 template <typename H> |
207 struct WrapperTraits<ScopedHandleBase<H>, true, false> { | 207 struct WrapperTraits<ScopedHandleBase<H>, true, false> { |
208 using DataType = H; | 208 using DataType = H; |
209 }; | 209 }; |
210 template <typename I> | 210 template <typename I> |
211 struct WrapperTraits<InterfaceRequest<I>, true, false> { | 211 struct WrapperTraits<InterfaceRequest<I>, true, false> { |
212 using DataType = MessagePipeHandle; | 212 using DataType = MessagePipeHandle; |
213 }; | 213 }; |
214 template <typename Interface> | 214 template <typename Interface> |
215 struct WrapperTraits<InterfacePtr<Interface>, true, false> { | 215 struct WrapperTraits<InterfaceHandle<Interface>, true, false> { |
216 using DataType = Interface_Data; | 216 using DataType = Interface_Data; |
217 }; | 217 }; |
218 // Unions. | 218 // Unions. |
219 template <typename U> | 219 template <typename U> |
220 struct WrapperTraits<StructPtr<U>, true, true> { | 220 struct WrapperTraits<StructPtr<U>, true, true> { |
221 using DataType = typename U::Data_; | 221 using DataType = typename U::Data_; |
222 }; | 222 }; |
223 template <typename U> | 223 template <typename U> |
224 struct WrapperTraits<InlinedStructPtr<U>, true, true> { | 224 struct WrapperTraits<InlinedStructPtr<U>, true, true> { |
225 using DataType = typename U::Data_; | 225 using DataType = typename U::Data_; |
(...skipping 20 matching lines...) Expand all Loading... |
246 }; | 246 }; |
247 | 247 |
248 template <typename T> | 248 template <typename T> |
249 struct ValueTraits<ScopedHandleBase<T>> { | 249 struct ValueTraits<ScopedHandleBase<T>> { |
250 static bool Equals(const ScopedHandleBase<T>& a, | 250 static bool Equals(const ScopedHandleBase<T>& a, |
251 const ScopedHandleBase<T>& b) { | 251 const ScopedHandleBase<T>& b) { |
252 return (&a == &b) || (!a.is_valid() && !b.is_valid()); | 252 return (&a == &b) || (!a.is_valid() && !b.is_valid()); |
253 } | 253 } |
254 }; | 254 }; |
255 | 255 |
256 // |InterfacePtr|s hold message pipes uniquely, so they can only be equal if | 256 // |InterfaceHandle|s hold message pipes uniquely, so they can only be equal if |
257 // they're the same object or are both "invalid". | 257 // they're the same object or are both "invalid". |
258 template <typename I> | 258 template <typename I> |
259 struct ValueTraits<InterfacePtr<I>> { | 259 struct ValueTraits<InterfaceHandle<I>> { |
260 static bool Equals(const InterfacePtr<I>& a, const InterfacePtr<I>& b) { | 260 static bool Equals(const InterfaceHandle<I>& a, const InterfaceHandle<I>& b) { |
261 return (&a == &b) || (!a.is_bound() && !b.is_bound()); | 261 return (&a == &b) || (!a.is_valid() && !b.is_valid()); |
262 } | 262 } |
263 }; | 263 }; |
264 | 264 |
265 // |InterfaceRequest|s hold message pipes uniquely, so they can only be equal if | 265 // |InterfaceRequest|s hold message pipes uniquely, so they can only be equal if |
266 // they're the same object or are both "invalid". | 266 // they're the same object or are both "invalid". |
267 template <typename I> | 267 template <typename I> |
268 struct ValueTraits<InterfaceRequest<I>> { | 268 struct ValueTraits<InterfaceRequest<I>> { |
269 static bool Equals(const InterfaceRequest<I>& a, | 269 static bool Equals(const InterfaceRequest<I>& a, |
270 const InterfaceRequest<I>& b) { | 270 const InterfaceRequest<I>& b) { |
271 return (&a == &b) || (!a.is_pending() && !b.is_pending()); | 271 return (&a == &b) || (!a.is_pending() && !b.is_pending()); |
272 } | 272 } |
273 }; | 273 }; |
274 | 274 |
275 } // namespace internal | 275 } // namespace internal |
276 } // namespace mojo | 276 } // namespace mojo |
277 | 277 |
278 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 278 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |