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

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
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}}() : header_({sizeof(*this), {{struct.versions[-1].version}}}) {
52 }
52 ~{{class_name}}() = delete; 53 ~{{class_name}}() = delete;
53 }; 54 };
54 static_assert(sizeof({{class_name}}) == {{struct.versions[-1].num_bytes}}, 55 static_assert(sizeof({{class_name}}) == {{struct.versions[-1].num_bytes}},
55 "Bad sizeof({{class_name}})"); 56 "Bad sizeof({{class_name}})");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698