| 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 private: |
| 97 template <typename U> | 98 template <typename U> |
| 98 static YesType Test(const typename U::MojomUnionDataType*); | 99 static YesType Test(const typename U::MojomUnionDataType*); |
| 99 | 100 |
| 100 template <typename U> | 101 template <typename U> |
| 101 static NoType Test(...); | 102 static NoType Test(...); |
| 102 | 103 |
| 104 EnsureTypeIsComplete<T> check_t_; |
| 105 |
| 106 public: |
| 103 static const bool value = | 107 static const bool value = |
| 104 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; | 108 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; |
| 105 }; | 109 }; |
| 110 |
| 111 template <typename T> |
| 112 struct IsEnumDataType { |
| 113 private: |
| 114 template <typename U> |
| 115 static YesType Test(const typename U::MojomEnumDataType*); |
| 116 |
| 117 template <typename U> |
| 118 static NoType Test(...); |
| 119 |
| 120 EnsureTypeIsComplete<T> check_t_; |
| 121 |
| 122 public: |
| 123 static const bool value = |
| 124 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value; |
| 125 }; |
| 106 | 126 |
| 107 template <typename T, bool move_only = IsMoveOnlyType<T>::value> | 127 template <typename T, bool move_only = IsMoveOnlyType<T>::value> |
| 108 struct WrapperTraits; | 128 struct WrapperTraits; |
| 109 | 129 |
| 110 template <typename T> | 130 template <typename T> |
| 111 struct WrapperTraits<T, false> { | 131 struct WrapperTraits<T, false> { |
| 112 typedef T DataType; | 132 typedef T DataType; |
| 113 }; | 133 }; |
| 114 template <typename H> | 134 template <typename H> |
| 115 struct WrapperTraits<ScopedHandleBase<H>, true> { | 135 struct WrapperTraits<ScopedHandleBase<H>, true> { |
| 116 typedef H DataType; | 136 typedef H DataType; |
| 117 }; | 137 }; |
| 118 template <typename S> | 138 template <typename S> |
| 119 struct WrapperTraits<StructPtr<S>, true> { | 139 struct WrapperTraits<StructPtr<S>, true> { |
| 120 typedef typename S::Data_* DataType; | 140 typedef typename S::Data_* DataType; |
| 121 }; | 141 }; |
| 122 template <typename S> | 142 template <typename S> |
| 123 struct WrapperTraits<InlinedStructPtr<S>, true> { | 143 struct WrapperTraits<InlinedStructPtr<S>, true> { |
| 124 typedef typename S::Data_* DataType; | 144 typedef typename S::Data_* DataType; |
| 125 }; | 145 }; |
| 126 template <typename S> | 146 template <typename S> |
| 127 struct WrapperTraits<S, true> { | 147 struct WrapperTraits<S, true> { |
| 128 typedef typename S::Data_* DataType; | 148 typedef typename S::Data_* DataType; |
| 129 }; | 149 }; |
| 130 | 150 |
| 131 } // namespace internal | 151 } // namespace internal |
| 132 } // namespace mojo | 152 } // namespace mojo |
| 133 | 153 |
| 134 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 154 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
| OLD | NEW |