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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/lib/interface_id.h" | 10 #include "mojo/public/cpp/bindings/lib/interface_id.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 return temp; | 87 return temp; |
88 } | 88 } |
89 | 89 |
90 template <typename H> | 90 template <typename H> |
91 struct IsHandle { | 91 struct IsHandle { |
92 enum { value = IsBaseOf<Handle, H>::value }; | 92 enum { value = IsBaseOf<Handle, H>::value }; |
93 }; | 93 }; |
94 | 94 |
95 template <typename T> | 95 template <typename T> |
96 struct IsUnionDataType { | 96 struct IsUnionDataType { |
97 typedef char (*EnsureTypeIsComplete)[sizeof(T)]; | |
Ken Rockot(use gerrit already)
2016/01/26 15:39:20
nit: any reason not to use a c++11 alias here and
yzshen1
2016/01/26 18:16:04
Done. I also refactored a little bit. Thanks!
| |
98 | |
97 template <typename U> | 99 template <typename U> |
98 static YesType Test(const typename U::MojomUnionDataType*); | 100 static YesType Test(const typename U::MojomUnionDataType*); |
99 | 101 |
100 template <typename U> | 102 template <typename U> |
101 static NoType Test(...); | 103 static NoType Test(...); |
102 | 104 |
103 static const bool value = | 105 static const bool value = |
104 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; | 106 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; |
105 }; | 107 }; |
106 | 108 |
109 template <typename T> | |
110 struct IsEnumDataType { | |
111 typedef char (*EnsureTypeIsComplete)[sizeof(T)]; | |
112 | |
113 template <typename U> | |
114 static YesType Test(const typename U::MojomEnumDataType*); | |
115 | |
116 template <typename U> | |
117 static NoType Test(...); | |
118 | |
119 static const bool value = | |
120 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; | |
121 }; | |
122 | |
107 template <typename T, bool move_only = IsMoveOnlyType<T>::value> | 123 template <typename T, bool move_only = IsMoveOnlyType<T>::value> |
108 struct WrapperTraits; | 124 struct WrapperTraits; |
109 | 125 |
110 template <typename T> | 126 template <typename T> |
111 struct WrapperTraits<T, false> { | 127 struct WrapperTraits<T, false> { |
112 typedef T DataType; | 128 typedef T DataType; |
113 }; | 129 }; |
114 template <typename H> | 130 template <typename H> |
115 struct WrapperTraits<ScopedHandleBase<H>, true> { | 131 struct WrapperTraits<ScopedHandleBase<H>, true> { |
116 typedef H DataType; | 132 typedef H DataType; |
117 }; | 133 }; |
118 template <typename S> | 134 template <typename S> |
119 struct WrapperTraits<StructPtr<S>, true> { | 135 struct WrapperTraits<StructPtr<S>, true> { |
120 typedef typename S::Data_* DataType; | 136 typedef typename S::Data_* DataType; |
121 }; | 137 }; |
122 template <typename S> | 138 template <typename S> |
123 struct WrapperTraits<InlinedStructPtr<S>, true> { | 139 struct WrapperTraits<InlinedStructPtr<S>, true> { |
124 typedef typename S::Data_* DataType; | 140 typedef typename S::Data_* DataType; |
125 }; | 141 }; |
126 template <typename S> | 142 template <typename S> |
127 struct WrapperTraits<S, true> { | 143 struct WrapperTraits<S, true> { |
128 typedef typename S::Data_* DataType; | 144 typedef typename S::Data_* DataType; |
129 }; | 145 }; |
130 | 146 |
131 } // namespace internal | 147 } // namespace internal |
132 } // namespace mojo | 148 } // namespace mojo |
133 | 149 |
134 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 150 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |