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

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

Issue 2207763003: Make mojo::internal::Buffer a non-virtual class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@85_3_inline_validation_context
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 = union.name ~ "_Data" -%} 1 {%- set class_name = union.name ~ "_Data" -%}
2 {%- set enum_name = union.name ~ "_Tag" -%} 2 {%- set enum_name = union.name ~ "_Tag" -%}
3 {%- import "struct_macros.tmpl" as struct_macros %} 3 {%- import "struct_macros.tmpl" as struct_macros %}
4 4
5 class {{class_name}} { 5 class {{class_name}} {
6 public: 6 public:
7 // Used to identify Mojom Union Data Classes. 7 // Used to identify Mojom Union Data Classes.
8 typedef void MojomUnionDataType; 8 typedef void MojomUnionDataType;
9 static {{class_name}}* New(mojo::internal::Buffer* buf); 9
10 static {{class_name}}* New(mojo::internal::Buffer* buf) {
11 return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}();
12 }
13
10 {{class_name}}(); 14 {{class_name}}();
11 // Do nothing in the destructor since it won't be called. 15 // Do nothing in the destructor since it won't be called.
12 ~{{class_name}}() {} 16 ~{{class_name}}() {}
13 17
14 static bool Validate(const void* data, 18 static bool Validate(const void* data,
15 mojo::internal::ValidationContext* validation_context, 19 mojo::internal::ValidationContext* validation_context,
16 bool inlined); 20 bool inlined);
17 21
18 bool is_null() const { 22 bool is_null() const {
19 return size == 0; 23 return size == 0;
(...skipping 20 matching lines...) Expand all
40 {%- endfor %} 44 {%- endfor %}
41 uint64_t unknown; 45 uint64_t unknown;
42 }; 46 };
43 47
44 uint32_t size; 48 uint32_t size;
45 {{enum_name}} tag; 49 {{enum_name}} tag;
46 Union_ data; 50 Union_ data;
47 }; 51 };
48 static_assert(sizeof({{class_name}}) == mojo::internal::kUnionDataSize, 52 static_assert(sizeof({{class_name}}) == mojo::internal::kUnionDataSize,
49 "Bad sizeof({{class_name}})"); 53 "Bad sizeof({{class_name}})");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698