| Index: mojo/public/tools/bindings/generators/java_templates/java_macros.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/java_templates/java_macros.tmpl b/mojo/public/tools/bindings/generators/java_templates/java_macros.tmpl
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c677ed8f9472079924b53729a4b35317524bb37a
|
| --- /dev/null
|
| +++ b/mojo/public/tools/bindings/generators/java_templates/java_macros.tmpl
|
| @@ -0,0 +1,23 @@
|
| +{% macro build_default(module, kind, value) %}
|
| +{% if kind|is_string_kind %}
|
| +{{value|expression_to_text(module)}}
|
| +{% elif kind|is_array_kind %}
|
| +{% set _ = value|verify_token_type("ARRAY") %}
|
| +new {{kind.kind|java_type}}[] {
|
| +{% for element in value[1] %}
|
| + {{build_default(module, kind.kind, element)|indent(4)}}{%- if not loop.last %}, {% endif %}
|
| +
|
| +{% endfor %}
|
| +}
|
| +{% elif kind|is_object_kind %}
|
| +{% set _ = value|verify_token_type("OBJECT") %}
|
| + {{kind|java_type}}.newBuilder()
|
| +{% for element in value[1] %}
|
| +{% set subfield = kind.fields[loop.index0] %}
|
| + .set{{subfield.name|camelcase|capitalize_first}}({{build_default(module, subfield.kind, element)|indent(8)}})
|
| +{% endfor %}
|
| + .build()
|
| +{% else %}
|
| +({{kind|java_type}}) {{value|expression_to_text(module)}}
|
| +{% endif %}
|
| +{% endmacro %}
|
|
|