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

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

Issue 1524703002: [mojo] Support native types with mojom wire format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-5-pickles
Patch Set: doc 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 cc186fb18ce35abad69562d24425b0e69f19ee23..ff9bb12ec8bbe1d062160a709e046a0db3478e2c 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
@@ -14,13 +14,19 @@
{%- macro get_serialized_size(struct, input_field_pattern) -%}
size_t size = sizeof(internal::{{struct.name}}_Data);
{%- for pf in struct.packed.packed_fields_in_ordinal_order if pf.field.kind|is_object_kind %}
-{%- if pf.field.kind|is_native_only_kind %}
+{%- set name = pf.field.name -%}
+{%- set kind = pf.field.kind -%}
+{%- if kind|is_native_only_kind %}
size += mojo::internal::GetSerializedSizeNative_(
- {{input_field_pattern|format(pf.field.name)}});
-{%- elif pf.field.kind|is_union_kind %}
- size += GetSerializedSize_({{input_field_pattern|format(pf.field.name)}}, true);
+ {{input_field_pattern|format(name)}});
+{%- elif kind|is_typemapped_kind %}
+ size +=
+ {{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}>
+ ::GetSize({{input_field_pattern|format(name)}});
+{%- elif kind|is_union_kind %}
+ size += GetSerializedSize_({{input_field_pattern|format(name)}}, true);
{%- else %}
- size += GetSerializedSize_({{input_field_pattern|format(pf.field.name)}});
+ size += GetSerializedSize_({{input_field_pattern|format(name)}});
{%- endif %}
{%- endfor %}
{%- endmacro -%}
@@ -60,6 +66,9 @@
{%- elif kind|is_native_only_kind %}
mojo::internal::SerializeNative_(
{{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr);
+{%- elif kind|is_typemapped_kind %}
+ {{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}>
+ ::Serialize({{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr);
{%- elif kind|is_union_kind %}
internal::{{kind.name}}_Data* {{name}}_ptr = &{{output}}->{{name}};
SerializeUnion_(std::move({{input_field}}), {{buffer}}, &{{name}}_ptr, true);
@@ -143,6 +152,12 @@
{{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) {
{{success}} = false;
}
+{%- elif kind|is_typemapped_kind %}
+ if (!{{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}>
+ ::Deserialize(
+ {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) {
+ {{success}} = false;
+ }
{%- elif kind|is_object_kind %}
{%- if kind|is_union_kind %}
if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}}))

Powered by Google App Engine
This is Rietveld 408576698