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

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

Issue 1753013002: Mojom runtime type info: New implementation for Dart. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months 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.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() {
31 {%- set mapping = '_mojomDesc' %} 31 if (runtimeTypeInfo__ == null) {
32 {%- set temp_mapping = 'map' %} 32 _initRuntimeTypeInfo();
33 Map<String, {{typepkg}}UserDefinedType> _initDescriptions() { 33 }
34 var {{temp_mapping}} = new HashMap<String, {{typepkg}}UserDefinedType>(); 34 return runtimeTypeInfo__;
alexfandrianto 2016/03/02 05:27:12 Optionally, you can rewrite 30 to 35 as {{typepkg}
rudominer 2016/03/03 01:09:36 Done.
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 } 35 }
56 36
57 var {{mapping}};
58 Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() { 37 Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() {
59 if ({{mapping}} == null) { 38 return getRuntimeTypeInfo().typeMap;
60 {{mapping}} = _initDescriptions();
61 }
62 return {{mapping}};
63 } 39 }
64 {%- endif %} 40
41 var runtimeTypeInfo__;
42 _initRuntimeTypeInfo() {
43 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of
44 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this
45 // file.
46 var serializedRuntimeTypeInfo = new Uint8List.fromList(const [{{serialized_run time_type_info_literal}}]);
47
48 // Deserialize RuntimeTypeInfo
49 var bdata = new ByteData.view(serializedRuntimeTypeInfo.buffer);
50 var message = new bindings.Message(bdata, null, serializedRuntimeTypeInfo.leng th, 0);
51 runtimeTypeInfo__ = {{typepkg}}RuntimeTypeInfo.deserialize(message);
52 }
53
54 {%- endif %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698