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

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

Issue 1953493002: Mojo C++ bindings: custom type mapping for array - part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@21_simplify
Patch Set: Created 4 years, 7 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/module.h.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
index 29c99d567255a430ae278cde575af51bd4196a84..80ecdbae9e3161e33fb7695cd52c5ba3a3b97d54 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
@@ -56,6 +56,26 @@
#include "{{header}}"
{%- endfor %}
+{#--- Struct Serialization Helpers -#}
+{% for struct in structs %}
+{%- if struct|is_native_only_kind and struct|is_typemapped_kind %}
+{# This helps the array serializer understand how to serialize arrays of this
+ native-only type. #}
+
+namespace mojo {
+namespace internal {
+
+template <>
+struct GetDataTypeAsArrayElement<{{struct|cpp_wrapper_type}}> {
+ using Data = NativeStruct_Data*;
+};
+
+} // namespace internal
+} // namespace mojo
+
+{%- endif %}
+{%- endfor %}
+
{%- for namespace in namespaces_as_array %}
namespace {{namespace}} {
{%- endfor %}
@@ -172,46 +192,6 @@ typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr;
{% endif %}
{%- endfor %}
-{#--- Struct Serialization Helpers -#}
-{% for struct in structs %}
-{%- if struct|is_native_only_kind and struct|is_typemapped_kind %}
-{# This helps the array serializer understand how to serialize arrays of this
- native-only type.
- TODO(yzshen): Remove these specializations once the array serializtion code
- is refactored to be specialized with Mojom stanadard type and user type. #}
-
-{%- if variant %}
-} // namespace {{variant}}
-{%- endif %}
-{%- for namespace in namespaces_as_array|reverse %}
-} // namespace {{namespace}}
-{%- endfor %}
-
-namespace mojo {
-namespace internal {
-
-template <>
-struct ShouldUseNativeSerializer<{{struct|cpp_wrapper_type}}> {
- static const bool value = true;
-};
-
-template <>
-struct GetDataTypeAsArrayElement<{{struct|cpp_wrapper_type}}> {
- using Data = NativeStruct_Data*;
-};
-
-} // namespace internal
-} // namespace mojo
-
-{%- for namespace in namespaces_as_array %}
-namespace {{namespace}} {
-{%- endfor %}
-{%- if variant %}
-namespace {{variant}} {
-{%- endif %}
-{%- endif %}
-{%- endfor %}
-
{#--- Union Serialization Helpers -#}
{% if unions %}
{% for union in unions %}

Powered by Google App Engine
This is Rietveld 408576698