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

Unified Diff: mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl

Issue 1433183002: Generate Mojom Types for Dart (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Removed assert that breaks dart unit test Created 5 years, 1 month 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/mojom_reference_macros.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl b/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..81333a6b2a06065460e083367e8172fd88144c5c
--- /dev/null
+++ b/mojo/public/tools/bindings/generators/dart_templates/mojom_reference_macros.tmpl
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+{%- macro registerType(mapping, typepkg, pkg, type) -%}
+{%- if type|identifier|identifier_check('RegisterType') -%}{# Already printed out #}
+{%- elif type|is_imported_kind -%} {# Don't print. That package will do it. #}
+{%- else -%}
+{{type|identifier|identifier_store('RegisterType')}}
+
+{%- if type|mojom_type_value(typepkg) != "" -%}{#- simple kind case: do nothing -#}
+{%- elif type|is_array_kind -%}
+{{registerType(mapping, typepkg, pkg, type.kind)}}
+{%- elif type|is_map_kind -%}
+{{registerType(mapping, typepkg, pkg, type.key_kind)}}
+{{registerType(mapping, typepkg, pkg, type.value_kind)}}
+{% elif type|is_enum_kind %}
+ {{mapping}}["{{type|mojom_type_identifier}}"] =
+ new {{typepkg}}UserDefinedType()
+ ..enumType = {{type|mojom_type_identifier}}();
+{% elif type|is_struct_kind %}
+ {{mapping}}["{{type|mojom_type_identifier}}"] =
+ new {{typepkg}}UserDefinedType()
+ ..structType = {{type|mojom_type_identifier}}();
+ {% for field in type.fields %}
+{{registerType(mapping, typepkg, pkg, field.kind)}}
+ {% endfor %}
+{% elif type|is_union_kind %}
+ {{mapping}}["{{type|mojom_type_identifier}}"] =
+ new {{typepkg}}UserDefinedType()
+ ..unionType = {{type|mojom_type_identifier}}();
+ {% for field in type.fields %}
+{{registerType(mapping, typepkg, pkg, field.kind)}}
+ {% endfor %}
+{% elif type|is_interface_kind %}
+ {{mapping}}["{{type|mojom_type_identifier}}"] =
+ new {{typepkg}}UserDefinedType()
+ ..interfaceType = {{type|mojom_type_identifier}}();
+ {%- for enum in type.enums %}
+ {{ registerType(mapping, typepkg, pkg, enum) }}
+ {%- endfor %}
+{% elif type|is_interface_request_kind -%} {# No need to register anything #}
+{%- else -%}
+ ERROR: UNSUPPORTED TYPE
+ {{type|identifier}}
+{%- endif -%}
+{%- endif -%}
+{%- endmacro -%}

Powered by Google App Engine
This is Rietveld 408576698