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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
index 20d676bd599f831973e38f18cfa0ba72015e47c3..29bdd8eeb95162fb4a2daf8a19ebc135bbc0c1a5 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
@@ -1,9 +1,3 @@
-{%- macro get_default(field) -%}
-{%- if field.default -%}
-{{field.default|expression_to_text}}
-{%- endif -%}
-{%- endmacro -%}
-
// static
{{struct.name}}Ptr {{struct.name}}::New() {
{{struct.name}}Ptr rv;
@@ -13,7 +7,7 @@
{{struct.name}}::{{struct.name}}()
{%-for field in struct.fields %}
- {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{get_default(field)}}){% if not loop.last %},{% endif %}
+ {% if loop.first %}:{% else %} {% endif %} {{field.name}}({{field|default_value}}){% if not loop.last %},{% endif %}
{%- endfor %} {
}

Powered by Google App Engine
This is Rietveld 408576698