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

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

Issue 1635613002: [mojo-bindings] Support reuse of native enum classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more missing public_deps Created 4 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_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 91d0bf14c12d80beda0d04d21bfe225a4fcc60e2..cb15c94a131076c6f79e45f8ef98fbfdb2ec4f68 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
@@ -16,7 +16,7 @@
{%- for pf in struct.packed.packed_fields_in_ordinal_order if pf.field.kind|is_object_kind %}
{%- set name = pf.field.name -%}
{%- set kind = pf.field.kind -%}
-{%- if kind|is_native_only_kind and kind|is_typemapped_kind %}
+{%- if kind|is_native_struct_kind and kind|is_typemapped_kind %}
size += mojo::internal::GetSerializedSizeNative_(
{{input_field_pattern|format(name)}});
{%- elif kind|is_typemapped_kind %}
@@ -54,7 +54,7 @@
{%- set kind = pf.field.kind %}
{%- if kind|is_object_kind %}
{%- if kind|is_array_kind or
- (kind|is_native_only_kind and not kind|is_typemapped_kind) %}
+ (kind|is_native_struct_kind and not kind|is_typemapped_kind) %}
const mojo::internal::ArrayValidateParams {{name}}_validate_params(
{{kind|get_array_validate_params_ctor_args|indent(10)}});
mojo::SerializeArray_(std::move({{input_field}}), {{buffer}},
@@ -64,7 +64,7 @@
{{kind.value_kind|get_map_validate_params_ctor_args|indent(10)}});
mojo::SerializeMap_(std::move({{input_field}}), {{buffer}},
&{{output}}->{{name}}.ptr, &{{name}}_validate_params);
-{%- elif kind|is_native_only_kind and kind|is_typemapped_kind %}
+{%- elif kind|is_native_struct_kind and kind|is_typemapped_kind %}
mojo::internal::SerializeNative_(
{{input_field}}, {{buffer}}, &{{output}}->{{name}}.ptr);
{%- elif kind|is_typemapped_kind %}
@@ -150,11 +150,14 @@
if ({{input}}->header_.version < {{pf.min_version}})
break;
{%- endif %}
-{%- if kind|is_native_only_kind and kind|is_typemapped_kind %}
+{%- if kind|is_native_struct_kind and kind|is_typemapped_kind %}
if (!DeserializeNative_(
{{input}}->{{name}}.ptr, &{{output_field}}, {{context}})) {
{{success}} = false;
}
+{%- elif kind|is_native_enum_kind and kind|is_typemapped_kind %}
+ {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>(
+ {{input}}->{{name}}.value);
{%- elif kind|is_typemapped_kind %}
if (!{{kind|get_name_for_kind}}_SerializerTraits_<{{kind|cpp_wrapper_type}}>
::Deserialize(

Powered by Google App Engine
This is Rietveld 408576698