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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_macros.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
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {%- macro validate(struct, class_name) %} 1 {%- macro validate(struct, class_name) %}
2 if (!data) 2 if (!data)
3 return true; 3 return true;
4 4
5 if (!ValidateStructHeader( 5 if (!ValidateStructHeader(
6 data, sizeof({{class_name}}), 6 data, sizeof({{class_name}}),
7 {{struct.packed.packed_fields|length}}, bounds_checker)) { 7 {{struct.packed.packed_fields|length}}, bounds_checker)) {
8 return false; 8 return false;
9 } 9 }
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%} 71 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
72 mojo::internal::Encode(&{{pf.field.name}}, handles); 72 mojo::internal::Encode(&{{pf.field.name}}, handles);
73 {% endfor %} 73 {% endfor %}
74 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%} 74 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
75 mojo::internal::EncodeHandle(&{{pf.field.name}}, handles); 75 mojo::internal::EncodeHandle(&{{pf.field.name}}, handles);
76 {% endfor %} 76 {% endfor %}
77 {%- endmacro -%} 77 {%- endmacro -%}
78 78
79 {%- macro decodes(struct) -%} 79 {%- macro decodes(struct) -%}
80 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%} 80 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
81 if (!mojo::internal::Decode(&{{pf.field.name}}, message)) 81 mojo::internal::Decode(&{{pf.field.name}}, handles);
82 return false;
83 {% endfor %} 82 {% endfor %}
84 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%} 83 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
85 if (!mojo::internal::DecodeHandle(&{{pf.field.name}}, 84 mojo::internal::DecodeHandle(&{{pf.field.name}}, handles);
86 message->mutable_handles()))
87 return false;
88 {% endfor %} 85 {% endfor %}
89 {%- endmacro -%} 86 {%- endmacro -%}
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698