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

Unified Diff: mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl

Issue 141893004: Support default values for arrays of POD data types in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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
« no previous file with comments | « no previous file | mojo/public/bindings/generators/mojom_cpp_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl
diff --git a/mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl b/mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl
index 3841f4d912e4457261263ec275b142fcd9264933..e1fc09e397210c19f1470e867f696cc1fe714ace 100644
--- a/mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl
+++ b/mojo/public/bindings/generators/cpp_templates/struct_builder_definition.tmpl
@@ -9,6 +9,14 @@
{%- macro set_default(field) -%}
{%- if field.kind|is_string_kind -%}
set_{{field.name}}(mojo::String({{field.default}}));
+{%- elif field.kind|is_array_kind -%}
+{
+ {{field.kind|cpp_wrapper_type}}::Builder tmp({{field.default|length}});
+{%- for element in field.default %}
+ tmp[{{loop.index0}}] = {{element}};
+{%- endfor %}
+ set_{{field.name}}(tmp.Finish());
+}
{%- elif field.kind|is_object_kind -%}
{
{{field.kind|cpp_wrapper_type}}::Builder tmp;
« no previous file with comments | « no previous file | mojo/public/bindings/generators/mojom_cpp_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698