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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_definition.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 {%- 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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698