| Index: mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| index ffd32222a5509fa8ad1aa4f98774b46ce6279738..a2e57084edc55efd21b3d0e243e0716f9c05418b 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| @@ -73,43 +73,6 @@ bool {{class_name}}::Validate(
|
| return true;
|
| }
|
|
|
| -void {{class_name}}::EncodePointers() {
|
| - CHECK(header_.version == {{struct.versions[-1].version}});
|
| -{%- for pf in struct.packed.packed_fields_in_ordinal_order %}
|
| -{%- if pf.field.kind|is_union_kind %}
|
| - this->{{pf.field.name}}.EncodePointers();
|
| -{%- elif pf.field.kind|is_object_kind %}
|
| - mojo::internal::Encode(&this->{{pf.field.name}});
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -}
|
| -
|
| -void {{class_name}}::DecodePointers() {
|
| - // NOTE: The memory backing |this| may be smaller than |sizeof(*this)|, if the
|
| - // message comes from an older version.
|
| -{#- Before decoding fields introduced at a certain version, we need to add
|
| - a version check, which makes sure we skip further decoding if |this|
|
| - is from an earlier version. |last_checked_version| records the last
|
| - version that we have added such version check. #}
|
| -{%- set last_checked_version = 0 %}
|
| -{%- for pf in struct.packed.packed_fields_in_ordinal_order %}
|
| -{%- set name = pf.field.name %}
|
| -{%- set kind = pf.field.kind %}
|
| -{%- if kind|is_object_kind %}
|
| -{%- if pf.min_version > last_checked_version %}
|
| -{%- set last_checked_version = pf.min_version %}
|
| - if (header_.version < {{pf.min_version}})
|
| - return;
|
| -{%- endif %}
|
| -{%- if kind|is_union_kind %}
|
| - this->{{name}}.DecodePointers();
|
| -{%- elif kind|is_object_kind %}
|
| - mojo::internal::Decode(&this->{{name}});
|
| -{%- endif %}
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -}
|
| -
|
| {{class_name}}::{{class_name}}() {
|
| header_.num_bytes = sizeof(*this);
|
| header_.version = {{struct.versions[-1].version}};
|
|
|