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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl

Issue 1520153002: [mojo] Allow value deserialization to fail (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-3-misc-support
Patch Set: merge Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
index f28948aab179fafae4b28a5638cafca67b68d79b..08989492631f2dd823f7b3de70b9872e1ac6112c 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
@@ -113,7 +113,8 @@
- method parameters/response parameters: the output is a list of
arguments. #}
|context| is the name of the serialization context.
-{%- macro deserialize(struct, input, output_field_pattern, context) -%}
+ |success| is the name of a bool variable to track success of the operation.
+{%- macro deserialize(struct, input, output_field_pattern, context, success) -%}
do {
// NOTE: The memory backing |{{input}}| may has be smaller than
// |sizeof(*{{input}})| if the message comes from an older version.
@@ -133,9 +134,11 @@
{%- endif %}
{%- if kind|is_object_kind %}
{%- if kind|is_union_kind %}
- Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}});
+ if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}}))
+ {{success}} = false;
{%- else %}
- Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}});
+ if (!Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}}))
+ {{success}} = false;
{%- endif %}
{%- elif kind|is_interface_kind %}
mojo::internal::InterfaceDataToPointer(&{{input}}->{{name}}, &{{output_field}});

Powered by Google App Engine
This is Rietveld 408576698