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

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

Issue 1387993002: mojo::Serialize*_() calls now propogate/return validation errors. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_macros %}
2 size_t GetSerializedSize_(const {{struct.name}}& input) { 2 size_t GetSerializedSize_(const {{struct.name}}& input) {
3 {{struct_macros.get_serialized_size(struct, "input.%s")}} 3 {{struct_macros.get_serialized_size(struct, "input.%s")}}
4 return size; 4 return size;
5 } 5 }
6 6
7 void Serialize_({{struct.name}}* input, mojo::internal::Buffer* buf, 7 mojo::internal::ValidationError Serialize_(
8 internal::{{struct.name}}_Data** output) { 8 {{struct.name}}* input,
9 mojo::internal::Buffer* buf,
10 internal::{{struct.name}}_Data** output) {
9 if (input) { 11 if (input) {
10 {{struct_macros.serialize(struct, struct.name ~ " struct", "input->%s", "res ult", "buf")|indent(2)}} 12 {{struct_macros.serialize(struct, struct.name ~ " struct", "input->%s", "res ult", "buf", true)|indent(2)}}
11 *output = result; 13 *output = result;
12 } else { 14 } else {
13 *output = nullptr; 15 *output = nullptr;
14 } 16 }
17 return mojo::internal::VALIDATION_ERROR_NONE;
15 } 18 }
16 19
17 void Deserialize_(internal::{{struct.name}}_Data* input, 20 void Deserialize_(internal::{{struct.name}}_Data* input,
18 {{struct.name}}* result) { 21 {{struct.name}}* result) {
19 if (input) { 22 if (input) {
20 {{struct_macros.deserialize(struct, "input", "result->%s")|indent(2)}} 23 {{struct_macros.deserialize(struct, "input", "result->%s")|indent(2)}}
21 } 24 }
22 } 25 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698