Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {%- set class_name = struct.name ~ "_Data" -%} | 1 {%- set class_name = struct.name ~ "_Data" -%} |
| 2 | 2 |
| 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}}))) {{class_name}}(); | 6 return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 static bool Validate(const void* data, | 9 static bool Validate(const void* data, |
| 10 mojo::internal::ValidationContext* validation_context); | 10 mojo::internal::ValidationContext* validation_context); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 {%- if num_fields > 0 %} | 41 {%- if num_fields > 0 %} |
| 42 {%- set last_field = struct.packed.packed_fields[num_fields - 1] %} | 42 {%- set last_field = struct.packed.packed_fields[num_fields - 1] %} |
| 43 {%- set offset = last_field.offset + last_field.size %} | 43 {%- set offset = last_field.offset + last_field.size %} |
| 44 {%- set pad = offset|get_pad(8) %} | 44 {%- set pad = offset|get_pad(8) %} |
| 45 {%- if pad > 0 %} | 45 {%- if pad > 0 %} |
| 46 uint8_t padfinal_[{{pad}}]; | 46 uint8_t padfinal_[{{pad}}]; |
| 47 {%- endif %} | 47 {%- endif %} |
| 48 {%- endif %} | 48 {%- endif %} |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 {{class_name}}(); | 51 {{class_name}}() { |
|
Fady Samuel
2016/08/03 23:44:05
Does inlining the constructor help here? Can you a
yzshen1
2016/08/03 23:58:14
It doesn't help much actually. I saw some New() ca
| |
| 52 header_.num_bytes = sizeof(*this); | |
| 53 header_.version = {{struct.versions[-1].version}}; | |
| 54 } | |
| 52 ~{{class_name}}() = delete; | 55 ~{{class_name}}() = delete; |
| 53 }; | 56 }; |
| 54 static_assert(sizeof({{class_name}}) == {{struct.versions[-1].num_bytes}}, | 57 static_assert(sizeof({{class_name}}) == {{struct.versions[-1].num_bytes}}, |
| 55 "Bad sizeof({{class_name}})"); | 58 "Bad sizeof({{class_name}})"); |
| OLD | NEW |