Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl

Issue 1433183002: Generate Mojom Types for Dart (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Simplify identifier_store for Go and Dart Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {#--- Constants #} 1 {#--- Constants #}
2 {%- for constant in module.constants %} 2 {%- for constant in module.constants %}
3 const {{constant.name}} = {{constant.value|expression_to_text}}; 3 const {{constant.name}} = {{constant.value|expression_to_text}};
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
30 {% if should_gen_mojom_types -%}
31
32 {% import "mojom_reference_macros.tmpl" as mojom_reference_macros %}
33
34
35 {% set mapping = '_MojomDesc__' %}
zra 2015/11/24 17:34:44 Trailing underscores are a bit unusual in Dart cod
alexfandrianto 2015/12/18 01:53:19 Removed trailing underscores
36 {% set temp_mapping = 'map' %}
37
38 var {{mapping}} = _initDescriptions();
zra 2015/11/24 17:34:44 I find it a bit easier to read when globals like t
alexfandrianto 2015/12/18 01:53:19 Done.
39
40 Map<String, {{typepkg}}UserDefinedType> _initDescriptions() {
zra 2015/11/24 17:34:44 In the generated code for this function there's a
alexfandrianto 2015/12/18 01:53:19 I've somehow reduced it a lot. More -'s help.
41 var {{temp_mapping}} = new Map<String, {{typepkg}}UserDefinedType>();
zra 2015/11/24 17:34:44 If it is not necessary to preserve iteration order
alexfandrianto 2015/12/18 01:53:19 I switched this to HashMap. To use it, I am now co
42
43 {%- for enum in enums %}
44 {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, enum)}}
45 {%- endfor %}
46 {%- for struct in structs %}
47 {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, struct)} }
48 {%- endfor %}
49 {%- for union in unions %}
50 {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, union)}}
51 {%- endfor %}
52 {%- for interface in interfaces %}
53 {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, interfac e)}}
54 {%- endfor %}
55
56 {%- for import in imports %}
57 {{import.unique_name}}.getAllMojomTypeDefinitions().forEach((String s, {{typepkg }}UserDefinedType udt) {
58 {{temp_mapping}}[s] = udt;
59 });
60 {%- endfor %}
61 return {{temp_mapping}};
62 }
63
64 Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() {
65 return {{mapping}};
66 }
67 {%- endif %}
68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698