| Index: mojo/public/tools/bindings/generators/go_templates/source.tmpl
 | 
| diff --git a/mojo/public/tools/bindings/generators/go_templates/source.tmpl b/mojo/public/tools/bindings/generators/go_templates/source.tmpl
 | 
| index e864d67ca8b3e220e173691ce6df5f71a56d66fe..076451d83517e2f63717d7a1986e486f67603680 100644
 | 
| --- a/mojo/public/tools/bindings/generators/go_templates/source.tmpl
 | 
| +++ b/mojo/public/tools/bindings/generators/go_templates/source.tmpl
 | 
| @@ -20,23 +20,79 @@ import (
 | 
|  {% import "interface.tmpl" as interface_macros %}
 | 
|  {% import "struct.tmpl" as struct_macros %}
 | 
|  {% import "union.tmpl" as union_macros %}
 | 
| +{% import "mojom_reference_macros.tmpl" as mojom_reference_macros %}
 | 
| +{% import "mojom_util_macros.tmpl" as util %}
 | 
|  
 | 
| -{#- Enum definitions #}
 | 
| +{#- This init function initializes a mapping between identifiers and their
 | 
| +    corresponding user-defined type. This could have been a MojomDescriptor,
 | 
| +    but since it allows Types to be unresolved, it is more complex than is
 | 
| +    necessary. It's simpler to resolve everything in codegen.
 | 
| +    It is also difficult to insert changes to the description during the
 | 
| +    process of generating each type, so this mapping is computed in Python.
 | 
| +    Note: While we may register items into the map multiple times, this is okay
 | 
| +    because the keys will match.
 | 
| +-#}
 | 
| +
 | 
| +// These IDs are the Mojom Identifiers / Type Keys.
 | 
| +// Mojom libraries importing this one will use these identifiers when building
 | 
| +// TypeReference objects.
 | 
|  {% for enum in enums %}
 | 
| -{{enum_macros.define(enum)}}
 | 
| +var ID_{{util.typeName(enum, typepkg, package)}} string = "{{util.typeName(enum, typepkg, package)}}"
 | 
| +{% endfor %}
 | 
| +{% for struct in structs %}
 | 
| +var ID_{{util.typeName(struct, typepkg, package)}} string = "{{util.typeName(struct, typepkg, package)}}"
 | 
| +{% endfor %}
 | 
| +{% for union in unions %}
 | 
| +var ID_{{util.typeName(union, typepkg, package)}} string = "{{util.typeName(union, typepkg, package)}}"
 | 
| +{% endfor %}
 | 
| +{% for interface in interfaces %}
 | 
| +var ID_{{util.typeName(interface, typepkg, package)}} string = "{{util.typeName(interface, typepkg, package)}}"
 | 
| +{% endfor %}
 | 
| +
 | 
| +{% set mapping = package|qualified(None, true) ~ 'Desc__' %}
 | 
| +var {{mapping}} = make(map[string]{{typepkg}}UserDefinedType)
 | 
| +func init() {
 | 
| +  {% for enum in enums %}
 | 
| +  {{mojom_reference_macros.registerType(mapping, typepkg, package, enum)}}
 | 
| +  {%- endfor %}
 | 
| +  {% for struct in structs %}
 | 
| +  {{mojom_reference_macros.registerType(mapping, typepkg, package, struct)}}
 | 
| +  {%- endfor %}
 | 
| +  {% for union in unions %}
 | 
| +  {{mojom_reference_macros.registerType(mapping, typepkg, package, union)}}
 | 
| +  {%- endfor %}
 | 
| +  {% for interface in interfaces %}
 | 
| +  {{mojom_reference_macros.registerType(mapping, typepkg, package, interface)}}
 | 
| +  {%- endfor %}
 | 
| +
 | 
| +  {% for mi in mojom_imports.values() %}
 | 
| +  {%- if mi ~ '.' != typepkg and mi ~ '.' != descpkg %}
 | 
| +  for s, udt := range {{mi}}.Descriptor() {
 | 
| +    {{mapping}}[s] = udt
 | 
| +  }
 | 
| +  {% endif -%}
 | 
| +  {% endfor %}
 | 
| +}
 | 
| +func Descriptor() map[string]{{typepkg}}UserDefinedType {
 | 
| +  return {{mapping}}
 | 
| +}
 | 
| +
 | 
| +{# Enum definitions #}
 | 
| +{%- for enum in enums %}
 | 
| +{{enum_macros.define(enum, typepkg, package)}}
 | 
|  {%- endfor %}
 | 
|  
 | 
|  {#- Interface definitions #}
 | 
|  {% for interface in interfaces %}
 | 
| -{{interface_macros.define(interface)}}
 | 
| +{{interface_macros.define(interface, descpkg, typepkg, package)}}
 | 
|  {%- endfor %}
 | 
|  
 | 
|  {#- Struct definitions #}
 | 
|  {% for struct in structs %}
 | 
| -{{struct_macros.define(struct)}}
 | 
| +{{struct_macros.define(struct, typepkg, package)}}
 | 
|  {%- endfor %}
 | 
|  
 | 
|  {#- Union definitions #}
 | 
|  {% for union in unions %}
 | 
| -{{union_macros.define(union)}}
 | 
| +{{union_macros.define(union, typepkg, package)}}
 | 
|  {%- endfor %}
 | 
| 
 |