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

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

Issue 1618963006: Mojo C++ bindings: support enum validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
index f067e64f3674cb37afd29cf0b891ed9d27f9c82d..6fde8c9516bdea50e3867b451c4078c0b5156d69 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
@@ -79,7 +79,7 @@ void SerializeUnion_({{union.name}}Ptr input, mojo::internal::Buffer* buf,
{%- elif field.kind|is_associated_kind %}
// TODO(yzshen): add seralization logic for associated kinds.
{% elif field.kind|is_enum_kind %}
- result->data.f_{{field.name}} = static_cast<int32_t>(input_acc.data()->{{field.name}});
+ result->data.f_{{field.name}}.value = static_cast<int32_t>(input_acc.data()->{{field.name}});
{% else %}
result->data.f_{{field.name}} = input_acc.data()->{{field.name}};
{%- endif %}
@@ -124,7 +124,7 @@ bool Deserialize_(internal::{{union.name}}_Data* input,
{%- elif field.kind|is_associated_kind %}
// TODO(yzshen): add deserialization logic for associated kinds.
{% elif field.kind|is_enum_kind %}
- result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>(input->data.f_{{field.name}}));
+ result->set_{{field.name}}(static_cast<{{field.kind|cpp_wrapper_type}}>(input->data.f_{{field.name}}.value));
{% else %}
result->set_{{field.name}}(input->data.f_{{field.name}});
{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698