| {%- set mojom_type = enum|get_qualified_name_for_kind( |
| flatten_nested_kind=True) %} |
| |
| template <> |
| struct EnumTraits<{{mojom_type}}, {{mojom_type}}> { |
| static {{mojom_type}} ToMojom({{mojom_type}} input) { return input; } |
| static bool FromMojom({{mojom_type}} input, {{mojom_type}}* output) { |
| *output = input; |
| return true; |
| } |
| }; |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<{{mojom_type}}, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<{{mojom_type}}, UserType>; |
| |
| static void Serialize(UserType input, int32_t* output) { |
| *output = static_cast<int32_t>(Traits::ToMojom(input)); |
| } |
| |
| static bool Deserialize(int32_t input, UserType* output) { |
| return Traits::FromMojom(static_cast<{{mojom_type}}>(input), output); |
| } |
| }; |
| |
| } // namespace internal |