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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.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 size_t GetSerializedSize_(const {{union.name}}Ptr& input, bool inlined) { 1 size_t GetSerializedSize_(const {{union.name}}Ptr& input, bool inlined) {
2 size_t size = 0U; 2 size_t size = 0U;
3 if (!inlined) { 3 if (!inlined) {
4 size += sizeof(internal::{{union.name}}_Data); 4 size += sizeof(internal::{{union.name}}_Data);
5 } 5 }
6 6
7 if (!input) 7 if (!input)
8 return size; 8 return size;
9 9
10 mojo::internal::UnionAccessor<{{union.name}}> input_acc(input.get()); 10 mojo::internal::UnionAccessor<{{union.name}}> input_acc(input.get());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 buf, &result->data.f_{{field.name}}.ptr, &{{field.name}}_validate_pa rams); 68 buf, &result->data.f_{{field.name}}.ptr, &{{field.name}}_validate_pa rams);
69 {%- endif %} 69 {%- endif %}
70 {% elif field.kind|is_any_handle_kind %} 70 {% elif field.kind|is_any_handle_kind %}
71 result->data.f_{{field.name}} = 71 result->data.f_{{field.name}} =
72 input_acc.data()->{{field.name}}->release().value(); 72 input_acc.data()->{{field.name}}->release().value();
73 {% elif field.kind|is_interface_kind %} 73 {% elif field.kind|is_interface_kind %}
74 mojo::internal::Interface_Data* {{field.name}} = 74 mojo::internal::Interface_Data* {{field.name}} =
75 reinterpret_cast<mojo::internal::Interface_Data*>( 75 reinterpret_cast<mojo::internal::Interface_Data*>(
76 &result->data.f_{{field.name}}); 76 &result->data.f_{{field.name}});
77 mojo::internal::InterfacePointerToData( 77 mojo::internal::InterfacePointerToData(
78 input_acc.data()->{{field.name}}->Pass(), {{field.name}}); 78 std::move(*input_acc.data()->{{field.name}}), {{field.name}});
79 {%- elif field.kind|is_associated_kind %} 79 {%- elif field.kind|is_associated_kind %}
80 // TODO(yzshen): add seralization logic for associated kinds. 80 // TODO(yzshen): add seralization logic for associated kinds.
81 {% else %} 81 {% else %}
82 result->data.f_{{field.name}} = input_acc.data()->{{field.name}}; 82 result->data.f_{{field.name}} = input_acc.data()->{{field.name}};
83 {%- endif %} 83 {%- endif %}
84 break; 84 break;
85 } 85 }
86 {%- endfor %} 86 {%- endfor %}
87 } 87 }
88 } else if (inlined) { 88 } else if (inlined) {
(...skipping 14 matching lines...) Expand all
103 switch (input->tag) { 103 switch (input->tag) {
104 {% for field in union.fields %} 104 {% for field in union.fields %}
105 case {{union.name}}::Tag::{{field.name|upper}}: { 105 case {{union.name}}::Tag::{{field.name|upper}}: {
106 {% if field.kind|is_object_kind %} 106 {% if field.kind|is_object_kind %}
107 result_acc.SwitchActive({{union.name}}::Tag::{{field.name|upper}}); 107 result_acc.SwitchActive({{union.name}}::Tag::{{field.name|upper}});
108 if (!Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{ {field.name}}, context)) 108 if (!Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{ {field.name}}, context))
109 success = false; 109 success = false;
110 {% elif field.kind|is_any_handle_kind %} 110 {% elif field.kind|is_any_handle_kind %}
111 {{field.kind|cpp_wrapper_type}}* {{field.name}} = 111 {{field.kind|cpp_wrapper_type}}* {{field.name}} =
112 reinterpret_cast<{{field.kind|cpp_wrapper_type}}*>(&input->data.f_{{ field.name}}); 112 reinterpret_cast<{{field.kind|cpp_wrapper_type}}*>(&input->data.f_{{ field.name}});
113 result->set_{{field.name}}({{field.name}}->Pass()); 113 result->set_{{field.name}}(std::move(*{{field.name}}));
114 {% elif field.kind|is_interface_kind %} 114 {% elif field.kind|is_interface_kind %}
115 {{field.kind|cpp_wrapper_type}} {{field.name}}_out; 115 {{field.kind|cpp_wrapper_type}} {{field.name}}_out;
116 mojo::internal::Interface_Data* {{field.name}}_in = 116 mojo::internal::Interface_Data* {{field.name}}_in =
117 reinterpret_cast<mojo::internal::Interface_Data*>( 117 reinterpret_cast<mojo::internal::Interface_Data*>(
118 &input->data.f_{{field.name}}); 118 &input->data.f_{{field.name}});
119 mojo::internal::InterfaceDataToPointer( 119 mojo::internal::InterfaceDataToPointer(
120 {{field.name}}_in, &{{field.name}}_out); 120 {{field.name}}_in, &{{field.name}}_out);
121 result->set_{{field.name}}({{field.name}}_out.Pass()); 121 result->set_{{field.name}}(std::move({{field.name}}_out));
122 {%- elif field.kind|is_associated_kind %} 122 {%- elif field.kind|is_associated_kind %}
123 // TODO(yzshen): add deserialization logic for associated kinds. 123 // TODO(yzshen): add deserialization logic for associated kinds.
124 {% elif field.kind|is_enum_kind %} 124 {% elif field.kind|is_enum_kind %}
125 result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>( input->data.f_{{field.name}})); 125 result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>( input->data.f_{{field.name}}));
126 {% else %} 126 {% else %}
127 result->set_{{field.name}}(input->data.f_{{field.name}}); 127 result->set_{{field.name}}(input->data.f_{{field.name}});
128 {%- endif %} 128 {%- endif %}
129 break; 129 break;
130 } 130 }
131 {%- endfor %} 131 {%- endfor %}
132 } 132 }
133 *output = result.Pass(); 133 *output = std::move(result);
134 } else { 134 } else {
135 output->reset(); 135 output->reset();
136 } 136 }
137 return success; 137 return success;
138 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698