| Index: mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl
|
| index 3e6b0ade989afa0cc76c9ba643cedfaf8aca8521..9ddcc5168db21b4c8cc0d591c558dffe69a4be3d 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl
|
| @@ -57,10 +57,36 @@ void {{class_name}}::set_null() {
|
|
|
| void {{class_name}}::EncodePointersAndHandles(
|
| std::vector<mojo::Handle>* handles) {
|
| - // TODO(azani): Implement pointers and handles.
|
| + switch (tag) {
|
| +{%- for field in union.fields %}
|
| + case {{enum_name}}::{{field.name|upper}}: {
|
| +{%- if field.kind|is_object_kind and not field.kind|is_union_kind %}
|
| + mojo::internal::Encode(
|
| + reinterpret_cast<{{field.kind|cpp_field_type}}*>(&data.f_{{field.name}}),
|
| + handles);
|
| +{%- elif field.kind|is_any_handle_kind %}
|
| + mojo::internal::EncodeHandle(&data.f_{{field.name}}, handles);
|
| +{%- endif %}
|
| + return;
|
| + }
|
| +{%- endfor %}
|
| + }
|
| }
|
|
|
| void {{class_name}}::DecodePointersAndHandles(
|
| std::vector<mojo::Handle>* handles) {
|
| - // TODO(azani): Implement pointers and handles.
|
| + switch (tag) {
|
| +{%- for field in union.fields %}
|
| + case {{enum_name}}::{{field.name|upper}}: {
|
| +{%- if field.kind|is_object_kind and not field.kind|is_union_kind %}
|
| + mojo::internal::Decode(
|
| + reinterpret_cast<{{field.kind|cpp_field_type}}*>(&data.f_{{field.name}}),
|
| + handles);
|
| +{%- elif field.kind|is_any_handle_kind %}
|
| + mojo::internal::DecodeHandle(&data.f_{{field.name}}, handles);
|
| +{%- endif %}
|
| + return;
|
| + }
|
| +{%- endfor %}
|
| + }
|
| }
|
|
|