Index: mojo/public/cpp/bindings/lib/bindings_internal.h |
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.h b/mojo/public/cpp/bindings/lib/bindings_internal.h |
index a8f95b2300bdb8143a8adecbb89afa9345f75830..c8810a6469baad436515e8016adc0b978ea937a6 100644 |
--- a/mojo/public/cpp/bindings/lib/bindings_internal.h |
+++ b/mojo/public/cpp/bindings/lib/bindings_internal.h |
@@ -76,27 +76,76 @@ struct IsHandle { |
enum { value = IsBaseOf<Handle, H>::value }; |
}; |
-template <typename T, bool move_only = IsMoveOnlyType<T>::value> |
+template <typename T> |
+struct IsUnionDataType { |
+ template <typename U> |
+ static YesType Test(const typename U::MojomUnionDataType*); |
+ |
+ template <typename U> |
+ static NoType Test(...); |
+ |
+ static const bool value = |
+ sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; |
+}; |
+ |
+template <typename T> |
+struct IsWrappedUnionPtr { |
+ static const bool value = false; |
+}; |
+ |
+template <typename S> |
+struct IsWrappedUnionPtr<StructPtr<S>> { |
yzshen1
2015/02/25 21:07:00
I feel that you could use IsUnionDataType and Wrap
azani
2015/03/03 00:44:15
Done.
|
+ template <typename U> |
+ static YesType Test(const typename U::Data_::MojomUnionDataType*); |
+ |
+ template <typename U> |
+ static NoType Test(...); |
+ |
+ static const bool value = sizeof(Test<S>(0)) == sizeof(YesType); |
+}; |
+ |
+template <typename S> |
+struct IsWrappedUnionPtr<InlinedStructPtr<S>> { |
yzshen1
2015/02/25 21:07:00
ditto.
azani
2015/03/03 00:44:15
Done.
|
+ template <typename U> |
+ static YesType Test(const typename U::Data_::MojomUnionDataType*); |
+ |
+ template <typename U> |
+ static NoType Test(...); |
+ |
+ static const bool value = sizeof(Test<S>(0)) == sizeof(YesType); |
+}; |
+ |
+template <typename T, |
+ bool move_only = IsMoveOnlyType<T>::value, |
+ bool is_union_wrapper = IsWrappedUnionPtr<T>::value> |
struct WrapperTraits; |
template <typename T> |
-struct WrapperTraits<T, false> { |
+struct WrapperTraits<T, false, false> { |
typedef T DataType; |
}; |
template <typename H> |
-struct WrapperTraits<ScopedHandleBase<H>, true> { |
+struct WrapperTraits<ScopedHandleBase<H>, true, false> { |
typedef H DataType; |
}; |
template <typename S> |
-struct WrapperTraits<StructPtr<S>, true> { |
+struct WrapperTraits<StructPtr<S>, true, false> { |
typedef typename S::Data_* DataType; |
}; |
template <typename S> |
-struct WrapperTraits<InlinedStructPtr<S>, true> { |
+struct WrapperTraits<InlinedStructPtr<S>, true, false> { |
typedef typename S::Data_* DataType; |
}; |
template <typename S> |
-struct WrapperTraits<S, true> { |
+struct WrapperTraits<StructPtr<S>, true, true> { |
+ typedef typename S::Data_ DataType; |
yzshen1
2015/02/25 21:07:00
I looked at array_serialization, and didn't see wh
azani
2015/03/03 00:44:15
Done.
|
+}; |
+template <typename S> |
+struct WrapperTraits<InlinedStructPtr<S>, true, true> { |
+ typedef typename S::Data_ DataType; |
+}; |
+template <typename S> |
+struct WrapperTraits<S, true, false> { |
typedef typename S::Data_* DataType; |
}; |