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

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

Issue 1550733002: Convert Pass()→std::move() in generated Mojo bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 {%- from "enum_macros.tmpl" import is_valid_enum_def %} 1 {%- from "enum_macros.tmpl" import is_valid_enum_def %}
2 2
3 {#--- Enums #} 3 {#--- Enums #}
4 {%- for enum in struct.enums -%} 4 {%- for enum in struct.enums -%}
5 {{is_valid_enum_def(enum, class_name=struct.name)}} 5 {{is_valid_enum_def(enum, class_name=struct.name)}}
6 {%- endfor %} 6 {%- endfor %}
7 7
8 // static 8 // static
9 {{struct.name}}Ptr {{struct.name}}::New() { 9 {{struct.name}}Ptr {{struct.name}}::New() {
10 {{struct.name}}Ptr rv; 10 {{struct.name}}Ptr rv;
11 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv); 11 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv);
12 return rv.Pass(); 12 return rv;
13 } 13 }
14 14
15 {{struct.name}}::{{struct.name}}() 15 {{struct.name}}::{{struct.name}}()
16 {%- for field in struct.fields %} 16 {%- for field in struct.fields %}
17 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_va lue}}){% if not loop.last %},{% endif %} 17 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_va lue}}){% if not loop.last %},{% endif %}
18 {%- endfor %} { 18 {%- endfor %} {
19 } 19 }
20 20
21 {{struct.name}}::~{{struct.name}}() { 21 {{struct.name}}::~{{struct.name}}() {
22 } 22 }
23 23
24 {% if struct|is_cloneable_kind %} 24 {% if struct|is_cloneable_kind %}
25 {{struct.name}}Ptr {{struct.name}}::Clone() const { 25 {{struct.name}}Ptr {{struct.name}}::Clone() const {
26 {{struct.name}}Ptr rv(New()); 26 {{struct.name}}Ptr rv(New());
27 {%- for field in struct.fields %} 27 {%- for field in struct.fields %}
28 {%- if field.kind|is_object_kind and not field.kind|is_string_kind %} 28 {%- if field.kind|is_object_kind and not field.kind|is_string_kind %}
29 rv->{{field.name}} = {{field.name}}.Clone(); 29 rv->{{field.name}} = {{field.name}}.Clone();
30 {%- else %} 30 {%- else %}
31 rv->{{field.name}} = {{field.name}}; 31 rv->{{field.name}} = {{field.name}};
32 {%- endif %} 32 {%- endif %}
33 {%- endfor %} 33 {%- endfor %}
34 return rv.Pass(); 34 return rv;
35 } 35 }
36 {% endif %} 36 {% endif %}
37 37
38 bool {{struct.name}}::Equals(const {{struct.name}}& other) const { 38 bool {{struct.name}}::Equals(const {{struct.name}}& other) const {
39 {%- for field in struct.fields %} 39 {%- for field in struct.fields %}
40 {%- if field.kind|is_typemapped_kind %} 40 {%- if field.kind|is_typemapped_kind %}
41 {# TODO(rockot): Consider adding support for native equality testing. #} 41 {# TODO(rockot): Consider adding support for native equality testing. #}
42 NOTREACHED() << "Equality testing not supported with typemapped fields."; 42 NOTREACHED() << "Equality testing not supported with typemapped fields.";
43 {%- else %} 43 {%- else %}
44 if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(this ->{{field.name}}, other.{{field.name}})) 44 if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(this ->{{field.name}}, other.{{field.name}}))
45 return false; 45 return false;
46 {%- endif %} 46 {%- endif %}
47 {%- endfor %} 47 {%- endfor %}
48 return true; 48 return true;
49 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698