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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl
index dd215f5cd7d5130ae107b89eed4266b24d3965d6..6fb7c1dc4959c5a5459d5a046f32ff70249579bf 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/module_definition.tmpl
@@ -22,43 +22,33 @@ const {{constant.kind|dart_type}} {{constant|name}} = {{constant.resolved_value}
{%- endfor -%}
{#--- Interface definitions #}
-{% import "mojom_type_macros.tmpl" as mojom_type_macros %}
{%- for interface in interfaces -%}
{%- include "interface_definition.tmpl" %}
{%- endfor %}
-{% if should_gen_mojom_types -%}
-{%- import "mojom_reference_macros.tmpl" as mojom_reference_macros %}
-{%- set mapping = '_mojomDesc' %}
-{%- set temp_mapping = 'map' %}
-Map<String, {{typepkg}}UserDefinedType> _initDescriptions() {
- var {{temp_mapping}} = new HashMap<String, {{typepkg}}UserDefinedType>();
-{%- for enum in enums %}
- {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, enum)}}
-{%- endfor -%}
-{%- for struct in structs %}
- {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, struct)}}
-{%- endfor -%}
-{%- for union in unions %}
- {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, union)}}
-{%- endfor -%}
-{%- for interface in interfaces %}
- {{mojom_reference_macros.registerType(temp_mapping, typepkg, package, interface)}}
-{%- endfor -%}
-{%- for import in imports %}
- {{import.unique_name}}.getAllMojomTypeDefinitions()
- .forEach((String s, {{typepkg}}UserDefinedType udt) {
- {{temp_mapping}}[s] = udt;
- });
-{% endfor %}
- return {{temp_mapping}};
+{% if should_gen_mojom_types -%}
+{{typepkg}}RuntimeTypeInfo getRuntimeTypeInfo() {
+ if (runtimeTypeInfo__ == null) {
+ _initRuntimeTypeInfo();
+ }
+ 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.
}
-var {{mapping}};
Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() {
- if ({{mapping}} == null) {
- {{mapping}} = _initDescriptions();
- }
- return {{mapping}};
+ return getRuntimeTypeInfo().typeMap;
+}
+
+var runtimeTypeInfo__;
+_initRuntimeTypeInfo() {
+ // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of
+ // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this
+ // file.
+ var serializedRuntimeTypeInfo = new Uint8List.fromList(const [{{serialized_runtime_type_info_literal}}]);
+
+ // Deserialize RuntimeTypeInfo
+ var bdata = new ByteData.view(serializedRuntimeTypeInfo.buffer);
+ var message = new bindings.Message(bdata, null, serializedRuntimeTypeInfo.length, 0);
+ runtimeTypeInfo__ = {{typepkg}}RuntimeTypeInfo.deserialize(message);
}
-{%- endif %}
+
+{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698