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

Unified Diff: mojo/public/tools/bindings/generators/dart_templates/interface_definition.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/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
index 8a844c5f89ff38e7a7e6e74ac0199c26f7b4f705..d647c6dc7085629758e6ec24c5dba85746d7298a 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -8,10 +8,45 @@ const String {{interface|name}}Name =
{#--- Interface Enums #}
{%- from "enum_definition.tmpl" import enum_def -%}
{%- for enum in interface.enums %}
- {{ enum_def(enum) }}
+ {{ enum_def(enum, typepkg, package) }}
{%- endfor %}
+{{ mojom_type_macros.writeMojomTypeDef(interface, typepkg, package) }}
+
+class _{{interface|name}}ServiceDescription extends {{descpkg}}ServiceDescription {
+ // Avoid infinite loop by overriding serviceDescription field.
+ final {{descpkg}}ServiceDescription serviceDescription = null;
+{% if should_gen_mojom_types -%}
+ dynamic getTopLevelInterface([Function responseFactory = null]) {
+ return {{interface|mojom_type_identifier}}();
+ }
+ dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]) {
+ return getAllMojomTypeDefinitions()[typeKey];
+ }
+ dynamic getAllTypeDefinitions([Function responseFactory = null]) {
+ return getAllMojomTypeDefinitions();
+ }
+{%- else -%}
+ dynamic getTopLevelInterface([Function responseFactory = null]) {
+ return null;
+ }
+ dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]) {
+ return null;
+ }
+ dynamic getAllTypeDefinitions([Function responseFactory = null]) {
+ return null;
+ }
+{%- endif %}
+}
+
abstract class {{interface|name}} {
+ final {{descpkg}}ServiceDescription serviceDescription =
zra 2015/11/18 19:24:35 This is probably not the right place for this. See
+ {% if descpkg != '' -%}
+ new _{{interface|name}}ServiceDescription();
+ {%- else -%}
+ null;
+ {%- endif %}
+
{%- for method in interface.methods %}
{%- if method.response_parameters == None %}
void {{method|name}}(
@@ -53,6 +88,9 @@ class {{interface|name}}ProxyImpl extends bindings.Proxy {
String get name => {{interface|name}}Name;
+ {{descpkg}}ServiceDescription get serviceDescription =>
zra 2015/11/18 19:24:36 This seems like the right place. See comment below
+ new _{{interface|name}}ServiceDescription();
+
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
{%- for method in interface.methods %}
@@ -94,7 +132,7 @@ class {{interface|name}}ProxyImpl extends bindings.Proxy {
}
-class _{{interface|name}}ProxyCalls implements {{interface|name}} {
+class _{{interface|name}}ProxyCalls extends {{interface|name}} {
zra 2015/11/18 19:24:36 Sorry for the lack of comments here. The ProxyCall
alexfandrianto 2015/11/19 23:27:23 As discussed offline, the reason for these changes
{{interface|name}}ProxyImpl _proxyImpl;
_{{interface|name}}ProxyCalls(this._proxyImpl);

Powered by Google App Engine
This is Rietveld 408576698