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

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

Issue 293983026: Mojo cpp bindings: remove redundant validation in Decode*(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 {%- import "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_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) { 5 {{class_name}}* {{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 9 // static
10 bool {{class_name}}::Validate(const void* data, 10 bool {{class_name}}::Validate(const void* data,
11 mojo::internal::BoundsChecker* bounds_checker) { 11 mojo::internal::BoundsChecker* bounds_checker) {
12 {{ struct_macros.validate(struct, class_name)|indent(2) }} 12 {{ struct_macros.validate(struct, class_name)|indent(2) }}
13 } 13 }
14 14
15 {{class_name}}::{{class_name}}() { 15 {{class_name}}::{{class_name}}() {
16 header_.num_bytes = sizeof(*this); 16 header_.num_bytes = sizeof(*this);
17 header_.num_fields = {{struct.packed.packed_fields|length}}; 17 header_.num_fields = {{struct.packed.packed_fields|length}};
18 } 18 }
19 19
20 void {{class_name}}::EncodePointersAndHandles( 20 void {{class_name}}::EncodePointersAndHandles(
21 std::vector<mojo::Handle>* handles) { 21 std::vector<mojo::Handle>* handles) {
22 {{ struct_macros.encodes(struct)|indent(2) }} 22 {{ struct_macros.encodes(struct)|indent(2) }}
23 } 23 }
24 24
25 bool {{class_name}}::DecodePointersAndHandles(mojo::Message* message) { 25 void {{class_name}}::DecodePointersAndHandles(
26 std::vector<mojo::Handle>* handles) {
26 {{ struct_macros.decodes(struct)|indent(2) }} 27 {{ struct_macros.decodes(struct)|indent(2) }}
27 return true;
28 } 28 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698