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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_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/struct_serialization_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
deleted file mode 100644
index 1612bbec9e571e4680dee6e0c06f7a1599915de8..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
+++ /dev/null
@@ -1,78 +0,0 @@
-size_t GetSerializedSize_(const {{struct.name}}Ptr& input) {
- if (!input)
- return 0;
- size_t size = sizeof(internal::{{struct.name}}_Data);
-{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind %}
- size += GetSerializedSize_(input->{{pf.field.name}});
-{%- endfor %}
- return size;
-}
-
-void Serialize_({{struct.name}}Ptr input, mojo::internal::Buffer* buf,
- internal::{{struct.name}}_Data** output) {
- if (input) {
- internal::{{struct.name}}_Data* result =
- internal::{{struct.name}}_Data::New(buf);
-{%- for pf in struct.packed.packed_fields %}
-{%- if pf.field.kind|is_object_kind %}
-{%- if pf.field.kind|is_array_kind %}
- mojo::SerializeArray_<{{pf.field.kind|get_array_validate_params|indent(26)}}>(
- mojo::internal::Forward(input->{{pf.field.name}}), buf, &result->{{pf.field.name}}.ptr);
-{%- elif pf.field.kind|is_map_kind %}
- mojo::SerializeMap_<{{pf.field.kind.value_kind|get_map_validate_params|indent(26)}}>(
- mojo::internal::Forward(input->{{pf.field.name}}), buf, &result->{{pf.field.name}}.ptr);
-{%- else %}
- Serialize_(mojo::internal::Forward(input->{{pf.field.name}}), buf, &result->{{pf.field.name}}.ptr);
-{%- endif %}
-{%- if not pf.field.kind|is_nullable_kind %}
- MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
- !result->{{pf.field.name}}.ptr,
- mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
- "null {{pf.field.name}} field in {{struct.name}} struct");
-{%- endif %}
-{%- elif pf.field.kind|is_any_handle_kind %}
-{%- if pf.field.kind|is_interface_kind %}
- result->{{pf.field.name}} = input->{{pf.field.name}}.PassMessagePipe().release();
-{%- else %}
- result->{{pf.field.name}} = input->{{pf.field.name}}.release();
-{%- endif %}
-{%- if not pf.field.kind|is_nullable_kind %}
- MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
- !result->{{pf.field.name}}.is_valid(),
- mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
- "invalid {{pf.field.name}} field in {{struct.name}} struct");
-{%- endif %}
-{%- else %}
- result->{{pf.field.name}} = input->{{pf.field.name}};
-{%- endif %}
-{%- endfor %}
- *output = result;
- } else {
- *output = nullptr;
- }
-}
-
-void Deserialize_(internal::{{struct.name}}_Data* input,
- {{struct.name}}Ptr* output) {
- if (input) {
- {{struct.name}}Ptr result({{struct.name}}::New());
-{%- for pf in struct.packed.packed_fields %}
-{%- if pf.field.kind|is_object_kind %}
- Deserialize_(input->{{pf.field.name}}.ptr, &result->{{pf.field.name}});
-{%- elif pf.field.kind|is_interface_kind %}
- if (input->{{pf.field.name}}.is_valid())
- result->{{pf.field.name}}.Bind(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&input->{{pf.field.name}})));
-{%- elif pf.field.kind|is_any_handle_kind %}
- result->{{pf.field.name}}.reset(mojo::internal::FetchAndReset(&input->{{pf.field.name}}));
-{%- elif pf.field.kind|is_enum_kind %}
- result->{{pf.field.name}} = static_cast<{{pf.field.kind|cpp_wrapper_type}}>(
- input->{{pf.field.name}});
-{%- else %}
- result->{{pf.field.name}} = input->{{pf.field.name}};
-{%- endif %}
-{%- endfor %}
- *output = result.Pass();
- } else {
- output->reset();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698