| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Collections_h | 5 #ifndef {{"_".join(config.protocol.namespace)}}_Collections_h |
| 6 #define Collections_h | 6 #define {{"_".join(config.protocol.namespace)}}_Collections_h |
| 7 | 7 |
| 8 #include "{{config.protocol.package}}/Forward.h" |
| 8 #include <cstddef> | 9 #include <cstddef> |
| 9 | 10 |
| 10 #if defined(__APPLE__) && !defined(_LIBCPP_VERSION) | 11 #if defined(__APPLE__) && !defined(_LIBCPP_VERSION) |
| 11 #include <map> | 12 #include <map> |
| 12 #include <set> | 13 #include <set> |
| 13 | 14 |
| 14 namespace blink { | 15 {% for namespace in config.protocol.namespace %} |
| 15 namespace protocol { | 16 namespace {{namespace}} { |
| 17 {% endfor %} |
| 16 | 18 |
| 17 template <class Key, class T> using HashMap = std::map<Key, T>; | 19 template <class Key, class T> using HashMap = std::map<Key, T>; |
| 18 template <class Key> using HashSet = std::set<Key>; | 20 template <class Key> using HashSet = std::set<Key>; |
| 19 | 21 |
| 20 } // namespace protocol | 22 {% for namespace in config.protocol.namespace %} |
| 21 } // namespace blink | 23 } // namespace {{namespace}} |
| 24 {% endfor %} |
| 22 | 25 |
| 23 #else | 26 #else |
| 24 #include <unordered_map> | 27 #include <unordered_map> |
| 25 #include <unordered_set> | 28 #include <unordered_set> |
| 26 | 29 |
| 27 namespace blink { | 30 {% for namespace in config.protocol.namespace %} |
| 28 namespace protocol { | 31 namespace {{namespace}} { |
| 32 {% endfor %} |
| 29 | 33 |
| 30 template <class Key, class T> using HashMap = std::unordered_map<Key, T>; | 34 template <class Key, class T> using HashMap = std::unordered_map<Key, T>; |
| 31 template <class Key> using HashSet = std::unordered_set<Key>; | 35 template <class Key> using HashSet = std::unordered_set<Key>; |
| 32 | 36 |
| 33 } // namespace protocol | 37 {% for namespace in config.protocol.namespace %} |
| 34 } // namespace blink | 38 } // namespace {{namespace}} |
| 39 {% endfor %} |
| 35 | 40 |
| 36 #endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) | 41 #endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) |
| 37 | 42 |
| 38 // Macro that returns a compile time constant with the length of an array, but g
ives an error if passed a non-array. | 43 // Macro that returns a compile time constant with the length of an array, but g
ives an error if passed a non-array. |
| 39 template<typename T, std::size_t Size> char (&ArrayLengthHelperFunction(T (&)[Si
ze]))[Size]; | 44 template<typename T, std::size_t Size> char (&ArrayLengthHelperFunction(T (&)[Si
ze]))[Size]; |
| 40 // GCC needs some help to deduce a 0 length array. | 45 // GCC needs some help to deduce a 0 length array. |
| 41 #if defined(__GNUC__) | 46 #if defined(__GNUC__) |
| 42 template<typename T> char (&ArrayLengthHelperFunction(T (&)[0]))[0]; | 47 template<typename T> char (&ArrayLengthHelperFunction(T (&)[0]))[0]; |
| 43 #endif | 48 #endif |
| 44 #define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) | 49 #define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) |
| 45 | 50 |
| 46 #endif // !defined(Collections_h) | 51 #endif // !defined({{"_".join(config.protocol.namespace)}}_Collections_h) |
| OLD | NEW |