OLD | NEW |
| (Empty) |
1 {#--- Constants #} | |
2 {%- for constant in module.constants %} | |
3 const {{constant.kind|dart_type}} {{constant|name}} = {{constant.resolved_value}
}; | |
4 {%- endfor %} | |
5 | |
6 {#--- Enums #} | |
7 {%- from "enum_definition.tmpl" import enum_def %} | |
8 {%- for enum in enums %} | |
9 {{ enum_def(enum, typepkg, package) }} | |
10 {%- endfor %} | |
11 | |
12 {#--- Struct definitions #} | |
13 {%- from "struct_definition.tmpl" import struct_def %} | |
14 {% for struct in structs %} | |
15 {{ struct_def(struct, typepkg, package) }} | |
16 {%- endfor -%} | |
17 | |
18 {#--- Union definitions #} | |
19 {%- from "union_definition.tmpl" import union_def %} | |
20 {% for union in unions %} | |
21 {{ union_def(union, typepkg, package) }} | |
22 {%- endfor -%} | |
23 | |
24 {#--- Interface definitions #} | |
25 {%- for interface in interfaces -%} | |
26 {%- include "interface_definition.tmpl" %} | |
27 {%- endfor %} | |
28 | |
29 {% if should_gen_mojom_types -%} | |
30 {{typepkg}}RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? | |
31 _initRuntimeTypeInfo(); | |
32 | |
33 Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() { | |
34 return getRuntimeTypeInfo().typeMap; | |
35 } | |
36 | |
37 var _runtimeTypeInfo; | |
38 {{typepkg}}RuntimeTypeInfo _initRuntimeTypeInfo() { | |
39 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of | |
40 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this | |
41 // file. The string contains the base64 encoding of the gzip-compressed bytes. | |
42 var serializedRuntimeTypeInfo = "{{module.serialized_runtime_type_info}}"; | |
43 | |
44 // Deserialize RuntimeTypeInfo | |
45 var bytes = BASE64.decode(serializedRuntimeTypeInfo); | |
46 var unzippedBytes = new ZLibDecoder().convert(bytes); | |
47 var bdata = new ByteData.view(unzippedBytes.buffer); | |
48 var message = new bindings.Message(bdata, null, unzippedBytes.length, 0); | |
49 _runtimeTypeInfo = {{typepkg}}RuntimeTypeInfo.deserialize(message); | |
50 | |
51 {%- for import in imports %} | |
52 {{import.unique_name}}.getAllMojomTypeDefinitions() | |
53 .forEach((String s, {{typepkg}}UserDefinedType udt) { | |
54 _runtimeTypeInfo.typeMap[s] = udt; | |
55 }); | |
56 {% endfor %} | |
57 return _runtimeTypeInfo; | |
58 } | |
59 | |
60 {%- endif %} | |
OLD | NEW |