OLD | NEW |
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 Loading... |
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 |
OLD | NEW |