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 <functional> |
| 11 |
| 12 #include "base/template_util.h" |
10 #include "mojo/public/cpp/bindings/interface_id.h" | 13 #include "mojo/public/cpp/bindings/interface_id.h" |
11 #include "mojo/public/cpp/bindings/lib/template_util.h" | 14 #include "mojo/public/cpp/bindings/lib/template_util.h" |
12 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/core.h" |
13 | 16 |
14 namespace mojo { | 17 namespace mojo { |
15 | 18 |
16 template <typename T> | 19 template <typename T> |
17 class Array; | 20 class Array; |
18 | 21 |
19 template <typename T> | 22 template <typename T> |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 ? MojomTypeCategory::UNION | 311 ? MojomTypeCategory::UNION |
309 : MojomTypeCategory::STRUCT; | 312 : MojomTypeCategory::STRUCT; |
310 }; | 313 }; |
311 | 314 |
312 template <typename T, MojomTypeCategory categories> | 315 template <typename T, MojomTypeCategory categories> |
313 struct BelongsTo { | 316 struct BelongsTo { |
314 static const bool value = | 317 static const bool value = |
315 static_cast<uint32_t>(MojomTypeTraits<T>::category & categories) != 0; | 318 static_cast<uint32_t>(MojomTypeTraits<T>::category & categories) != 0; |
316 }; | 319 }; |
317 | 320 |
| 321 template <typename T> |
| 322 struct EnumHashImpl { |
| 323 static_assert(std::is_enum<T>::value, "Incorrect hash function."); |
| 324 |
| 325 size_t operator()(T input) const { |
| 326 using UnderlyingType = typename base::underlying_type<T>::type; |
| 327 return std::hash<UnderlyingType>()(static_cast<UnderlyingType>(input)); |
| 328 } |
| 329 }; |
| 330 |
318 } // namespace internal | 331 } // namespace internal |
319 } // namespace mojo | 332 } // namespace mojo |
320 | 333 |
321 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ | 334 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |