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

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: Created 3 years, 10 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 // Use StructPtrType to prevent the compiler from trying to compile this
4 // without being asked. 4 // without being asked.
5 StructPtrType rv(New()); 5 return StructPtrType::Struct::New(
yzshen1 2017/02/14 17:21:53 This could be "return New(" Right?
Sam McNally 2017/02/15 06:35:49 Done.
6 {%- for field in struct.fields %} 6 {%- for field in struct.fields %}
7 rv->{{field.name}} = mojo::internal::Clone({{field.name}}); 7 mojo::internal::Clone({{field.name}})
8 {%- if not loop.last -%},{%- endif %}
8 {%- endfor %} 9 {%- endfor %}
9 return rv; 10 );
10 } 11 }
11 12
12 template <typename T, 13 template <typename T,
13 typename std::enable_if<std::is_same< 14 typename std::enable_if<std::is_same<
14 T, {{struct.name}}>::value>::type*> 15 T, {{struct.name}}>::value>::type*>
15 bool {{struct.name}}::Equals(const T& other) const { 16 bool {{struct.name}}::Equals(const T& other) const {
16 {%- for field in struct.fields %} 17 {%- for field in struct.fields %}
17 if (!mojo::internal::Equals(this->{{field.name}}, other.{{field.name}})) 18 if (!mojo::internal::Equals(this->{{field.name}}, other.{{field.name}}))
18 return false; 19 return false;
19 {%- endfor %} 20 {%- endfor %}
20 return true; 21 return true;
21 } 22 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698