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__' %} |
+{% set temp_mapping = 'map' %} |
+ |
+var {{mapping}} = _initDescriptions(); |
+ |
+Map<String, {{typepkg}}UserDefinedType> _initDescriptions() { |
+ var {{temp_mapping}} = new Map<String, {{typepkg}}UserDefinedType>(); |
+ |
+{%- 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 %} |
+ |