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

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

Issue 649633003: Add Equals() to mojom structs and related types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 6 years, 2 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 // static 1 // static
2 {{struct.name}}Ptr {{struct.name}}::New() { 2 {{struct.name}}Ptr {{struct.name}}::New() {
3 {{struct.name}}Ptr rv; 3 {{struct.name}}Ptr rv;
4 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv); 4 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv);
5 return rv.Pass(); 5 return rv.Pass();
6 } 6 }
7 7
8 {{struct.name}}::{{struct.name}}() 8 {{struct.name}}::{{struct.name}}()
9 {%- for field in struct.fields %} 9 {%- for field in struct.fields %}
10 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_va lue}}){% if not loop.last %},{% endif %} 10 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_va lue}}){% if not loop.last %},{% endif %}
11 {%- endfor %} { 11 {%- endfor %} {
12 } 12 }
13 13
14 {{struct.name}}::~{{struct.name}}() { 14 {{struct.name}}::~{{struct.name}}() {
15 } 15 }
16
yzshen1 2014/10/14 21:47:21 (Results in two empty lines in the generated code)
16 {% if struct|is_cloneable_kind %} 17 {% if struct|is_cloneable_kind %}
17 {{struct.name}}Ptr {{struct.name}}::Clone() const { 18 {{struct.name}}Ptr {{struct.name}}::Clone() const {
18 {{struct.name}}Ptr rv(New()); 19 {{struct.name}}Ptr rv(New());
19 {%- for field in struct.fields %} 20 {%- for field in struct.fields %}
20 {%- if field.kind|is_struct_kind or field.kind|is_any_array_kind or field.ki nd|is_map_kind %} 21 {%- if field.kind|is_struct_kind or field.kind|is_any_array_kind or field.ki nd|is_map_kind %}
21 rv->{{field.name}} = {{field.name}}.Clone(); 22 rv->{{field.name}} = {{field.name}}.Clone();
22 {%- else %} 23 {%- else %}
23 rv->{{field.name}} = {{field.name}}; 24 rv->{{field.name}} = {{field.name}};
24 {%- endif %} 25 {%- endif %}
25 {%- endfor %} 26 {%- endfor %}
26 return rv.Pass(); 27 return rv.Pass();
27 } 28 }
28 {% endif %} 29 {% endif %}
30
31 bool {{struct.name}}::Equals(const {{struct.name}}& other) const {
32 {% for field in struct.fields %}
yzshen1 2014/10/14 21:47:21 nit: {%- to avoid an unnecessary empty line.
Aaron Boodman 2014/10/14 22:30:13 Done.
33 if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals({{fi eld.name}}, other.{{field.name}}))
34 return false;
35 {% endfor %}
36 return true;
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698