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) }} | 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) }} | 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) }} | 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 %} |
25 {%- for interface in interfaces -%} | 26 {%- for interface in interfaces -%} |
26 {%- include "interface_definition.tmpl" %} | 27 {%- include "interface_definition.tmpl" %} |
27 {%- endfor %} | 28 {%- endfor %} |
| 29 {% if should_gen_mojom_types -%} |
| 30 {%- import "mojom_reference_macros.tmpl" as mojom_reference_macros %} |
| 31 {%- set mapping = '_mojomDesc' %} |
| 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 |
| 48 {%- for import in imports %} |
| 49 {{import.unique_name}}.getAllMojomTypeDefinitions() |
| 50 .forEach((String s, {{typepkg}}UserDefinedType udt) { |
| 51 {{temp_mapping}}[s] = udt; |
| 52 }); |
| 53 {% endfor %} |
| 54 return {{temp_mapping}}; |
| 55 } |
| 56 |
| 57 var {{mapping}}; |
| 58 Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() { |
| 59 if ({{mapping}} == null) { |
| 60 {{mapping}} = _initDescriptions(); |
| 61 } |
| 62 return {{mapping}}; |
| 63 } |
| 64 {%- endif %} |
OLD | NEW |