| OLD | NEW |
| 1 {%- import "validation_macros.tmpl" as validation_macros %} | 1 {%- import "validation_macros.tmpl" as validation_macros %} |
| 2 {%- set class_name = struct.name ~ "_Data" %} | 2 {%- set class_name = struct.name ~ "_Data" %} |
| 3 | 3 |
| 4 // static | 4 // static |
| 5 {{class_name}}* {{class_name}}::New(mojo::internal::Buffer* buf) { | |
| 6 return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}(); | |
| 7 } | |
| 8 | |
| 9 // static | |
| 10 bool {{class_name}}::Validate( | 5 bool {{class_name}}::Validate( |
| 11 const void* data, | 6 const void* data, |
| 12 mojo::internal::ValidationContext* validation_context) { | 7 mojo::internal::ValidationContext* validation_context) { |
| 13 if (!data) | 8 if (!data) |
| 14 return true; | 9 return true; |
| 15 | 10 |
| 16 if (!ValidateStructHeaderAndClaimMemory(data, validation_context)) | 11 if (!ValidateStructHeaderAndClaimMemory(data, validation_context)) |
| 17 return false; | 12 return false; |
| 18 | 13 |
| 19 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if | 14 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 {%- endif %} | 65 {%- endif %} |
| 71 {%- endfor %} | 66 {%- endfor %} |
| 72 | 67 |
| 73 return true; | 68 return true; |
| 74 } | 69 } |
| 75 | 70 |
| 76 {{class_name}}::{{class_name}}() { | 71 {{class_name}}::{{class_name}}() { |
| 77 header_.num_bytes = sizeof(*this); | 72 header_.num_bytes = sizeof(*this); |
| 78 header_.version = {{struct.versions[-1].version}}; | 73 header_.version = {{struct.versions[-1].version}}; |
| 79 } | 74 } |
| OLD | NEW |