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

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

Issue 1618963006: Mojo C++ bindings: support enum validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 {%- from "enum_macros.tmpl" import is_valid_enum_def %}
2
3 {#--- Enums #}
4 {%- for enum in struct.enums -%}
5 {{is_valid_enum_def(enum, class_name=struct.name)}}
6 {%- endfor %}
7
8 // static 1 // static
9 {{struct.name}}Ptr {{struct.name}}::New() { 2 {{struct.name}}Ptr {{struct.name}}::New() {
10 {{struct.name}}Ptr rv; 3 {{struct.name}}Ptr rv;
11 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv); 4 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv);
12 return rv; 5 return rv;
13 } 6 }
14 7
15 {{struct.name}}::{{struct.name}}() 8 {{struct.name}}::{{struct.name}}()
16 {%- for field in struct.fields %} 9 {%- for field in struct.fields %}
17 {% 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 %}
(...skipping 22 matching lines...) Expand all
40 {%- if field.kind|is_typemapped_kind %} 33 {%- if field.kind|is_typemapped_kind %}
41 {# TODO(rockot): Consider adding support for native equality testing. #} 34 {# TODO(rockot): Consider adding support for native equality testing. #}
42 NOTREACHED() << "Equality testing not supported with typemapped fields."; 35 NOTREACHED() << "Equality testing not supported with typemapped fields.";
43 {%- else %} 36 {%- else %}
44 if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(this ->{{field.name}}, other.{{field.name}})) 37 if (!mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(this ->{{field.name}}, other.{{field.name}}))
45 return false; 38 return false;
46 {%- endif %} 39 {%- endif %}
47 {%- endfor %} 40 {%- endfor %}
48 return true; 41 return true;
49 } 42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698