• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{%- set mojom_type = enum|get_qualified_name_for_kind(
2        flatten_nested_kind=True) %}
3
4template <>
5struct EnumTraits<{{mojom_type}}, {{mojom_type}}> {
6  static {{mojom_type}} ToMojom({{mojom_type}} input) { return input; }
7  static bool FromMojom({{mojom_type}} input, {{mojom_type}}* output) {
8    *output = input;
9    return true;
10  }
11};
12
13namespace internal {
14
15template <typename MaybeConstUserType>
16struct Serializer<{{mojom_type}}, MaybeConstUserType> {
17  using UserType = typename std::remove_const<MaybeConstUserType>::type;
18  using Traits = EnumTraits<{{mojom_type}}, UserType>;
19
20  static void Serialize(UserType input, int32_t* output) {
21    *output = static_cast<int32_t>(Traits::ToMojom(input));
22  }
23
24  static bool Deserialize(int32_t input, UserType* output) {
25    return Traits::FromMojom(static_cast<{{mojom_type}}>(input), output);
26  }
27};
28
29}  // namespace internal
30