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 f28948aab179fafae4b28a5638cafca67b68d79b..8f71c6566bccb10a992c8648fcefc1604a832395 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl |
@@ -16,6 +16,11 @@ |
{%- for pf in struct.packed.packed_fields_in_ordinal_order if pf.field.kind|is_object_kind %} |
{%- if pf.field.kind|is_union_kind %} |
size += GetSerializedSize_({{input_field_pattern|format(pf.field.name)}}, true); |
+{%- elif pf.field.kind|is_native_kind %} |
+ // TODO(rockot): Support sizing of native kinds. This requires adding support |
+ // to IPC::ParamTraits. It's not checked and is only used for preallocating |
+ // space, so for now we just short the size result and let the buffer grow |
+ // a little dynamically when needed. |
{%- else %} |
size += GetSerializedSize_({{input_field_pattern|format(pf.field.name)}}); |
{%- endif %} |
@@ -57,6 +62,9 @@ |
{%- elif kind|is_union_kind %} |
internal::{{kind.name}}_Data* {{name}}_ptr = &{{output}}->{{name}}; |
SerializeUnion_(std::move({{input_field}}), {{buffer}}, &{{name}}_ptr, true); |
+{%- elif kind|is_native_kind %} |
+ mojo::internal::SerializeNative_( |
+ {{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr); |
{%- else %} |
Serialize_(std::move({{input_field}}), {{buffer}}, &{{output}}->{{name}}.ptr); |
{%- endif %} |
@@ -133,9 +141,16 @@ |
{%- endif %} |
{%- if kind|is_object_kind %} |
{%- if kind|is_union_kind %} |
- Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}}); |
+ if (!Deserialize_(&{{input}}->{{name}}, &{{output_field}}, {{context}})) |
+ return false; |
+{%- elif kind|is_native_kind %} |
+ if (!DeserializeNative_( |
+ {{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) { |
+ return false; |
+ } |
{%- else %} |
- Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}}); |
+ if (!Deserialize_({{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) |
+ return false; |
{%- endif %} |
{%- elif kind|is_interface_kind %} |
mojo::internal::InterfaceDataToPointer(&{{input}}->{{name}}, &{{output_field}}); |