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

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

Issue 2259283003: Mojo C++ bindings: share DataView class between chromium and blink variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@92_change_traits_param
Patch Set: . Created 4 years, 4 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
deleted file mode 100644
index 5394950b2dc5c8989e04f7fe24dbc79fc63cc155..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
+++ /dev/null
@@ -1,42 +0,0 @@
-{%- set mojom_type = union|get_qualified_name_for_kind %}
-
-// static
-bool UnionTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr>::Read(
- {{mojom_type}}::DataView input,
- {{mojom_type}}Ptr* output) {
- *output = {{mojom_type}}::New();
- {{mojom_type}}Ptr& result = *output;
-
- internal::UnionAccessor<{{mojom_type}}> result_acc(result.get());
- switch (input.tag()) {
-{%- for field in union.fields %}
- case {{mojom_type}}::Tag::{{field.name|upper}}: {
-{%- set name = field.name %}
-{%- set kind = field.kind %}
-{%- set serializer_type = kind|unmapped_type_for_serializer %}
-{%- if kind|is_object_kind %}
- result_acc.SwitchActive({{mojom_type}}::Tag::{{name|upper}});
- if (!input.Read{{name|under_to_camel}}(result_acc.data()->{{name}}))
- return false;
-
-{%- elif kind|is_any_handle_or_interface_kind %}
- auto result_{{name}} = input.Take{{name|under_to_camel}}();
- result->set_{{name}}(std::move(result_{{name}}));
-
-{%- elif kind|is_enum_kind %}
- decltype(result->get_{{name}}()) result_{{name}};
- if (!input.Read{{name|under_to_camel}}(&result_{{name}}))
- return false;
- result->set_{{name}}(result_{{name}});
-
-{%- else %}
- result->set_{{name}}(input.{{name}}());
-{%- endif %}
- break;
- }
-{%- endfor %}
- default:
- return false;
- }
- return true;
-}

Powered by Google App Engine
This is Rietveld 408576698