| Index: third_party/mojo/src/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
|
| diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
|
| index b5e9c23781a297302ea397d7266f6c441eec5015..bab528c65ff8b39f0addae2d7396857d964a6b45 100644
|
| --- a/third_party/mojo/src/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
|
| +++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
|
| @@ -21,11 +21,7 @@
|
| switch (tag_) {
|
| {% for field in union.fields %}
|
| case Tag::{{field.name|upper}}:
|
| -{% if field.kind|is_object_kind %}
|
| - rv->set_{{field.name}}(*(data_.{{field.name}}));
|
| -{%- else %}
|
| rv->set_{{field.name}}(data_.{{field.name}});
|
| -{%- endif %}
|
| break;
|
| {%- endfor %}
|
| };
|
| @@ -41,11 +37,7 @@
|
| switch (tag_) {
|
| {% for field in union.fields %}
|
| case Tag::{{field.name|upper}}:
|
| -{% if field.kind|is_object_kind %}
|
| - return mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(*(data_.{{field.name}}), *(other.data_.{{field.name}}));
|
| -{%- else %}
|
| - return mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(data_.{{field.name}}, other.data_.{{field.name}});
|
| -{%- endif %}
|
| + return mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(data_.{{field.name}}, other.get_{{field.name}}());
|
| {%- endfor %}
|
| };
|
|
|
| @@ -59,20 +51,12 @@
|
|
|
| {{field.kind|cpp_result_type}} {{union.name}}::get_{{field.name}}() const {
|
| MOJO_DCHECK(tag_ == Tag::{{field.name|upper}});
|
| -{% if field.kind|is_object_kind %}
|
| - return *(data_.{{field.name}});
|
| -{%- else %}
|
| return data_.{{field.name}};
|
| -{%- endif %}
|
| }
|
|
|
| void {{union.name}}::set_{{field.name}}({{field.kind|cpp_const_wrapper_type}} {{field.name}}) {
|
| SwitchActive(Tag::{{field.name|upper}});
|
| -{% if field.kind|is_string_kind %}
|
| - *(data_.{{field.name}}) = {{field.name}};
|
| -{%- else %}
|
| data_.{{field.name}} = {{field.name}};
|
| -{%- endif %}
|
| }
|
| {%- endfor %}
|
|
|
| @@ -90,7 +74,7 @@
|
| {% for field in union.fields %}
|
| case Tag::{{field.name|upper}}:
|
| {% if field.kind|is_string_kind %}
|
| - data_.{{field.name}} = new String();
|
| + new (&data_.{{field.name}}) String();
|
| {%- endif %}
|
| break;
|
| {%- endfor %}
|
| @@ -104,7 +88,7 @@
|
| {% for field in union.fields %}
|
| case Tag::{{field.name|upper}}:
|
| {% if field.kind|is_string_kind %}
|
| - delete data_.{{field.name}};
|
| + data_.{{field.name}}.~String();
|
| {%- endif %}
|
| break;
|
| {%- endfor %}
|
|
|