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

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: No changes to sha1s 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..b22a7f3e6496d4d9b67d657e44fd2eb1447e7615 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,30 @@ 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 -%}
+{{typepkg}}RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ??
+ _initRuntimeTypeInfo();
-{%- for import in imports %}
- {{import.unique_name}}.getAllMojomTypeDefinitions()
- .forEach((String s, {{typepkg}}UserDefinedType udt) {
- {{temp_mapping}}[s] = udt;
- });
-{% endfor %}
- return {{temp_mapping}};
+Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() {
+ return getRuntimeTypeInfo().typeMap;
}
-var {{mapping}};
-Map<String, {{typepkg}}UserDefinedType> getAllMojomTypeDefinitions() {
- if ({{mapping}} == null) {
- {{mapping}} = _initDescriptions();
- }
- return {{mapping}};
+var _runtimeTypeInfo;
+{{typepkg}}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);
+ return _runtimeTypeInfo;
}
-{%- endif %}
+
+{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698