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

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

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/wrapper_class_template_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_template_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_template_definition.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..f4aa314fae9e1987503f7f92388102120e797809
--- /dev/null
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_template_definition.tmpl
@@ -0,0 +1,21 @@
+template <typename StructPtrType>
+{{struct.name}}Ptr {{struct.name}}::Clone() const {
+ // Use StructPtrType to prevent the compiler from trying to compile this
+ // without being asked.
+ StructPtrType rv(New());
+{%- for field in struct.fields %}
+ rv->{{field.name}} = mojo::internal::Clone({{field.name}});
+{%- endfor %}
+ return rv;
+}
+
+template <typename T,
+ typename std::enable_if<std::is_same<
+ T, {{struct.name}}>::value>::type*>
+bool {{struct.name}}::Equals(const T& other) const {
+{%- for field in struct.fields %}
+ if (!mojo::internal::Equals(this->{{field.name}}, other.{{field.name}}))
+ return false;
+{%- endfor %}
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698