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 %} |
23 | 24 |
24 {#- Enum definitions #} | 25 {#- This init function initializes a mapping between identifiers and their |
| 26 corresponding user-defined type. This could have been a MojomDescriptor, |
| 27 but since it allows Types to be unresolved, it is more complex than is |
| 28 necessary. It's simpler to resolve everything in codegen. |
| 29 It is also difficult to insert changes to the description during the |
| 30 process of generating each type, so this mapping is computed in Python. |
| 31 Note: While we may register items into the map multiple times, this is okay |
| 32 because the keys will match. |
| 33 -#} |
| 34 |
| 35 // These IDs are the Mojom Identifiers / Type Keys. |
| 36 // Mojom libraries importing this one will use these identifiers when building |
| 37 // TypeReference objects. |
25 {% for enum in enums %} | 38 {% for enum in enums %} |
26 {{enum_macros.define(enum)}} | 39 var ID_{{enum|mojom_type_identifier}} string = "{{enum|mojom_type_identifier}}" |
| 40 {% endfor %} |
| 41 {% for struct in structs %} |
| 42 var ID_{{struct|mojom_type_identifier}} string = "{{struct|mojom_type_identifier
}}" |
| 43 {% endfor %} |
| 44 {% for union in unions %} |
| 45 var ID_{{union|mojom_type_identifier}} string = "{{union|mojom_type_identifier}}
" |
| 46 {% endfor %} |
| 47 {% for interface in interfaces %} |
| 48 var ID_{{interface|mojom_type_identifier}} string = "{{interface|mojom_type_iden
tifier}}" |
| 49 {% endfor %} |
| 50 |
| 51 {% set mapping = package|qualified(None, true) ~ 'Desc__' %} |
| 52 var {{mapping}} = make(map[string]{{typepkg}}UserDefinedType) |
| 53 func init() { |
| 54 {% for enum in enums %} |
| 55 {{mojom_reference_macros.registerType(mapping, typepkg, package, enum)}} |
| 56 {%- endfor %} |
| 57 {% for struct in structs %} |
| 58 {{mojom_reference_macros.registerType(mapping, typepkg, package, struct)}} |
| 59 {%- endfor %} |
| 60 {% for union in unions %} |
| 61 {{mojom_reference_macros.registerType(mapping, typepkg, package, union)}} |
| 62 {%- endfor %} |
| 63 {% for interface in interfaces %} |
| 64 {{mojom_reference_macros.registerType(mapping, typepkg, package, interface)}} |
| 65 {%- endfor %} |
| 66 |
| 67 {% for mi in mojom_imports.values() %} |
| 68 {%- if mi ~ '.' != typepkg and mi ~ '.' != descpkg %} |
| 69 for s, udt := range {{mi}}.Descriptor() { |
| 70 {{mapping}}[s] = udt |
| 71 } |
| 72 {% endif -%} |
| 73 {% endfor %} |
| 74 } |
| 75 func Descriptor() map[string]{{typepkg}}UserDefinedType { |
| 76 return {{mapping}} |
| 77 } |
| 78 |
| 79 {# Enum definitions #} |
| 80 {%- for enum in enums %} |
| 81 {{enum_macros.define(enum, typepkg, package)}} |
27 {%- endfor %} | 82 {%- endfor %} |
28 | 83 |
29 {#- Interface definitions #} | 84 {#- Interface definitions #} |
30 {% for interface in interfaces %} | 85 {% for interface in interfaces %} |
31 {{interface_macros.define(interface)}} | 86 {{interface_macros.define(interface, descpkg, typepkg, package)}} |
32 {%- endfor %} | 87 {%- endfor %} |
33 | 88 |
34 {#- Struct definitions #} | 89 {#- Struct definitions #} |
35 {% for struct in structs %} | 90 {% for struct in structs %} |
36 {{struct_macros.define(struct)}} | 91 {{struct_macros.define(struct, typepkg, package)}} |
37 {%- endfor %} | 92 {%- endfor %} |
38 | 93 |
39 {#- Union definitions #} | 94 {#- Union definitions #} |
40 {% for union in unions %} | 95 {% for union in unions %} |
41 {{union_macros.define(union)}} | 96 {{union_macros.define(union, typepkg, package)}} |
42 {%- endfor %} | 97 {%- endfor %} |
OLD | NEW |