Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl | 
| diff --git a/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl b/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..510194104b83d365386750da21bb7fc5bc445820 | 
| --- /dev/null | 
| +++ b/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl | 
| @@ -0,0 +1,48 @@ | 
| +// 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 -%}{# Already printed out #} | 
| 
 
azani
2015/11/24 20:02:02
In what situation would you call registerType on t
 
 | 
| +{%- elif type|is_imported_kind -%} {# Don't print. That package will do it. #} | 
| +{%- else -%} | 
| +{{type|identifier|identifier_store}} | 
| + | 
| +{%- if type|mojom_type_value(typepkg) != "" -%}{#- simple kind case: do nothing -#} | 
| +{%- elif type|is_array_kind -%} | 
| +{{registerType(mapping, typepkg, pkg, type.kind)}} | 
| +{%- elif type|is_map_kind -%} | 
| +{{registerType(mapping, typepkg, pkg, type.key_kind)}} | 
| +{{registerType(mapping, typepkg, pkg, type.value_kind)}} | 
| +{% elif type|is_enum_kind %} | 
| 
 
zra
2015/11/24 17:34:44
Maybe here and below is where the extra whitespace
 
alexfandrianto
2015/12/18 01:53:19
Done.
 
 | 
| + {{mapping}}["{{type|mojom_type_identifier}}"] = | 
| + new {{typepkg}}UserDefinedType() | 
| + ..enumType = {{type|mojom_type_identifier}}(); | 
| +{% elif type|is_struct_kind %} | 
| + {{mapping}}["{{type|mojom_type_identifier}}"] = | 
| + new {{typepkg}}UserDefinedType() | 
| + ..structType = {{type|mojom_type_identifier}}(); | 
| + {% for field in type.fields %} | 
| +{{registerType(mapping, typepkg, pkg, field.kind)}} | 
| + {% endfor %} | 
| +{% elif type|is_union_kind %} | 
| + {{mapping}}["{{type|mojom_type_identifier}}"] = | 
| + new {{typepkg}}UserDefinedType() | 
| + ..unionType = {{type|mojom_type_identifier}}(); | 
| + {% for field in type.fields %} | 
| +{{registerType(mapping, typepkg, pkg, field.kind)}} | 
| + {% endfor %} | 
| +{% elif type|is_interface_kind %} | 
| + {{mapping}}["{{type|mojom_type_identifier}}"] = | 
| + new {{typepkg}}UserDefinedType() | 
| + ..interfaceType = {{type|mojom_type_identifier}}(); | 
| + {%- for enum in type.enums %} | 
| + {{ registerType(mapping, typepkg, pkg, enum) }} | 
| + {%- endfor %} | 
| +{% elif type|is_interface_request_kind -%} {# No need to register anything #} | 
| +{%- else -%} | 
| + ERROR: UNSUPPORTED TYPE | 
| 
 
zra
2015/11/24 17:34:44
Should this case cause bindings generation to fail
 
alexfandrianto
2015/12/18 01:53:19
Changed enough such that it doesn't need to error.
 
 | 
| + {{type|identifier}} | 
| +{%- endif -%} | 
| +{%- endif -%} | 
| +{%- endmacro -%} |