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

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

Issue 968243003: Dart: Adds optional named arguments for creating bindings. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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/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 cbd39ef51c051574d0a550745bd6babeff920c7a..45f83f7f96fd1afd5d2594a5c99e2a4c1be5e3f5 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -38,10 +38,13 @@ abstract class {{interface|name}} {
class {{interface|name}}ProxyImpl extends bindings.Proxy {
{{interface|name}}ProxyImpl.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
+ core.MojoMessagePipeEndpoint endpoint,
+ {bool doListen: true, Function onClosed}) :
+ super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed);
- {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
+ {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle,
+ {bool doListen: true, Function onClosed}) :
+ super.fromHandle(handle, doListen: doListen, onClosed: onClosed);
{{interface|name}}ProxyImpl.unbound() : super.unbound();
@@ -89,6 +92,7 @@ class _{{interface|name}}ProxyCalls implements {{interface|name}} {
{%- endfor -%}
{%- set request_struct = method|struct_from_method -%}
) {
+ assert(_proxyImpl.isBound);
var params = new {{request_struct|name}}();
{%- for parameter in method.parameters %}
params.{{parameter|name}} = {{parameter|name}};
@@ -103,6 +107,7 @@ class _{{interface|name}}ProxyCalls implements {{interface|name}} {
{{parameter.kind|dart_type}} {{parameter|name}},
{%- endfor -%}
[Function responseFactory = null]) {
+ assert(_proxyImpl.isBound);
var params = new {{request_struct|name}}();
{%- for parameter in method.parameters %}
params.{{parameter|name}} = {{parameter|name}};
@@ -128,13 +133,17 @@ class {{interface|name}}Proxy implements bindings.ProxyBase {
ptr = new _{{interface|name}}ProxyCalls(proxyImpl);
{{interface|name}}Proxy.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) :
- impl = new {{interface|name}}ProxyImpl.fromEndpoint(endpoint) {
+ core.MojoMessagePipeEndpoint endpoint,
+ {bool doListen: true, Function onClosed}) :
+ impl = new {{interface|name}}ProxyImpl.fromEndpoint(
+ endpoint, doListen: doListen, onClosed: onClosed) {
ptr = new _{{interface|name}}ProxyCalls(impl);
}
- {{interface|name}}Proxy.fromHandle(core.MojoHandle handle) :
- impl = new {{interface|name}}ProxyImpl.fromHandle(handle) {
+ {{interface|name}}Proxy.fromHandle(core.MojoHandle handle,
+ {bool doListen: true, Function onClosed}) :
+ impl = new {{interface|name}}ProxyImpl.fromHandle(
+ handle, doListen: doListen, onClosed: onClosed) {
ptr = new _{{interface|name}}ProxyCalls(impl);
}
@@ -151,20 +160,38 @@ class {{interface|name}}Proxy implements bindings.ProxyBase {
}
-class {{interface|name}}Stub extends bindings.Stub {
+class {{interface|name}}Binding extends bindings.Stub {
{{interface|name}} _delegate = null;
- {{interface|name}}Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint) :
- super(endpoint);
+ {{interface|name}}Binding.fromEndpoint(core.MojoMessagePipeEndpoint endpoint,
+ { {{interface|name}} delegate, bool doListen: true, Function onClosed}) :
sky 2015/03/02 20:28:22 Did you consider interfaceImpl or impl over delega
zra 2015/03/02 20:52:45 It has to be optional in at least one constructor
+ super.fromEndpoint(endpoint, doListen: false) {
+ assert(!doListen || (delegate != null));
+ if (delegate != null) {
+ this._delegate = delegate;
+ }
+ if (doListen) {
+ listen(onClosed: onClosed);
+ }
+ }
- {{interface|name}}Stub.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
+ {{interface|name}}Binding.fromHandle(core.MojoHandle handle,
+ { {{interface|name}} delegate, bool doListen: true, Function onClosed}) :
+ super.fromHandle(handle, doListen: false) {
+ assert(!doListen || (delegate != null));
+ if (delegate != null) {
+ this._delegate = delegate;
+ }
+ if (doListen) {
+ listen(onClosed: onClosed);
+ }
+ }
- {{interface|name}}Stub.unbound() : super.unbound();
+ {{interface|name}}Binding.unbound() : super.unbound();
- static {{interface|name}}Stub newFromEndpoint(
+ static {{interface|name}}Binding newFromEndpoint(
core.MojoMessagePipeEndpoint endpoint) =>
- new {{interface|name}}Stub.fromEndpoint(endpoint);
+ new {{interface|name}}Binding.fromEndpoint(endpoint, doListen: false);
static const String name = {{interface|name}}Name;

Powered by Google App Engine
This is Rietveld 408576698