| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 {%- set last_checked_version = 0 %} | 142 {%- set last_checked_version = 0 %} |
| 143 {%- for pf in struct.packed.packed_fields_in_ordinal_order %} | 143 {%- for pf in struct.packed.packed_fields_in_ordinal_order %} |
| 144 {%- set output_field = output_field_pattern|format(pf.field.name) %} | 144 {%- set output_field = output_field_pattern|format(pf.field.name) %} |
| 145 {%- set name = pf.field.name %} | 145 {%- set name = pf.field.name %} |
| 146 {%- set kind = pf.field.kind %} | 146 {%- set kind = pf.field.kind %} |
| 147 {%- if pf.min_version > last_checked_version %} | 147 {%- if pf.min_version > last_checked_version %} |
| 148 {%- set last_checked_version = pf.min_version %} | 148 {%- set last_checked_version = pf.min_version %} |
| 149 if ({{input}}->header_.version < {{pf.min_version}}) | 149 if ({{input}}->header_.version < {{pf.min_version}}) |
| 150 break; | 150 break; |
| 151 {%- endif %} | 151 {%- endif %} |
| 152 {%- if kind|is_native_only_kind %} | 152 {%- if kind|is_native_only_kind and kind|is_struct_kind %} |
| 153 if (!DeserializeNative_( | 153 if (!DeserializeNative_( |
| 154 {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) { | 154 {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) { |
| 155 {{success}} = false; | 155 {{success}} = false; |
| 156 } | 156 } |
| 157 {%- elif kind|is_native_only_kind and kind|is_enum_kind %} |
| 158 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>( |
| 159 {{input}}->{{name}}); |
| 157 {%- elif kind|is_typemapped_kind %} | 160 {%- elif kind|is_typemapped_kind %} |
| 158 if (!{{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}> | 161 if (!{{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}> |
| 159 ::Deserialize( | 162 ::Deserialize( |
| 160 {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) { | 163 {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) { |
| 161 {{success}} = false; | 164 {{success}} = false; |
| 162 } | 165 } |
| 163 {%- elif kind|is_object_kind %} | 166 {%- elif kind|is_object_kind %} |
| 164 {%- if kind|is_union_kind %} | 167 {%- if kind|is_union_kind %} |
| 165 if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}})) | 168 if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}})) |
| 166 {{success}} = false; | 169 {{success}} = false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 181 &{{output_field}}, | 184 &{{output_field}}, |
| 182 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); | 185 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); |
| 183 {%- elif kind|is_enum_kind %} | 186 {%- elif kind|is_enum_kind %} |
| 184 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}); | 187 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}); |
| 185 {%- else %} | 188 {%- else %} |
| 186 {{output_field}} = {{input}}->{{name}}; | 189 {{output_field}} = {{input}}->{{name}}; |
| 187 {%- endif %} | 190 {%- endif %} |
| 188 {%- endfor %} | 191 {%- endfor %} |
| 189 } while (false); | 192 } while (false); |
| 190 {%- endmacro %} | 193 {%- endmacro %} |
| OLD | NEW |