| Index: mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl b/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c3df9ed8b1908497bf372740eb3f452edd89efe8
|
| --- /dev/null
|
| +++ b/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +{%- macro registerType(mapping, typepkg, pkg, t) -%}
|
| +{%- if t|identifier(pkg)|identifier_check('RegisterType') -%}{# Already printed out #}
|
| +{%- elif t|package != '' -%} {# Don't print. That package will do it. #}
|
| +{%- else -%}
|
| +{{t|identifier(pkg)|identifier_store('RegisterType')}}
|
| +
|
| +{%- if t|mojom_type(typepkg) != "" -%}{#- simple kind case: do nothing -#}
|
| +{%- elif t|is_array -%}
|
| +{{registerType(mapping, typepkg, pkg, t.kind)}}
|
| +{%- elif t|is_map -%}
|
| +{{registerType(mapping, typepkg, pkg, t.key_kind)}}
|
| +{{registerType(mapping, typepkg, pkg, t.value_kind)}}
|
| +{% elif t|is_enum %}
|
| + {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeEnumType{
|
| + Value: {{t|mojom_type_identifier(pkg)}}(),
|
| + }
|
| +{% elif t|is_struct %}
|
| + {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeStructType{
|
| + Value: {{t|mojom_type_identifier(pkg)}}(),
|
| + }
|
| + {% for field in t.fields %}
|
| +{{registerType(mapping, typepkg, pkg, field.kind)}}
|
| + {% endfor %}
|
| +{% elif t|is_union %}
|
| + {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeUnionType{
|
| + Value: {{t|mojom_type_identifier(pkg)}}(),
|
| + }
|
| + {% for field in t.fields %}
|
| +{{registerType(mapping, typepkg, pkg, field.kind)}}
|
| + {% endfor %}
|
| +{% elif t|is_interface %}
|
| + {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeInterfaceType{
|
| + Value: {{t|mojom_type_identifier(pkg)}}(),
|
| + }
|
| + {% for method in t.methods %}
|
| +{{registerType(mapping, typepkg, pkg, method.param_struct)}}
|
| + {% if method.response_parameters -%}
|
| +{{registerType(mapping, typepkg, pkg, method.response_param_struct)}}
|
| + {%- endif %}
|
| + {%- endfor %}
|
| +{% elif t|is_interface_request -%} {# No need to register anything #}
|
| +{%- else -%}
|
| + ERROR: UNSUPPORTED TYPE
|
| + {{t|identifier(pkg)}}
|
| +{%- endif -%}
|
| +{%- endif -%}
|
| +{%- endmacro -%}
|
|
|