| Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
|
| index b4d627a72fd9c6b20df98ccc6a595363b8a0c7d9..b191fe6d97c6ee53acc1d546ebd791986fca63ec 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
|
| @@ -38,8 +38,18 @@ class {{export_attribute}} {{union.name}} {
|
| }
|
|
|
| {% for field in union.fields %}
|
| - bool is_{{field.name}}() const;
|
| - {{field.kind|cpp_union_getter_return_type}} get_{{field.name}}() const;
|
| + bool is_{{field.name}}() const { return tag_ == Tag::{{field.name|upper}}; }
|
| +
|
| + {{field.kind|cpp_union_getter_return_type}} get_{{field.name}}() const {
|
| + DCHECK(tag_ == Tag::{{field.name|upper}});
|
| +{%- if field.kind|is_object_kind or
|
| + field.kind|is_any_handle_or_interface_kind %}
|
| + return *(data_.{{field.name}});
|
| +{%- else %}
|
| + return data_.{{field.name}};
|
| +{%- endif %}
|
| + }
|
| +
|
| void set_{{field.name}}({{field.kind|cpp_wrapper_param_type}} {{field.name}});
|
| {%- endfor %}
|
|
|
|
|