| 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..d93f9024f3635af6c8ff60adb9cd2c047821e96e
|
| --- /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, type) -%}
|
| +{%- if type|identifier|identifier_check('RegisterType') -%}{# Already printed out #}
|
| +{%- elif type|package != '' -%} {# Don't print. That package will do it. #}
|
| +{%- else -%}
|
| +{{type|identifier|identifier_store('RegisterType')}}
|
| +
|
| +{%- if type|mojom_type(typepkg) != "" -%}{#- simple kind case: do nothing -#}
|
| +{%- elif type|is_array -%}
|
| +{{registerType(mapping, typepkg, pkg, type.kind)}}
|
| +{%- elif type|is_map -%}
|
| +{{registerType(mapping, typepkg, pkg, type.key_kind)}}
|
| +{{registerType(mapping, typepkg, pkg, type.value_kind)}}
|
| +{% elif type|is_enum %}
|
| + {{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeEnumType{
|
| + Value: {{type|mojom_type_identifier}}(),
|
| + }
|
| +{% elif type|is_struct %}
|
| + {{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeStructType{
|
| + Value: {{type|mojom_type_identifier}}(),
|
| + }
|
| + {% for field in type.fields %}
|
| +{{registerType(mapping, typepkg, pkg, field.kind)}}
|
| + {% endfor %}
|
| +{% elif type|is_union %}
|
| + {{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeUnionType{
|
| + Value: {{type|mojom_type_identifier}}(),
|
| + }
|
| + {% for field in type.fields %}
|
| +{{registerType(mapping, typepkg, pkg, field.kind)}}
|
| + {% endfor %}
|
| +{% elif type|is_interface %}
|
| + {{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeInterfaceType{
|
| + Value: {{type|mojom_type_identifier}}(),
|
| + }
|
| + {% for method in type.methods %}
|
| +{{registerType(mapping, typepkg, pkg, method.param_struct)}}
|
| + {% if method.response_parameters -%}
|
| +{{registerType(mapping, typepkg, pkg, method.response_param_struct)}}
|
| + {%- endif %}
|
| + {%- endfor %}
|
| +{% elif type|is_interface_request -%} {# No need to register anything #}
|
| +{%- else -%}
|
| + ERROR: UNSUPPORTED TYPE
|
| + {{type|identifier}}
|
| +{%- endif -%}
|
| +{%- endif -%}
|
| +{%- endmacro -%}
|
|
|