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; |
+ } |
} |