Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_declaration.tmpl

Issue 1956603002: Mojo C++ bindings: switch union to use the new serialization interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20_array_serializer
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698