| 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 |context| is the name of the serialization context. | 8 |context| is the name of the serialization context. |
| 9 |input_may_be_temp| indicates whether any input may be temporary obejcts. | 9 |input_may_be_temp| indicates whether any input may be temporary obejcts. |
| 10 We need to assign temporary objects to local variables before passing it to | 10 We need to assign temporary objects to local variables before passing it to |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 {%- if kind|is_object_kind %} | 67 {%- if kind|is_object_kind %} |
| 68 {%- set serializer_type = kind|unmapped_type_for_serializer %} | 68 {%- set serializer_type = kind|unmapped_type_for_serializer %} |
| 69 {%- set original_input_field = input_field_pattern|format(name) %} | 69 {%- set original_input_field = input_field_pattern|format(name) %} |
| 70 {%- set input_field = "in_%s"|format(name) if input_may_be_temp | 70 {%- set input_field = "in_%s"|format(name) if input_may_be_temp |
| 71 else original_input_field %} | 71 else original_input_field %} |
| 72 {%- if input_may_be_temp %} | 72 {%- if input_may_be_temp %} |
| 73 decltype({{original_input_field}}) in_{{name}} = {{original_input_field}}; | 73 decltype({{original_input_field}}) in_{{name}} = {{original_input_field}}; |
| 74 {%- endif %} | 74 {%- endif %} |
| 75 | 75 |
| 76 {%- if kind|is_array_kind or kind|is_map_kind %} | 76 {%- if kind|is_array_kind or kind|is_map_kind %} |
| 77 const mojo::internal::ArrayValidateParams {{name}}_validate_params( | 77 const mojo::internal::ContainerValidateParams {{name}}_validate_params( |
| 78 {{kind|get_array_validate_params_ctor_args|indent(10)}}); | 78 {{kind|get_container_validate_params_ctor_args|indent(10)}}); |
| 79 mojo::internal::Serialize<{{serializer_type}}>( | 79 mojo::internal::Serialize<{{serializer_type}}>( |
| 80 {{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr, | 80 {{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr, |
| 81 &{{name}}_validate_params, {{context}}); | 81 &{{name}}_validate_params, {{context}}); |
| 82 {%- elif kind|is_union_kind %} | 82 {%- elif kind|is_union_kind %} |
| 83 auto {{name}}_ptr = &{{output}}->{{name}}; | 83 auto {{name}}_ptr = &{{output}}->{{name}}; |
| 84 mojo::internal::Serialize<{{serializer_type}}>( | 84 mojo::internal::Serialize<{{serializer_type}}>( |
| 85 {{input_field}}, {{buffer}}, &{{name}}_ptr, true, {{context}}); | 85 {{input_field}}, {{buffer}}, &{{name}}_ptr, true, {{context}}); |
| 86 {%- else %} | 86 {%- else %} |
| 87 mojo::internal::Serialize<{{serializer_type}}>( | 87 mojo::internal::Serialize<{{serializer_type}}>( |
| 88 {{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr, {{context}}); | 88 {{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr, {{context}}); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (!{{input}}.Read{{name|under_to_camel}}(&{{output_field}})) | 156 if (!{{input}}.Read{{name|under_to_camel}}(&{{output_field}})) |
| 157 {{success}} = false; | 157 {{success}} = false; |
| 158 {%- elif kind|is_interface_kind or kind|is_any_handle_kind or | 158 {%- elif kind|is_interface_kind or kind|is_any_handle_kind or |
| 159 kind|is_associated_kind %} | 159 kind|is_associated_kind %} |
| 160 {{output_field}} = {{input}}.Take{{name|under_to_camel}}(); | 160 {{output_field}} = {{input}}.Take{{name|under_to_camel}}(); |
| 161 {%- else %} | 161 {%- else %} |
| 162 {{output_field}} = {{input}}.{{name}}(); | 162 {{output_field}} = {{input}}.{{name}}(); |
| 163 {%- endif %} | 163 {%- endif %} |
| 164 {%- endfor %} | 164 {%- endfor %} |
| 165 {%- endmacro %} | 165 {%- endmacro %} |
| OLD | NEW |