| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 !{{output}}->{{name}}.is_valid(), | 116 !{{output}}->{{name}}.is_valid(), |
| 117 {%- endif %} | 117 {%- endif %} |
| 118 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, | 118 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| 119 "invalid {{name}} in {{struct_display_name}}"); | 119 "invalid {{name}} in {{struct_display_name}}"); |
| 120 {%- endif %} | 120 {%- endif %} |
| 121 {%- elif kind|is_associated_kind %} | 121 {%- elif kind|is_associated_kind %} |
| 122 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router,
etc. | 122 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router,
etc. |
| 123 {%- if kind|is_associated_interface_kind %} | 123 {%- if kind|is_associated_interface_kind %} |
| 124 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), &
{{output}}->{{name}}); | 124 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), &
{{output}}->{{name}}); |
| 125 {%- else %} | 125 {%- else %} |
| 126 {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassH
andle(&{{input_field}}).release(); | 126 {{output}}->{{name}} = {{input_field}}.PassHandle().release(); |
| 127 {%- endif %} | 127 {%- endif %} |
| 128 {%- elif kind|is_enum_kind %} | 128 {%- elif kind|is_enum_kind %} |
| 129 {{output}}->{{name}} = static_cast<int32_t>({{input_field}}); | 129 {{output}}->{{name}} = static_cast<int32_t>({{input_field}}); |
| 130 {%- else %} | 130 {%- else %} |
| 131 {{output}}->{{name}} = {{input_field}}; | 131 {{output}}->{{name}} = {{input_field}}; |
| 132 {%- endif %} | 132 {%- endif %} |
| 133 {%- endfor %} | 133 {%- endfor %} |
| 134 {%- endmacro -%} | 134 {%- endmacro -%} |
| 135 | 135 |
| 136 {# Deserializes the specified struct. | 136 {# Deserializes the specified struct. |
| (...skipping 19 matching lines...) Expand all 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 |