OLD | NEW |
1 class {{struct.name}}DataView { | 1 class {{struct.name}}DataView { |
2 public: | 2 public: |
3 {{struct.name}}DataView() {} | 3 {{struct.name}}DataView() {} |
4 | 4 |
5 {{struct.name}}DataView( | 5 {{struct.name}}DataView( |
6 internal::{{struct.name}}_Data* data, | 6 internal::{{struct.name}}_Data* data, |
7 mojo::internal::SerializationContext* context) | 7 mojo::internal::SerializationContext* context) |
8 {%- if struct|requires_context_for_data_view %} | 8 {%- if struct|requires_context_for_data_view %} |
9 : data_(data), context_(context) {} | 9 : data_(data), context_(context) {} |
10 {%- else %} | 10 {%- else %} |
(...skipping 10 matching lines...) Expand all Loading... |
21 {{kind|cpp_data_view_type}}* output); | 21 {{kind|cpp_data_view_type}}* output); |
22 | 22 |
23 template <typename UserType> | 23 template <typename UserType> |
24 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) { | 24 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) { |
25 {%- if pf.min_version != 0 %} | 25 {%- if pf.min_version != 0 %} |
26 auto* pointer = data_->header_.version >= {{pf.min_version}} | 26 auto* pointer = data_->header_.version >= {{pf.min_version}} |
27 ? &data_->{{name}} : nullptr; | 27 ? &data_->{{name}} : nullptr; |
28 {%- else %} | 28 {%- else %} |
29 auto* pointer = &data_->{{name}}; | 29 auto* pointer = &data_->{{name}}; |
30 {%- endif %} | 30 {%- endif %} |
| 31 if (pointer && pointer->is_null()) |
| 32 pointer = nullptr; |
| 33 |
31 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>( | 34 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>( |
32 pointer, output, context_); | 35 pointer, output, context_); |
33 } | 36 } |
34 | 37 |
35 {%- elif kind|is_object_kind %} | 38 {%- elif kind|is_object_kind %} |
36 inline void Get{{name|under_to_camel}}DataView( | 39 inline void Get{{name|under_to_camel}}DataView( |
37 {{kind|cpp_data_view_type}}* output); | 40 {{kind|cpp_data_view_type}}* output); |
38 | 41 |
39 template <typename UserType> | 42 template <typename UserType> |
40 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) { | 43 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 112 |
110 {%- endif %} | 113 {%- endif %} |
111 {%- endfor %} | 114 {%- endfor %} |
112 private: | 115 private: |
113 internal::{{struct.name}}_Data* data_ = nullptr; | 116 internal::{{struct.name}}_Data* data_ = nullptr; |
114 {%- if struct|requires_context_for_data_view %} | 117 {%- if struct|requires_context_for_data_view %} |
115 mojo::internal::SerializationContext* context_ = nullptr; | 118 mojo::internal::SerializationContext* context_ = nullptr; |
116 {%- endif %} | 119 {%- endif %} |
117 }; | 120 }; |
118 | 121 |
OLD | NEW |