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 |
3 // static | 4 // static |
4 {{class_name}}* {{class_name}}::New(mojo::Buffer* buf, mojo::Buffer::Destructor
dtor) { | 5 {{class_name}}* {{class_name}}::New(mojo::Buffer* buf, mojo::Buffer::Destructor
dtor) { |
5 return new (buf->Allocate(sizeof({{class_name}}), dtor)) {{class_name}}(); | 6 return new (buf->Allocate(sizeof({{class_name}}), dtor)) {{class_name}}(); |
6 } | 7 } |
7 | 8 |
8 {{class_name}}::{{class_name}}() { | 9 {{class_name}}::{{class_name}}() { |
9 _header_.num_bytes = sizeof(*this); | 10 _header_.num_bytes = sizeof(*this); |
10 _header_.num_fields = {{struct.packed.packed_fields|length}}; | 11 _header_.num_fields = {{struct.packed.packed_fields|length}}; |
11 } | 12 } |
12 | 13 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 45 |
45 void {{class_name}}::EncodePointersAndHandles( | 46 void {{class_name}}::EncodePointersAndHandles( |
46 std::vector<mojo::Handle>* handles) { | 47 std::vector<mojo::Handle>* handles) { |
47 {{ struct_macros.encodes(struct)|indent(2) }} | 48 {{ struct_macros.encodes(struct)|indent(2) }} |
48 } | 49 } |
49 | 50 |
50 bool {{class_name}}::DecodePointersAndHandles(mojo::Message* message) { | 51 bool {{class_name}}::DecodePointersAndHandles(mojo::Message* message) { |
51 {{ struct_macros.decodes(struct)|indent(2) }} | 52 {{ struct_macros.decodes(struct)|indent(2) }} |
52 return true; | 53 return true; |
53 } | 54 } |
OLD | NEW |