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