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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Address sammc's comments and improve Blink tests Created 4 years, 2 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 {%- import "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_macros %}
2 {%- set data_view = struct|get_qualified_name_for_kind ~ "DataView" %} 2 {%- set data_view = struct|get_qualified_name_for_kind ~ "DataView" %}
3 {%- set data_type = struct|get_qualified_name_for_kind(internal=True) %} 3 {%- set data_type = struct|get_qualified_name_for_kind(internal=True) %}
4 4
5 namespace internal { 5 namespace internal {
6 6
7 template <typename MaybeConstUserType> 7 template <typename MaybeConstUserType>
8 struct Serializer<{{data_view}}, MaybeConstUserType> { 8 struct Serializer<{{data_view}}, MaybeConstUserType> {
9 using UserType = typename std::remove_const<MaybeConstUserType>::type; 9 using UserType = typename std::remove_const<MaybeConstUserType>::type;
10 using Traits = StructTraits<{{data_view}}, UserType>; 10 using Traits = StructTraits<{{data_view}}, UserType>;
(...skipping 19 matching lines...) Expand all
30 if (CallIsNullIfExists<Traits>(input)) { 30 if (CallIsNullIfExists<Traits>(input)) {
31 *output = nullptr; 31 *output = nullptr;
32 return; 32 return;
33 } 33 }
34 34
35 void* custom_context = CustomContextHelper<Traits>::GetNext(context); 35 void* custom_context = CustomContextHelper<Traits>::GetNext(context);
36 36
37 {{struct_macros.serialize( 37 {{struct_macros.serialize(
38 struct, struct.name ~ " struct", 38 struct, struct.name ~ " struct",
39 "CallWithContext(Traits::%s, input, custom_context)", "result", 39 "CallWithContext(Traits::%s, input, custom_context)", "result",
40 "buffer", "context", True)|indent(4)}} 40 "buffer", "context", True)|indent(2)}}
41 *output = result; 41 *output = result;
42 42
43 CustomContextHelper<Traits>::TearDown(input, custom_context); 43 CustomContextHelper<Traits>::TearDown(input, custom_context);
44 } 44 }
45 45
46 static bool Deserialize({{data_type}}* input, 46 static bool Deserialize({{data_type}}* input,
47 UserType* output, 47 UserType* output,
48 SerializationContext* context) { 48 SerializationContext* context) {
49 if (!input) 49 if (!input)
50 return CallSetToNullIfExists<Traits>(output); 50 return CallSetToNullIfExists<Traits>(output);
51 51
52 {{data_view}} data_view(input, context); 52 {{data_view}} data_view(input, context);
53 return Traits::Read(data_view, output); 53 return Traits::Read(data_view, output);
54 } 54 }
55 }; 55 };
56 56
57 } // namespace internal 57 } // namespace internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698