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

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

Issue 2689513003: Add field-initializing constructors to generated mojo structs. (Closed)
Patch Set: rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 template <typename StructPtrType> 1 template <typename StructPtrType>
2 {{struct.name}}Ptr {{struct.name}}::Clone() const { 2 {{struct.name}}Ptr {{struct.name}}::Clone() const {
3 // Use StructPtrType to prevent the compiler from trying to compile this 3 return New(
4 // without being asked.
5 StructPtrType rv(New());
6 {%- for field in struct.fields %} 4 {%- for field in struct.fields %}
7 rv->{{field.name}} = mojo::Clone({{field.name}}); 5 mojo::Clone({{field.name}})
6 {%- if not loop.last -%},{%- endif %}
8 {%- endfor %} 7 {%- endfor %}
9 return rv; 8 );
10 } 9 }
11 10
12 template <typename T, 11 template <typename T,
13 typename std::enable_if<std::is_same< 12 typename std::enable_if<std::is_same<
14 T, {{struct.name}}>::value>::type*> 13 T, {{struct.name}}>::value>::type*>
15 bool {{struct.name}}::Equals(const T& other) const { 14 bool {{struct.name}}::Equals(const T& other) const {
16 {%- for field in struct.fields %} 15 {%- for field in struct.fields %}
17 if (!mojo::internal::Equals(this->{{field.name}}, other.{{field.name}})) 16 if (!mojo::internal::Equals(this->{{field.name}}, other.{{field.name}}))
18 return false; 17 return false;
19 {%- endfor %} 18 {%- endfor %}
20 return true; 19 return true;
21 } 20 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698