| OLD | NEW |
| 1 {%- set mojom_type = union|get_qualified_name_for_kind %} | 1 {%- set mojom_type = union|get_qualified_name_for_kind %} |
| 2 {%- set data_type = union|get_qualified_name_for_kind(internal=True) %} | 2 {%- set data_type = union|get_qualified_name_for_kind(internal=True) %} |
| 3 | 3 |
| 4 namespace internal { | 4 namespace internal { |
| 5 | 5 |
| 6 template <typename MojomType> | 6 template <typename MojomType> |
| 7 struct UnionSerializerImpl; | 7 struct UnionSerializerImpl; |
| 8 | 8 |
| 9 template <> | 9 template <> |
| 10 struct UnionSerializerImpl<{{mojom_type}}Ptr> { | 10 struct {{export_attribute}} UnionSerializerImpl<{{mojom_type}}Ptr> { |
| 11 static size_t PrepareToSerialize({{mojom_type}}Ptr& input, | 11 static size_t PrepareToSerialize({{mojom_type}}Ptr& input, |
| 12 bool inlined, | 12 bool inlined, |
| 13 SerializationContext* context); | 13 SerializationContext* context); |
| 14 | 14 |
| 15 static void Serialize({{mojom_type}}Ptr& input, | 15 static void Serialize({{mojom_type}}Ptr& input, |
| 16 Buffer* buffer, | 16 Buffer* buffer, |
| 17 {{data_type}}** output, | 17 {{data_type}}** output, |
| 18 bool inlined, | 18 bool inlined, |
| 19 SerializationContext* context); | 19 SerializationContext* context); |
| 20 | 20 |
| 21 static bool Deserialize({{data_type}}* input, | 21 static bool Deserialize({{data_type}}* input, |
| 22 {{mojom_type}}Ptr* output, | 22 {{mojom_type}}Ptr* output, |
| 23 SerializationContext* context); | 23 SerializationContext* context); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 template <typename MaybeConstUserType> | 26 template <typename MaybeConstUserType> |
| 27 struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> | 27 struct {{export_attribute}} Serializer<{{mojom_type}}Ptr, MaybeConstUserType> |
| 28 : public UnionSerializerImpl<{{mojom_type}}Ptr> { | 28 : public UnionSerializerImpl<{{mojom_type}}Ptr> { |
| 29 using UserType = typename std::remove_const<MaybeConstUserType>::type; | 29 using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| 30 | 30 |
| 31 static_assert(std::is_same<MaybeConstUserType, UserType>::value, | 31 static_assert(std::is_same<MaybeConstUserType, UserType>::value, |
| 32 "Only support serialization of non-const Unions."); | 32 "Only support serialization of non-const Unions."); |
| 33 static_assert(std::is_same<UserType, {{mojom_type}}Ptr>::value, | 33 static_assert(std::is_same<UserType, {{mojom_type}}Ptr>::value, |
| 34 "Custom mapping of mojom union is not supported."); | 34 "Custom mapping of mojom union is not supported."); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 } // namespace internal | 37 } // namespace internal |
| OLD | NEW |