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