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

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

Issue 851173002: Dart: Encode/Decode handle and interface types. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix Interface encode parameters Created 5 years, 11 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
« no previous file with comments | « mojo/public/dart/src/interface.dart ('k') | mojo/public/tools/bindings/generators/mojom_dart_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c680055ce0f93ce01c2112204ddc10912ef44a8b..d9fee1c57ecb94ed69c4a7718f37ca4fefe787d1 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -46,7 +46,14 @@ abstract class {{interface|name}}Calls {
class {{interface|name}}Client extends bindings.Client with {{interface|name}}Calls {
{{interface|name}}Client(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
- {{interface|name}}Client.fromHandle(int handle) : super.fromHandle(handle);
+ {{interface|name}}Client.fromHandle(core.MojoHandle handle) :
+ super.fromHandle(handle);
+
+ {{interface|name}}Client.unbound() : super.unbound();
+
+ static {{interface|name}}Client newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) =>
+ new {{interface|name}}Client(endpoint);
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
@@ -73,13 +80,22 @@ class {{interface|name}}Client extends bindings.Client with {{interface|name}}Ca
}
-abstract class {{interface|name}}Interface extends bindings.Interface
+class {{interface|name}}Interface extends bindings.Interface
{% if interface.client != None -%}
with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Calls
{% endif -%} {
+ {{interface|name}}Interface _delegate = null;
+
{{interface|name}}Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
- {{interface|name}}Interface.fromHandle(int handle) : super.fromHandle(handle);
+ {{interface|name}}Interface.fromHandle(core.MojoHandle handle) :
+ super.fromHandle(handle);
+
+ {{interface|name}}Interface.unbound() : super.unbound();
+
+ static {{interface|name}}Interface newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) =>
+ new {{interface|name}}Interface(endpoint);
static const String name = '{{namespace|replace(".","::")}}::{{interface|name}}';
@@ -89,14 +105,26 @@ with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Cal
{%- for parameter in method.parameters -%}
{{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
{%- endfor -%}
- );
+ ) {
+ assert(_delegate != null);
+ _delegate.{{method|name}}(
+ {%- for parameter in method.parameters -%}
+ {{parameter|name}}{% if not loop.last %}, {% endif %}
+ {%- endfor %});
+ }
{%- else %}
{%- set response_struct = method|response_struct_from_method %}
Future<{{response_struct|name}}> {{method|name}}(
{%- for parameter in method.parameters -%}
{{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
{%- endfor -%}
- );
+ ) {
+ assert(_delegate != null);
+ return _delegate.{{method|name}}(
+ {%- for parameter in method.parameters -%}
+ {{parameter|name}}{% if not loop.last %}, {% endif %}
+ {%- endfor %});
+ }
{%- endif %}
{%- endfor %}
@@ -136,6 +164,12 @@ with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Cal
}
return null;
}
+
+ {{interface|name}}Interface get delegate => _delegate;
+ set delegate({{interface|name}}Interface d) {
+ assert(_delegate == null);
+ _delegate = d;
+ }
}
« no previous file with comments | « mojo/public/dart/src/interface.dart ('k') | mojo/public/tools/bindings/generators/mojom_dart_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698