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

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

Issue 982673002: Dart: Removes need to call listen(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Don't pile up callbacks Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 {%- for method in interface.methods %} 1 {%- for method in interface.methods %}
2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}}; 2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}};
3 {%- endfor %} 3 {%- endfor %}
4 4
5 const String {{interface|name}}Name = 5 const String {{interface|name}}Name =
6 '{{namespace|replace(".","::")}}::{{interface|name}}'; 6 '{{namespace|replace(".","::")}}::{{interface|name}}';
7 7
8 abstract class {{interface|name}} { 8 abstract class {{interface|name}} {
9 {%- for method in interface.methods %} 9 {%- for method in interface.methods %}
10 {%- if method.response_parameters == None %} 10 {%- if method.response_parameters == None %}
(...skipping 20 matching lines...) Expand all
31 {#--- Interface Enums #} 31 {#--- Interface Enums #}
32 {%- from "enum_definition.tmpl" import enum_def -%} 32 {%- from "enum_definition.tmpl" import enum_def -%}
33 {%- for enum in interface.enums %} 33 {%- for enum in interface.enums %}
34 {{ enum_def(" static ", enum) }} 34 {{ enum_def(" static ", enum) }}
35 {%- endfor %} 35 {%- endfor %}
36 } 36 }
37 37
38 38
39 class {{interface|name}}ProxyImpl extends bindings.Proxy { 39 class {{interface|name}}ProxyImpl extends bindings.Proxy {
40 {{interface|name}}ProxyImpl.fromEndpoint( 40 {{interface|name}}ProxyImpl.fromEndpoint(
41 core.MojoMessagePipeEndpoint endpoint, 41 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
42 {bool doListen: true, Function onClosed}) :
43 super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed);
44 42
45 {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle, 43 {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle) :
46 {bool doListen: true, Function onClosed}) : 44 super.fromHandle(handle);
47 super.fromHandle(handle, doListen: doListen, onClosed: onClosed);
48 45
49 {{interface|name}}ProxyImpl.unbound() : super.unbound(); 46 {{interface|name}}ProxyImpl.unbound() : super.unbound();
50 47
51 static {{interface|name}}ProxyImpl newFromEndpoint( 48 static {{interface|name}}ProxyImpl newFromEndpoint(
52 core.MojoMessagePipeEndpoint endpoint) => 49 core.MojoMessagePipeEndpoint endpoint) =>
53 new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); 50 new {{interface|name}}ProxyImpl.fromEndpoint(endpoint);
54 51
55 String get name => {{interface|name}}Name; 52 String get name => {{interface|name}}Name;
56 53
57 void handleResponse(bindings.ServiceMessage message) { 54 void handleResponse(bindings.ServiceMessage message) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 class {{interface|name}}Proxy implements bindings.ProxyBase { 123 class {{interface|name}}Proxy implements bindings.ProxyBase {
127 final bindings.Proxy impl; 124 final bindings.Proxy impl;
128 {{interface|name}} ptr; 125 {{interface|name}} ptr;
129 final String name = {{interface|name}}Name; 126 final String name = {{interface|name}}Name;
130 127
131 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) : 128 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) :
132 impl = proxyImpl, 129 impl = proxyImpl,
133 ptr = new _{{interface|name}}ProxyCalls(proxyImpl); 130 ptr = new _{{interface|name}}ProxyCalls(proxyImpl);
134 131
135 {{interface|name}}Proxy.fromEndpoint( 132 {{interface|name}}Proxy.fromEndpoint(
136 core.MojoMessagePipeEndpoint endpoint, 133 core.MojoMessagePipeEndpoint endpoint) :
137 {bool doListen: true, Function onClosed}) : 134 impl = new {{interface|name}}ProxyImpl.fromEndpoint(endpoint) {
138 impl = new {{interface|name}}ProxyImpl.fromEndpoint(
139 endpoint, doListen: doListen, onClosed: onClosed) {
140 ptr = new _{{interface|name}}ProxyCalls(impl); 135 ptr = new _{{interface|name}}ProxyCalls(impl);
141 } 136 }
142 137
143 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle, 138 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle) :
144 {bool doListen: true, Function onClosed}) : 139 impl = new {{interface|name}}ProxyImpl.fromHandle(handle) {
145 impl = new {{interface|name}}ProxyImpl.fromHandle(
146 handle, doListen: doListen, onClosed: onClosed) {
147 ptr = new _{{interface|name}}ProxyCalls(impl); 140 ptr = new _{{interface|name}}ProxyCalls(impl);
148 } 141 }
149 142
150 {{interface|name}}Proxy.unbound() : 143 {{interface|name}}Proxy.unbound() :
151 impl = new {{interface|name}}ProxyImpl.unbound() { 144 impl = new {{interface|name}}ProxyImpl.unbound() {
152 ptr = new _{{interface|name}}ProxyCalls(impl); 145 ptr = new _{{interface|name}}ProxyCalls(impl);
153 } 146 }
154 147
155 static {{interface|name}}Proxy newFromEndpoint( 148 static {{interface|name}}Proxy newFromEndpoint(
156 core.MojoMessagePipeEndpoint endpoint) => 149 core.MojoMessagePipeEndpoint endpoint) =>
157 new {{interface|name}}Proxy.fromEndpoint(endpoint); 150 new {{interface|name}}Proxy.fromEndpoint(endpoint);
158 151
159 void close() => impl.close(); 152 void close() => impl.close();
160 } 153 }
161 154
162 155
163 class {{interface|name}}Stub extends bindings.Stub { 156 class {{interface|name}}Stub extends bindings.Stub {
164 {{interface|name}} _impl = null; 157 {{interface|name}} _impl = null;
165 158
166 {{interface|name}}Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint, 159 {{interface|name}}Stub.fromEndpoint(
167 { {{interface|name}} impl, bool doListen: true, Function onClosed}) : 160 core.MojoMessagePipeEndpoint endpoint, [this._impl])
168 super.fromEndpoint(endpoint, doListen: false) { 161 : super.fromEndpoint(endpoint);
169 assert(!doListen || (impl != null));
170 if (impl != null) {
171 this._impl = impl;
172 }
173 if (doListen) {
174 listen(onClosed: onClosed);
175 }
176 }
177 162
178 {{interface|name}}Stub.fromHandle(core.MojoHandle handle, 163 {{interface|name}}Stub.fromHandle(core.MojoHandle handle, [this._impl])
179 { {{interface|name}} impl, bool doListen: true, Function onClosed}) : 164 : super.fromHandle(handle);
180 super.fromHandle(handle, doListen: false) {
181 assert(!doListen || (impl != null));
182 if (impl != null) {
183 this._impl = impl;
184 }
185 if (doListen) {
186 listen(onClosed: onClosed);
187 }
188 }
189 165
190 {{interface|name}}Stub.unbound() : super.unbound(); 166 {{interface|name}}Stub.unbound() : super.unbound();
191 167
192 static {{interface|name}}Stub newFromEndpoint( 168 static {{interface|name}}Stub newFromEndpoint(
193 core.MojoMessagePipeEndpoint endpoint) => 169 core.MojoMessagePipeEndpoint endpoint) =>
194 new {{interface|name}}Stub.fromEndpoint(endpoint, doListen: false); 170 new {{interface|name}}Stub.fromEndpoint(endpoint);
195 171
196 static const String name = {{interface|name}}Name; 172 static const String name = {{interface|name}}Name;
197 173
198 {% for method in interface.methods %} 174 {% for method in interface.methods %}
199 {%- if method.response_parameters != None %} 175 {%- if method.response_parameters != None %}
200 {%- set response_struct = method|response_struct_from_method %} 176 {%- set response_struct = method|response_struct_from_method %}
201 {{response_struct|name}} _{{response_struct|name}}Factory( 177 {{response_struct|name}} _{{response_struct|name}}Factory(
202 {%- for param in method.response_parameters -%} 178 {%- for param in method.response_parameters -%}
203 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %} 179 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %}
204 {%- endfor -%} 180 {%- endfor -%}
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 226 }
251 return null; 227 return null;
252 } 228 }
253 229
254 {{interface|name}} get impl => _impl; 230 {{interface|name}} get impl => _impl;
255 set impl({{interface|name}} d) { 231 set impl({{interface|name}} d) {
256 assert(_impl == null); 232 assert(_impl == null);
257 _impl = d; 233 _impl = d;
258 } 234 }
259 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698