OLD | NEW |
1 {# TODO(yzshen): Make these templates more readable. #} | 1 {# TODO(yzshen): Make these templates more readable. #} |
2 | 2 |
3 {# Computes the serialized size for the specified struct. | 3 {# Computes the serialized size for the specified struct. |
4 |struct| is the struct definition. | 4 |struct| is the struct definition. |
5 |input_field_pattern| should be a pattern that contains one string | 5 |input_field_pattern| should be a pattern that contains one string |
6 placeholder, for example, "input->%s", "p_%s". The placeholder will be | 6 placeholder, for example, "input->%s", "p_%s". The placeholder will be |
7 substituted with struct field names to refer to the input fields. | 7 substituted with struct field names to refer to the input fields. |
8 This macro is expanded to compute seriailized size for both: | 8 This macro is expanded to compute seriailized size for both: |
9 - user-defined structs: the input is an instance of the corresponding struct | 9 - user-defined structs: the input is an instance of the corresponding struct |
10 wrapper class. | 10 wrapper class. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 {%- set output_field = output_field_pattern|format(pf.field.name) %} | 126 {%- set output_field = output_field_pattern|format(pf.field.name) %} |
127 {%- set name = pf.field.name %} | 127 {%- set name = pf.field.name %} |
128 {%- set kind = pf.field.kind %} | 128 {%- set kind = pf.field.kind %} |
129 {%- if pf.min_version > last_checked_version %} | 129 {%- if pf.min_version > last_checked_version %} |
130 {%- set last_checked_version = pf.min_version %} | 130 {%- set last_checked_version = pf.min_version %} |
131 if ({{input}}->header_.version < {{pf.min_version}}) | 131 if ({{input}}->header_.version < {{pf.min_version}}) |
132 break; | 132 break; |
133 {%- endif %} | 133 {%- endif %} |
134 {%- if kind|is_object_kind %} | 134 {%- if kind|is_object_kind %} |
135 {%- if kind|is_union_kind %} | 135 {%- if kind|is_union_kind %} |
136 Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}}); | 136 if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}})) |
| 137 return false; |
137 {%- else %} | 138 {%- else %} |
138 Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}}); | 139 if (!Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) |
| 140 return false; |
139 {%- endif %} | 141 {%- endif %} |
140 {%- elif kind|is_interface_kind %} | 142 {%- elif kind|is_interface_kind %} |
141 mojo::internal::InterfaceDataToPointer(&{{input}}->{{name}}, &{{output_field
}}); | 143 mojo::internal::InterfaceDataToPointer(&{{input}}->{{name}}, &{{output_field
}}); |
142 {%- elif kind|is_interface_request_kind %} | 144 {%- elif kind|is_interface_request_kind %} |
143 {{output_field}}.Bind(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&
{{input}}->{{name}}))); | 145 {{output_field}}.Bind(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&
{{input}}->{{name}}))); |
144 {%- elif kind|is_any_handle_kind %} | 146 {%- elif kind|is_any_handle_kind %} |
145 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); | 147 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); |
146 {%- elif kind|is_associated_interface_kind %} | 148 {%- elif kind|is_associated_interface_kind %} |
147 mojo::internal::AssociatedInterfaceDataToPtrInfo(&{{input}}->{{name}}, &{{ou
tput_field}}, ({{context}})->router.get()); | 149 mojo::internal::AssociatedInterfaceDataToPtrInfo(&{{input}}->{{name}}, &{{ou
tput_field}}, ({{context}})->router.get()); |
148 {%- elif kind|is_associated_interface_request_kind %} | 150 {%- elif kind|is_associated_interface_request_kind %} |
149 mojo::internal::AssociatedInterfaceRequestHelper::SetHandle( | 151 mojo::internal::AssociatedInterfaceRequestHelper::SetHandle( |
150 &{{output_field}}, | 152 &{{output_field}}, |
151 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); | 153 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); |
152 {%- elif kind|is_enum_kind %} | 154 {%- elif kind|is_enum_kind %} |
153 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}); | 155 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}); |
154 {%- else %} | 156 {%- else %} |
155 {{output_field}} = {{input}}->{{name}}; | 157 {{output_field}} = {{input}}->{{name}}; |
156 {%- endif %} | 158 {%- endif %} |
157 {%- endfor %} | 159 {%- endfor %} |
158 } while (false); | 160 } while (false); |
159 {%- endmacro %} | 161 {%- endmacro %} |
OLD | NEW |