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 |
25 {% for enum in enums %} | 36 {% for enum in enums %} |
26 {{enum_macros.define(enum)}} | 37 var ID_{{util.enumName(enum, typepkg, package)}} string = "{{util.enumName(enum,
typepkg, package)}}" |
| 38 {% endfor %} |
| 39 {% for struct in structs %} |
| 40 var ID_{{util.structName(struct, typepkg, package)}} string = "{{util.structName
(struct, typepkg, package)}}" |
| 41 {% endfor %} |
| 42 {% for union in unions %} |
| 43 var ID_{{util.unionName(union, typepkg, package)}} string = "{{util.unionName(un
ion, typepkg, package)}}" |
| 44 {% endfor %} |
| 45 {% for interface in interfaces %} |
| 46 var ID_{{util.interfaceName(interface, typepkg, package)}} string = "{{util.inte
rfaceName(interface, typepkg, package)}}" |
| 47 {% endfor %} |
| 48 |
| 49 {%- if need_mojom_desc -%} |
| 50 {% set mapping = package|qualified(None, true) ~ 'Desc__' %} |
| 51 var {{mapping}} = make(map[string]{{descpkg}}UserDefinedType) |
| 52 func init() { |
| 53 {% for enum in enums %} |
| 54 {{mojom_reference_macros.registerType(mapping, descpkg, typepkg, package, enum
)}} |
| 55 {%- endfor %} |
| 56 {% for struct in structs %} |
| 57 {{mojom_reference_macros.registerType(mapping, descpkg, typepkg, package, stru
ct)}} |
| 58 {%- endfor %} |
| 59 {% for union in unions %} |
| 60 {{mojom_reference_macros.registerType(mapping, descpkg, typepkg, package, unio
n)}} |
| 61 {%- endfor %} |
| 62 {% for interface in interfaces %} |
| 63 {{mojom_reference_macros.registerType(mapping, descpkg, typepkg, package, inte
rface)}} |
| 64 {%- endfor %} |
| 65 |
| 66 {% for mi in mojom_imports.values() %} |
| 67 for s, udt := range {{mi}}.Descriptor() { |
| 68 {{mapping}}[s] = udt |
| 69 } |
| 70 {% endfor %} |
| 71 } |
| 72 func Descriptor() map[string]{{descpkg}}UserDefinedType { |
| 73 return {{mapping}} |
| 74 } |
| 75 {% endif %} |
| 76 |
| 77 {# Enum definitions #} |
| 78 {%- for enum in enums %} |
| 79 {{enum_macros.define(enum, typepkg, package)}} |
27 {%- endfor %} | 80 {%- endfor %} |
28 | 81 |
29 {#- Interface definitions #} | 82 {#- Interface definitions #} |
30 {% for interface in interfaces %} | 83 {% for interface in interfaces %} |
31 {{interface_macros.define(interface)}} | 84 {{interface_macros.define(interface, typepkg, package)}} |
32 {%- endfor %} | 85 {%- endfor %} |
33 | 86 |
34 {#- Struct definitions #} | 87 {#- Struct definitions #} |
35 {% for struct in structs %} | 88 {% for struct in structs %} |
36 {{struct_macros.define(struct)}} | 89 {{struct_macros.define(struct, typepkg, package)}} |
37 {%- endfor %} | 90 {%- endfor %} |
38 | 91 |
39 {#- Union definitions #} | 92 {#- Union definitions #} |
40 {% for union in unions %} | 93 {% for union in unions %} |
41 {{union_macros.define(union)}} | 94 {{union_macros.define(union, typepkg, package)}} |
42 {%- endfor %} | 95 {%- endfor %} |
OLD | NEW |