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

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

Issue 1526533002: [mojo] Add pickling support for native-only structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-4-bool-deserialize
Patch Set: 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/wrapper_class_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
index 8c61c86ab18527ffdcb80e789d8aee1a44c4e6a2..a53bb824209a8d4b6fc2b5a4b916e55490eea82f 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
@@ -25,7 +25,9 @@
{{struct.name}}Ptr {{struct.name}}::Clone() const {
{{struct.name}}Ptr rv(New());
{%- for field in struct.fields %}
-{%- if field.kind|is_object_kind and not field.kind|is_string_kind %}
+{%- if field.kind|is_typemapped_kind %}
+ NOTREACHED() << "Object cloning not supported with typemapped fields.";
yzshen1 2015/12/15 21:20:27 It seems reasonable to add support if the typemapp
Ken Rockot(use gerrit already) 2015/12/15 23:31:08 I agree we might want to, but I'd rather wait unti
+{%- elif field.kind|is_object_kind and not field.kind|is_string_kind %}
rv->{{field.name}} = {{field.name}}.Clone();
{%- else %}
rv->{{field.name}} = {{field.name}};
@@ -37,8 +39,12 @@
bool {{struct.name}}::Equals(const {{struct.name}}& other) const {
{%- for field in struct.fields %}
+{%- if field.kind|is_typemapped_kind %}
+ NOTREACHED() << "Equality testing not supported with typemapped fields.";
yzshen1 2015/12/15 21:20:27 Similarly, seems reasonable to add support if the
Ken Rockot(use gerrit already) 2015/12/15 23:31:08 Agreed
+{%- else %}
if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(this->{{field.name}}, other.{{field.name}}))
return false;
+{%- endif %}
{%- endfor %}
return true;
}

Powered by Google App Engine
This is Rietveld 408576698