OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file is autogenerated by: | 5 // This file is autogenerated by: |
6 // mojo/public/tools/bindings/mojom_bindings_generator.py | 6 // mojo/public/tools/bindings/mojom_bindings_generator.py |
7 // For: | 7 // For: |
8 // {{module.path}} | 8 // {{module.path}} |
9 // | 9 // |
10 | 10 |
11 package {{package}} | 11 package {{package}} |
12 | 12 |
13 import ( | 13 import ( |
14 {% for i in imports %} | 14 {% for i in imports %} |
15 {{i}} | 15 {{i}} |
16 {% endfor %} | 16 {% endfor %} |
17 ) | 17 ) |
18 | 18 |
19 {% import "enum.tmpl" as enum_macros %} | 19 {% import "enum.tmpl" as enum_macros %} |
20 {% import "interface.tmpl" as interface_macros %} | 20 {% import "interface.tmpl" as interface_macros %} |
21 {% import "struct.tmpl" as struct_macros %} | 21 {% import "struct.tmpl" as struct_macros %} |
22 {% import "union.tmpl" as union_macros %} | 22 {% import "union.tmpl" as union_macros %} |
| 23 {% import "mojom_reference_macros.tmpl" as mojom_reference_macros %} |
| 24 {% import "mojom_util_macros.tmpl" as util %} |
23 | 25 |
24 {#- Enum definitions #} | 26 {#- This init function initializes a mapping between identifiers and their |
| 27 corresponding user-defined type. This could have been a MojomDescriptor, |
| 28 but since it allows Types to be unresolved, it is more complex than is |
| 29 necessary. It's simpler to resolve everything in codegen. |
| 30 It is also difficult to insert changes to the description during the |
| 31 process of generating each type, so this mapping is computed in Python. |
| 32 Note: While we may register items into the map multiple times, this is okay |
| 33 because the keys will match. |
| 34 -#} |
| 35 |
| 36 // These IDs are the Mojom Identifiers / Type Keys. |
| 37 // Mojom libraries importing this one will use these identifiers when building |
| 38 // TypeReference objects. |
25 {% for enum in enums %} | 39 {% for enum in enums %} |
26 {{enum_macros.define(enum)}} | 40 var ID_{{util.typeName(enum, typepkg, package)}} string = "{{util.typeName(enum,
typepkg, package)}}" |
| 41 {% endfor %} |
| 42 {% for struct in structs %} |
| 43 var ID_{{util.typeName(struct, typepkg, package)}} string = "{{util.typeName(str
uct, typepkg, package)}}" |
| 44 {% endfor %} |
| 45 {% for union in unions %} |
| 46 var ID_{{util.typeName(union, typepkg, package)}} string = "{{util.typeName(unio
n, typepkg, package)}}" |
| 47 {% endfor %} |
| 48 {% for interface in interfaces %} |
| 49 var ID_{{util.typeName(interface, typepkg, package)}} string = "{{util.typeName(
interface, typepkg, package)}}" |
| 50 {% endfor %} |
| 51 |
| 52 {% set mapping = package|qualified(None, true) ~ 'Desc__' %} |
| 53 var {{mapping}} = make(map[string]{{typepkg}}UserDefinedType) |
| 54 func init() { |
| 55 {% for enum in enums %} |
| 56 {{mojom_reference_macros.registerType(mapping, typepkg, package, enum)}} |
| 57 {%- endfor %} |
| 58 {% for struct in structs %} |
| 59 {{mojom_reference_macros.registerType(mapping, typepkg, package, struct)}} |
| 60 {%- endfor %} |
| 61 {% for union in unions %} |
| 62 {{mojom_reference_macros.registerType(mapping, typepkg, package, union)}} |
| 63 {%- endfor %} |
| 64 {% for interface in interfaces %} |
| 65 {{mojom_reference_macros.registerType(mapping, typepkg, package, interface)}} |
| 66 {%- endfor %} |
| 67 |
| 68 {% for mi in mojom_imports.values() %} |
| 69 {%- if mi ~ '.' != typepkg and mi ~ '.' != descpkg %} |
| 70 for s, udt := range {{mi}}.Descriptor() { |
| 71 {{mapping}}[s] = udt |
| 72 } |
| 73 {% endif -%} |
| 74 {% endfor %} |
| 75 } |
| 76 func Descriptor() map[string]{{typepkg}}UserDefinedType { |
| 77 return {{mapping}} |
| 78 } |
| 79 |
| 80 {# Enum definitions #} |
| 81 {%- for enum in enums %} |
| 82 {{enum_macros.define(enum, typepkg, package)}} |
27 {%- endfor %} | 83 {%- endfor %} |
28 | 84 |
29 {#- Interface definitions #} | 85 {#- Interface definitions #} |
30 {% for interface in interfaces %} | 86 {% for interface in interfaces %} |
31 {{interface_macros.define(interface)}} | 87 {{interface_macros.define(interface, descpkg, typepkg, package)}} |
32 {%- endfor %} | 88 {%- endfor %} |
33 | 89 |
34 {#- Struct definitions #} | 90 {#- Struct definitions #} |
35 {% for struct in structs %} | 91 {% for struct in structs %} |
36 {{struct_macros.define(struct)}} | 92 {{struct_macros.define(struct, typepkg, package)}} |
37 {%- endfor %} | 93 {%- endfor %} |
38 | 94 |
39 {#- Union definitions #} | 95 {#- Union definitions #} |
40 {% for union in unions %} | 96 {% for union in unions %} |
41 {{union_macros.define(union)}} | 97 {{union_macros.define(union, typepkg, package)}} |
42 {%- endfor %} | 98 {%- endfor %} |
OLD | NEW |