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

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

Issue 317073005: Mojom: Add 'default' keyword for initializing structs to non-null value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 {%- macro get_default(field) -%}
2 {%- if field.default -%}
3 {{field.default|expression_to_text}}
4 {%- endif -%}
5 {%- endmacro -%}
6
7 // static 1 // static
8 {{struct.name}}Ptr {{struct.name}}::New() { 2 {{struct.name}}Ptr {{struct.name}}::New() {
9 {{struct.name}}Ptr rv; 3 {{struct.name}}Ptr rv;
10 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv); 4 mojo::internal::StructHelper<{{struct.name}}>::Initialize(&rv);
11 return rv.Pass(); 5 return rv.Pass();
12 } 6 }
13 7
14 {{struct.name}}::{{struct.name}}() 8 {{struct.name}}::{{struct.name}}()
15 {%-for field in struct.fields %} 9 {%-for field in struct.fields %}
16 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{get_default(fiel d)}}){% if not loop.last %},{% endif %} 10 {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_va lue}}){% if not loop.last %},{% endif %}
17 {%- endfor %} { 11 {%- endfor %} {
18 } 12 }
19 13
20 {{struct.name}}::~{{struct.name}}() { 14 {{struct.name}}::~{{struct.name}}() {
21 } 15 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698