Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1110)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_declaration.tmpl

Issue 2210673002: Improve gfx::Transform StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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}})");
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698