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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
deleted file mode 100644
index a29df078711d5d2666a2883d9440aeadd1896086..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
+++ /dev/null
@@ -1,67 +0,0 @@
-size_t GetSerializedSize_(const {{union.name}}Ptr& input) {
- if (!input)
- return 0;
-
- size_t size = sizeof(internal::{{union.name}}_Data);
- switch (input->which()) {
-{% for field in union.fields %}
-{% if field.kind|is_string_kind %}
- case {{union.name}}::Tag::{{field.name|upper}}:
- size += GetSerializedSize_(input->get_{{field.name}}());
- break;
-{%- endif %}
-{%- endfor %}
- default:
- break;
- }
- return size;
-}
-
-
-void Serialize_({{union.name}}Ptr input, mojo::internal::Buffer* buf,
- internal::{{union.name}}_Data** output) {
- if (input) {
- mojo::internal::UnionAccessor<{{union.name}}> input_acc(input.get());
- internal::{{union.name}}_Data* result =
- internal::{{union.name}}_Data::New(buf);
- // TODO(azani): Handle unknown and objects.
- result->tag = input->which();
- switch (input->which()) {
-{% for field in union.fields %}
- case {{union.name}}::Tag::{{field.name|upper}}:
-{% if field.kind|is_string_kind %}
- Serialize_(input_acc.data()->{{field.name}}, buf, &result->data.{{field.name}}.ptr);
-{% else %}
- result->data.{{field.name}} = input_acc.data()->{{field.name}};
-{%- endif %}
- break;
-{%- endfor %}
- }
- *output = result;
- } else {
- *output = nullptr;
- }
-}
-
-void Deserialize_(internal::{{union.name}}_Data* input,
- {{union.name}}Ptr* output) {
- if (input) {
- {{union.name}}Ptr result({{union.name}}::New());
- mojo::internal::UnionAccessor<{{union.name}}> result_acc(result.get());
- switch (input->tag) {
-{% for field in union.fields %}
- case {{union.name}}::Tag::{{field.name|upper}}:
-{% if field.kind|is_string_kind %}
- result_acc.SwitchActive({{union.name}}::Tag::{{field.name|upper}});
- Deserialize_(input->data.{{field.name}}.ptr, &result_acc.data()->{{field.name}});
-{% else %}
- result->set_{{field.name}}(input->data.{{field.name}});
-{%- endif %}
- break;
-{%- endfor %}
- }
- *output = result.Pass();
- } else {
- output->reset();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698