Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl

Issue 1550733002: Convert Pass()→std::move() in generated Mojo bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 {%- if kind|is_union_kind %} 80 {%- if kind|is_union_kind %}
81 {{output}}->{{name}}.is_null(), 81 {{output}}->{{name}}.is_null(),
82 {%- else %} 82 {%- else %}
83 !{{output}}->{{name}}.ptr, 83 !{{output}}->{{name}}.ptr,
84 {%- endif %} 84 {%- endif %}
85 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, 85 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
86 "null {{name}} in {{struct_display_name}}"); 86 "null {{name}} in {{struct_display_name}}");
87 {%- endif %} 87 {%- endif %}
88 {%- elif kind|is_any_handle_kind or kind|is_interface_kind %} 88 {%- elif kind|is_any_handle_kind or kind|is_interface_kind %}
89 {%- if kind|is_interface_kind %} 89 {%- if kind|is_interface_kind %}
90 mojo::internal::InterfacePointerToData({{input_field}}.Pass(), &{{output}}->{{ name}}); 90 mojo::internal::InterfacePointerToData(std::move({{input_field}}), &{{output}} ->{{name}});
91 {%- elif kind|is_interface_request_kind %} 91 {%- elif kind|is_interface_request_kind %}
92 {{output}}->{{name}} = {{input_field}}.PassMessagePipe().release(); 92 {{output}}->{{name}} = {{input_field}}.PassMessagePipe().release();
93 {%- else %} 93 {%- else %}
94 {{output}}->{{name}} = {{input_field}}.release(); 94 {{output}}->{{name}} = {{input_field}}.release();
95 {%- endif %} 95 {%- endif %}
96 {%- if not kind|is_nullable_kind %} 96 {%- if not kind|is_nullable_kind %}
97 MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( 97 MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
98 {%- if kind|is_interface_kind %} 98 {%- if kind|is_interface_kind %}
99 !{{output}}->{{name}}.handle.is_valid(), 99 !{{output}}->{{name}}.handle.is_valid(),
100 {%- else %} 100 {%- else %}
101 !{{output}}->{{name}}.is_valid(), 101 !{{output}}->{{name}}.is_valid(),
102 {%- endif %} 102 {%- endif %}
103 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, 103 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
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({{input_field}}.Pass(), &{{ou tput}}->{{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 {%- else %} 113 {%- else %}
114 {{output}}->{{name}} = {{input_field}}; 114 {{output}}->{{name}} = {{input_field}};
115 {%- endif %} 115 {%- endif %}
116 {%- endfor %} 116 {%- endfor %}
117 {%- endmacro -%} 117 {%- endmacro -%}
118 118
119 {# Deserializes the specified struct. 119 {# Deserializes the specified struct.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 &{{output_field}}, 179 &{{output_field}},
180 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn dReset(&{{input}}->{{name}}))); 180 ({{context}})->router->CreateLocalEndpointHandle(mojo::internal::FetchAn dReset(&{{input}}->{{name}})));
181 {%- elif kind|is_enum_kind %} 181 {%- elif kind|is_enum_kind %}
182 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} }); 182 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} });
183 {%- else %} 183 {%- else %}
184 {{output_field}} = {{input}}->{{name}}; 184 {{output_field}} = {{input}}->{{name}};
185 {%- endif %} 185 {%- endif %}
186 {%- endfor %} 186 {%- endfor %}
187 } while (false); 187 } while (false);
188 {%- endmacro %} 188 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698