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" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 struct RemoveStructPtr<StructPtr<T>> { | 98 struct RemoveStructPtr<StructPtr<T>> { |
99 typedef T type; | 99 typedef T type; |
100 }; | 100 }; |
101 | 101 |
102 template <typename T> | 102 template <typename T> |
103 struct RemoveStructPtr<InlinedStructPtr<T>> { | 103 struct RemoveStructPtr<InlinedStructPtr<T>> { |
104 typedef T type; | 104 typedef T type; |
105 }; | 105 }; |
106 | 106 |
107 template <typename T> | 107 template <typename T> |
| 108 struct UnwrapStructPtr { |
| 109 static T* value(T& x) { return &x; } |
| 110 }; |
| 111 |
| 112 template <typename T> |
| 113 struct UnwrapStructPtr<StructPtr<T>> { |
| 114 static T* value(StructPtr<T>& x) { return x.get(); } |
| 115 }; |
| 116 |
| 117 template <typename T> |
| 118 struct UnwrapStructPtr<InlinedStructPtr<T>> { |
| 119 static T* value(InlinedStructPtr<T>& x) { return x.get(); } |
| 120 }; |
| 121 |
| 122 template <typename T> |
| 123 struct UnwrapConstStructPtr { |
| 124 static const T* value(const T& x) { return &x; } |
| 125 }; |
| 126 |
| 127 template <typename T> |
| 128 struct UnwrapConstStructPtr<StructPtr<T>> { |
| 129 static const T* value(const StructPtr<T>& x) { return x.get(); } |
| 130 }; |
| 131 |
| 132 template <typename T> |
| 133 struct UnwrapConstStructPtr<InlinedStructPtr<T>> { |
| 134 static const T* value(const InlinedStructPtr<T>& x) { return x.get(); } |
| 135 }; |
| 136 |
| 137 template <typename T> |
| 138 struct IsStructPtr { |
| 139 static bool const value = IsSpecializationOf<StructPtr, T>::value || |
| 140 IsSpecializationOf<InlinedStructPtr, T>::value; |
| 141 }; |
| 142 |
| 143 template <typename T> |
108 struct IsUnionWrapperType { | 144 struct IsUnionWrapperType { |
109 template <typename U> | 145 template <typename U> |
110 static YesType Test(const typename U::Data_::MojomUnionDataType*); | 146 static YesType Test(const typename U::Data_::MojomUnionDataType*); |
111 | 147 |
112 template <typename U> | 148 template <typename U> |
113 static NoType Test(...); | 149 static NoType Test(...); |
114 | 150 |
115 static const bool value = | 151 static const bool value = |
116 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; | 152 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; |
117 }; | 153 }; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 static bool Equals(const ScopedHandleBase<T>& a, | 219 static bool Equals(const ScopedHandleBase<T>& a, |
184 const ScopedHandleBase<T>& b) { | 220 const ScopedHandleBase<T>& b) { |
185 return a.get().value() == b.get().value(); | 221 return a.get().value() == b.get().value(); |
186 } | 222 } |
187 }; | 223 }; |
188 | 224 |
189 } // namespace internal | 225 } // namespace internal |
190 } // namespace mojo | 226 } // namespace mojo |
191 | 227 |
192 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 228 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |