OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // This file is autogenerated by: | |
6 // mojo/public/tools/bindings/mojom_bindings_generator.py | |
7 // For: | |
8 // {{module.path}} | |
9 // | |
10 | |
11 package {{package}} | |
12 | |
13 import ( | |
14 {% for path, name in imports.iteritems() %} | |
15 {{name}} "{{path}}" | |
16 {% endfor %} | |
17 ) | |
18 | |
19 {% import "enum.tmpl" as enum_macros %} | |
20 {% import "interface.tmpl" as interface_macros %} | |
21 {% import "struct.tmpl" as struct_macros %} | |
22 {% import "union.tmpl" as union_macros %} | |
23 | |
24 {%- if should_gen_mojom_types -%} | |
25 // This global variable contains a mojom_types.RuntimeTypeInfo struct | |
26 // describing the types defined in this file and all of its imports as | |
27 // well as the top-level interfaces defined in this file. | |
28 var runtimeTypeInfo__ = {{typepkg}}RuntimeTypeInfo{} | |
29 | |
30 func getRuntimeTypeInfo() {{typepkg}}RuntimeTypeInfo { | |
31 if runtimeTypeInfo__.TypeMap == nil { | |
32 initRuntimeTypeInfo() | |
33 } | |
34 return runtimeTypeInfo__ | |
35 } | |
36 | |
37 func initRuntimeTypeInfo() { | |
38 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of | |
39 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this fil
e. | |
40 // The string contains the base64 encoding of the gzip-compressed bytes. | |
41 serializedRuntimeTypeInfo := "{{module.serialized_runtime_type_info}}" | |
42 | |
43 // Deserialize RuntimeTypeInfo | |
44 compressedBytes, err := base64.StdEncoding.DecodeString(serializedRuntimeTypeI
nfo) | |
45 if err != nil { | |
46 panic(fmt.Sprintf("Error while base64Decoding runtimeTypeInfo: %s", err.Erro
r())) | |
47 } | |
48 reader, err := gzip.NewReader(bytes.NewBuffer(compressedBytes)) | |
49 if err != nil { | |
50 panic(fmt.Sprintf("Error while decompressing runtimeTypeInfo: %s", err.Error
())) | |
51 } | |
52 uncompressedBytes, err := ioutil.ReadAll(reader) | |
53 if err != nil { | |
54 panic(fmt.Sprintf("Error while decompressing runtimeTypeInfo: %s", err.Erro
r())) | |
55 } | |
56 if err = reader.Close(); err != nil { | |
57 panic(fmt.Sprintf("Error while decompressing runtimeTypeInfo: %s", err.Error
())) | |
58 } | |
59 decoder := bindings.NewDecoder(uncompressedBytes, nil) | |
60 runtimeTypeInfo__.Decode(decoder) | |
61 | |
62 {% for mi in mojom_imports.values() %} | |
63 {%- if mi ~ '.' != typepkg and mi ~ '.' != descpkg %} | |
64 for s, udt := range {{mi}}.GetAllMojomTypeDefinitions() { | |
65 runtimeTypeInfo__.TypeMap[s] = udt | |
66 } | |
67 | |
68 | |
69 {% endif -%} | |
70 {% endfor %} | |
71 } | |
72 func GetAllMojomTypeDefinitions() map[string]{{typepkg}}UserDefinedType { | |
73 return getRuntimeTypeInfo().TypeMap | |
74 } | |
75 {% endif %} | |
76 | |
77 {# Enum definitions #} | |
78 {%- for enum in enums %} | |
79 {{enum_macros.define(enum, typepkg, package)}} | |
80 {%- endfor %} | |
81 | |
82 {#- Interface definitions #} | |
83 {% for interface in interfaces %} | |
84 {{interface_macros.define(interface, descpkg, typepkg, package)}} | |
85 {%- endfor %} | |
86 | |
87 {#- Struct definitions #} | |
88 {% for struct in structs %} | |
89 {{struct_macros.define(struct, typepkg, package)}} | |
90 {%- endfor %} | |
91 | |
92 {#- Union definitions #} | |
93 {% for union in unions %} | |
94 {{union_macros.define(union, typepkg, package)}} | |
95 {%- endfor %} | |
OLD | NEW |