OLD | NEW |
---|---|
1 size_t GetSerializedSize_({{union.name}}Ptr& input, | 1 {%- set mojom_type = union|get_qualified_name_for_kind %} |
2 bool inlined, | 2 {%- set data_type = union|get_qualified_name_for_kind(internal=True) %} |
3 mojo::internal::SerializationContext* context); | 3 |
4 void SerializeUnion_({{union.name}}Ptr input, | 4 namespace internal { |
5 mojo::internal::Buffer* buffer, | 5 |
6 internal::{{union.name}}_Data** output, | 6 template <typename MojomType> |
7 bool inlined, | 7 struct UnionSerializerImpl; |
8 mojo::internal::SerializationContext* context); | 8 |
9 bool Deserialize_(internal::{{union.name}}_Data* input, | 9 template <> |
10 {{union.name}}Ptr* output, | 10 struct UnionSerializerImpl<{{mojom_type}}Ptr> { |
11 mojo::internal::SerializationContext* context); | 11 static size_t PrepareToSerialize({{mojom_type}}Ptr& input, |
12 bool inlined, | |
13 SerializationContext* context); | |
14 | |
15 static void Serialize({{mojom_type}}Ptr& input, | |
Sam McNally
2016/05/09 01:14:59
Why are these taking a non-const lvalue reference?
yzshen1
2016/05/09 06:13:40
The old serialization API takes |input| by value,
Sam McNally
2016/05/09 07:02:29
I don't see why the input needs to be non-const. I
| |
16 Buffer* buffer, | |
17 {{data_type}}** output, | |
18 bool inlined, | |
19 SerializationContext* context); | |
20 | |
21 static bool Deserialize({{data_type}}* input, | |
22 {{mojom_type}}Ptr* output, | |
23 SerializationContext* context); | |
24 }; | |
25 | |
26 template <typename MaybeConstUserType> | |
27 struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> | |
28 : public UnionSerializerImpl<{{mojom_type}}Ptr> { | |
29 using UserType = typename std::remove_const<MaybeConstUserType>::type; | |
30 | |
31 static_assert(std::is_same<MaybeConstUserType, UserType>::value, | |
32 "Only support serialization of non-const Unions."); | |
33 static_assert(std::is_same<UserType, {{mojom_type}}Ptr>::value, | |
34 "Custom mapping of mojom union is not supported."); | |
35 }; | |
36 | |
37 } // namespace internal | |
OLD | NEW |