| 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 3420b0b23bfb5eca5ab861efb2a21ccb5cd34fc8..005a8384767ee3a7ac4007cac3e4aace0d416398 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
|
| @@ -2,45 +2,13 @@
|
| {%- set class_name = struct.name ~ "_Data" %}
|
|
|
| // static
|
| -{{class_name}}* {{class_name}}::New(mojo::Buffer* buf, mojo::Buffer::Destructor dtor) {
|
| - return new (buf->Allocate(sizeof({{class_name}}), dtor)) {{class_name}}();
|
| +{{class_name}}* {{class_name}}::New(mojo::internal::Buffer* buf) {
|
| + return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}();
|
| }
|
|
|
| {{class_name}}::{{class_name}}() {
|
| - _header_.num_bytes = sizeof(*this);
|
| - _header_.num_fields = {{struct.packed.packed_fields|length}};
|
| -}
|
| -
|
| -size_t {{class_name}}::ComputeSize() const {
|
| - size_t result = sizeof(*this);
|
| -{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind %}
|
| - if ({{pf.field.name}}_.ptr)
|
| - result += {{pf.field.name}}_.ptr->ComputeSize();
|
| -{%- endfor %}
|
| - return result;
|
| -}
|
| -
|
| -{{class_name}}* {{class_name}}::Clone(mojo::Buffer* buf) const {
|
| - {{class_name}}* clone = New(buf);
|
| - memcpy(clone, this, sizeof(*this));
|
| -{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind %}
|
| - if ({{pf.field.name}}_.ptr)
|
| - clone->set_{{pf.field.name}}({{pf.field.name}}_.ptr->Clone(buf));
|
| -{%- endfor %}
|
| -{%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind %}
|
| - mojo::internal::ResetIfNonNull({{pf.field.name}}());
|
| -{%- endfor %}
|
| - return clone;
|
| -}
|
| -
|
| -void {{class_name}}::CloseHandles() {
|
| -{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind %}
|
| - if ({{pf.field.name}}_.ptr)
|
| - {{pf.field.name}}_.ptr->CloseHandles();
|
| -{%- endfor %}
|
| -{%- if struct|is_struct_with_handles %}
|
| - {{struct.name}}_Data_Destructor(this);
|
| -{%- endif %}
|
| + header_.num_bytes = sizeof(*this);
|
| + header_.num_fields = {{struct.packed.packed_fields|length}};
|
| }
|
|
|
| void {{class_name}}::EncodePointersAndHandles(
|
|
|