| OLD | NEW |
| 1 {%- import "struct_macros.tmpl" as struct_macros %} | 1 {%- import "struct_macros.tmpl" as struct_macros %} |
| 2 {%- set class_name = struct.name ~ "_Data" %} | 2 {%- set class_name = struct.name ~ "_Data" %} |
| 3 class {{class_name}} { | 3 class {{class_name}} { |
| 4 public: | 4 public: |
| 5 static {{class_name}}* New(mojo::internal::Buffer* buf) { | 5 static {{class_name}}* New(mojo::internal::Buffer* buf) { |
| 6 return new (buf->Allocate(sizeof({{class_name}}))) | 6 return new (buf->Allocate(sizeof({{class_name}}))) |
| 7 {{class_name}}(); | 7 {{class_name}}(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 static bool Validate(const void* data, | 10 static bool Validate(const void* data, |
| 11 mojo::internal::BoundsChecker* bounds_checker) { | 11 mojo::internal::BoundsChecker* bounds_checker) { |
| 12 {{ struct_macros.validate(struct, class_name)|indent(4) }} | 12 {{ struct_macros.validate(struct, class_name)|indent(4) }} |
| 13 } | 13 } |
| 14 | 14 |
| 15 mojo::internal::StructHeader header_; | 15 mojo::internal::StructHeader header_; |
| 16 {{struct_macros.fields(struct)}} | 16 {{struct_macros.fields(struct)}} |
| 17 | 17 |
| 18 void EncodePointersAndHandles(std::vector<mojo::Handle>* handles) { | 18 void EncodePointersAndHandles(std::vector<mojo::Handle>* handles) { |
| 19 {{ struct_macros.encodes(struct)|indent(4) }} | 19 {{ struct_macros.encodes(struct)|indent(4) }} |
| 20 } | 20 } |
| 21 | 21 |
| 22 bool DecodePointersAndHandles(mojo::Message* message) { | 22 void DecodePointersAndHandles(std::vector<mojo::Handle>* handles) { |
| 23 {{ struct_macros.decodes(struct)|indent(4) }} | 23 {{ struct_macros.decodes(struct)|indent(4) }} |
| 24 return true; | |
| 25 } | 24 } |
| 26 | 25 |
| 27 private: | 26 private: |
| 28 {{class_name}}() { | 27 {{class_name}}() { |
| 29 header_.num_bytes = sizeof(*this); | 28 header_.num_bytes = sizeof(*this); |
| 30 header_.num_fields = {{struct.packed.packed_fields|length}}; | 29 header_.num_fields = {{struct.packed.packed_fields|length}}; |
| 31 } | 30 } |
| 32 }; | 31 }; |
| 33 MOJO_COMPILE_ASSERT(sizeof({{class_name}}) == {{struct.packed|struct_size}}, | 32 MOJO_COMPILE_ASSERT(sizeof({{class_name}}) == {{struct.packed|struct_size}}, |
| 34 bad_sizeof_{{class_name}}); | 33 bad_sizeof_{{class_name}}); |
| OLD | NEW |