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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 "invalid {{name}} in {{struct_display_name}}"); | 104 "invalid {{name}} in {{struct_display_name}}"); |
105 {%- endif %} | 105 {%- endif %} |
106 {%- elif kind|is_associated_kind %} | 106 {%- elif kind|is_associated_kind %} |
107 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router,
etc. | 107 // TODO(yzshen): add some DCHECKs for non-nullable, is_local, correct router,
etc. |
108 {%- if kind|is_associated_interface_kind %} | 108 {%- if kind|is_associated_interface_kind %} |
109 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), &
{{output}}->{{name}}); | 109 mojo::internal::AssociatedInterfacePtrInfoToData(std::move({{input_field}}), &
{{output}}->{{name}}); |
110 {%- else %} | 110 {%- else %} |
111 {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassH
andle(&{{input_field}}).release(); | 111 {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassH
andle(&{{input_field}}).release(); |
112 {%- endif %} | 112 {%- endif %} |
113 {%- elif kind|is_enum_kind %} | 113 {%- elif kind|is_enum_kind %} |
114 {{output}}->{{name}} = static_cast<int32_t>({{input_field}}); | 114 {{output}}->{{name}}.value = static_cast<int32_t>({{input_field}}); |
115 {%- else %} | 115 {%- else %} |
116 {{output}}->{{name}} = {{input_field}}; | 116 {{output}}->{{name}} = {{input_field}}; |
117 {%- endif %} | 117 {%- endif %} |
118 {%- endfor %} | 118 {%- endfor %} |
119 {%- endmacro -%} | 119 {%- endmacro -%} |
120 | 120 |
121 {# Deserializes the specified struct. | 121 {# Deserializes the specified struct. |
122 |struct| is the struct definition. | 122 |struct| is the struct definition. |
123 |input| is the name of the input struct instance. | 123 |input| is the name of the input struct instance. |
124 |output_field_pattern| should be a pattern that contains one string | 124 |output_field_pattern| should be a pattern that contains one string |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 {{output_field}}.Bind(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&
{{input}}->{{name}}))); | 174 {{output_field}}.Bind(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&
{{input}}->{{name}}))); |
175 {%- elif kind|is_any_handle_kind %} | 175 {%- elif kind|is_any_handle_kind %} |
176 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); | 176 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); |
177 {%- elif kind|is_associated_interface_kind %} | 177 {%- elif kind|is_associated_interface_kind %} |
178 mojo::internal::AssociatedInterfaceDataToPtrInfo(&{{input}}->{{name}}, &{{ou
tput_field}}, ({{context}})->router.get()); | 178 mojo::internal::AssociatedInterfaceDataToPtrInfo(&{{input}}->{{name}}, &{{ou
tput_field}}, ({{context}})->router.get()); |
179 {%- elif kind|is_associated_interface_request_kind %} | 179 {%- elif kind|is_associated_interface_request_kind %} |
180 mojo::internal::AssociatedInterfaceRequestHelper::SetHandle( | 180 mojo::internal::AssociatedInterfaceRequestHelper::SetHandle( |
181 &{{output_field}}, | 181 &{{output_field}}, |
182 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); | 182 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn
dReset(&{{input}}->{{name}}))); |
183 {%- elif kind|is_enum_kind %} | 183 {%- elif kind|is_enum_kind %} |
184 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}); | 184 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name}
}.value); |
185 {%- else %} | 185 {%- else %} |
186 {{output_field}} = {{input}}->{{name}}; | 186 {{output_field}} = {{input}}->{{name}}; |
187 {%- endif %} | 187 {%- endif %} |
188 {%- endfor %} | 188 {%- endfor %} |
189 } while (false); | 189 } while (false); |
190 {%- endmacro %} | 190 {%- endmacro %} |
OLD | NEW |