Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl |
| diff --git a/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl |
| index c1669785120e7a7396f13051e0630082a2f1f164..8ea413694c152aba12f035688937bc5651faae7f 100644 |
| --- a/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl |
| +++ b/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl |
| @@ -6,22 +6,63 @@ const {{constant.name}} = {{constant.value|expression_to_text}}; |
| {#--- Enums #} |
| {%- from "enum_definition.tmpl" import enum_def %} |
| {%- for enum in enums %} |
| -{{ enum_def(enum) }} |
| +{{ enum_def(enum, typepkg, package) }} |
| {%- endfor %} |
| {#--- Struct definitions #} |
| {%- from "struct_definition.tmpl" import struct_def %} |
| {% for struct in structs %} |
| -{{ struct_def(struct) }} |
| +{{ struct_def(struct, typepkg, package) }} |
| {%- endfor -%} |
| {#--- Union definitions #} |
| {%- from "union_definition.tmpl" import union_def %} |
| {% for union in unions %} |
| -{{ union_def(union) }} |
| +{{ union_def(union, typepkg, package) }} |
| {%- endfor -%} |
| {#--- Interface definitions #} |
| +{% import "mojom_type_macros.tmpl" as mojom_type_macros %} |
| {%- for interface in interfaces -%} |
| {%- include "interface_definition.tmpl" %} |
| {%- endfor %} |
| + |
| +{% if should_gen_mojom_types -%} |
| + |
| +{% import "mojom_reference_macros.tmpl" as mojom_reference_macros %} |
| + |
| + |
| +{% set mapping = '_MojomDesc__' %} |
|
zra
2015/11/24 17:34:44
Trailing underscores are a bit unusual in Dart cod
alexfandrianto
2015/12/18 01:53:19
Removed trailing underscores
|
| +{% set temp_mapping = 'map' %} |
| + |
| +var {{mapping}} = _initDescriptions(); |
|
zra
2015/11/24 17:34:44
I find it a bit easier to read when globals like t
alexfandrianto
2015/12/18 01:53:19
Done.
|
| + |
| +Map<String, {{typepkg}}UserDefinedType> _initDescriptions() { |
|
zra
2015/11/24 17:34:44
In the generated code for this function there's a
alexfandrianto
2015/12/18 01:53:19
I've somehow reduced it a lot. More -'s help.
|
| + var {{temp_mapping}} = new Map<String, {{typepkg}}UserDefinedType>(); |
|
zra
2015/11/24 17:34:44
If it is not necessary to preserve iteration order
alexfandrianto
2015/12/18 01:53:19
I switched this to HashMap. To use it, I am now co
|
| + |
| +{%- for enum in enums %} |
| + {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, enum)}} |
| +{%- endfor %} |
| +{%- for struct in structs %} |
| + {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, struct)}} |
| +{%- endfor %} |
| +{%- for union in unions %} |
| + {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, union)}} |
| +{%- endfor %} |
| +{%- for interface in interfaces %} |
| + {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, interface)}} |
| +{%- endfor %} |
| + |
| +{%- for import in imports %} |
| +{{import.unique_name}}.getAllMojomTypeDefinitions().forEach((String s, {{typepkg}}UserDefinedType udt) { |
| + {{temp_mapping}}[s] = udt; |
| +}); |
| +{%- endfor %} |
| + return {{temp_mapping}}; |
| +} |
| + |
| +Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() { |
| + return {{mapping}}; |
| +} |
| +{%- endif %} |
| + |