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

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: Merge and Format 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
« no previous file with comments | « mojo/public/dart/src/stub.dart ('k') | services/dart/dart_apptests/pingpong_apptests.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 class {{interface|name}}Proxy implements bindings.ProxyBase { 128 class {{interface|name}}Proxy implements bindings.ProxyBase {
132 final bindings.Proxy impl; 129 final bindings.Proxy impl;
133 {{interface|name}} ptr; 130 {{interface|name}} ptr;
134 final String name = {{interface|name}}Name; 131 final String name = {{interface|name}}Name;
135 132
136 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) : 133 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) :
137 impl = proxyImpl, 134 impl = proxyImpl,
138 ptr = new _{{interface|name}}ProxyCalls(proxyImpl); 135 ptr = new _{{interface|name}}ProxyCalls(proxyImpl);
139 136
140 {{interface|name}}Proxy.fromEndpoint( 137 {{interface|name}}Proxy.fromEndpoint(
141 core.MojoMessagePipeEndpoint endpoint, 138 core.MojoMessagePipeEndpoint endpoint) :
142 {bool doListen: true, Function onClosed}) : 139 impl = new {{interface|name}}ProxyImpl.fromEndpoint(endpoint) {
143 impl = new {{interface|name}}ProxyImpl.fromEndpoint(
144 endpoint, doListen: doListen, onClosed: onClosed) {
145 ptr = new _{{interface|name}}ProxyCalls(impl); 140 ptr = new _{{interface|name}}ProxyCalls(impl);
146 } 141 }
147 142
148 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle, 143 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle) :
149 {bool doListen: true, Function onClosed}) : 144 impl = new {{interface|name}}ProxyImpl.fromHandle(handle) {
150 impl = new {{interface|name}}ProxyImpl.fromHandle(
151 handle, doListen: doListen, onClosed: onClosed) {
152 ptr = new _{{interface|name}}ProxyCalls(impl); 145 ptr = new _{{interface|name}}ProxyCalls(impl);
153 } 146 }
154 147
155 {{interface|name}}Proxy.unbound() : 148 {{interface|name}}Proxy.unbound() :
156 impl = new {{interface|name}}ProxyImpl.unbound() { 149 impl = new {{interface|name}}ProxyImpl.unbound() {
157 ptr = new _{{interface|name}}ProxyCalls(impl); 150 ptr = new _{{interface|name}}ProxyCalls(impl);
158 } 151 }
159 152
160 static {{interface|name}}Proxy newFromEndpoint( 153 static {{interface|name}}Proxy newFromEndpoint(
161 core.MojoMessagePipeEndpoint endpoint) => 154 core.MojoMessagePipeEndpoint endpoint) =>
162 new {{interface|name}}Proxy.fromEndpoint(endpoint); 155 new {{interface|name}}Proxy.fromEndpoint(endpoint);
163 156
164 void close() => impl.close(); 157 void close() => impl.close();
165 158
166 String toString() { 159 String toString() {
167 return "{{interface|name}}Proxy($impl)"; 160 return "{{interface|name}}Proxy($impl)";
168 } 161 }
169 } 162 }
170 163
171 164
172 class {{interface|name}}Stub extends bindings.Stub { 165 class {{interface|name}}Stub extends bindings.Stub {
173 {{interface|name}} _impl = null; 166 {{interface|name}} _impl = null;
174 167
175 {{interface|name}}Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint, 168 {{interface|name}}Stub.fromEndpoint(
176 { {{interface|name}} impl, bool doListen: true, Function onClosed}) : 169 core.MojoMessagePipeEndpoint endpoint, [this._impl])
177 super.fromEndpoint(endpoint, doListen: false) { 170 : super.fromEndpoint(endpoint);
178 assert(!doListen || (impl != null));
179 if (impl != null) {
180 this._impl = impl;
181 }
182 if (doListen) {
183 listen(onClosed: onClosed);
184 }
185 }
186 171
187 {{interface|name}}Stub.fromHandle(core.MojoHandle handle, 172 {{interface|name}}Stub.fromHandle(core.MojoHandle handle, [this._impl])
188 { {{interface|name}} impl, bool doListen: true, Function onClosed}) : 173 : super.fromHandle(handle);
189 super.fromHandle(handle, doListen: false) {
190 assert(!doListen || (impl != null));
191 if (impl != null) {
192 this._impl = impl;
193 }
194 if (doListen) {
195 listen(onClosed: onClosed);
196 }
197 }
198 174
199 {{interface|name}}Stub.unbound() : super.unbound(); 175 {{interface|name}}Stub.unbound() : super.unbound();
200 176
201 static {{interface|name}}Stub newFromEndpoint( 177 static {{interface|name}}Stub newFromEndpoint(
202 core.MojoMessagePipeEndpoint endpoint) => 178 core.MojoMessagePipeEndpoint endpoint) =>
203 new {{interface|name}}Stub.fromEndpoint(endpoint, doListen: false); 179 new {{interface|name}}Stub.fromEndpoint(endpoint);
204 180
205 static const String name = {{interface|name}}Name; 181 static const String name = {{interface|name}}Name;
206 182
207 {% for method in interface.methods %} 183 {% for method in interface.methods %}
208 {%- if method.response_parameters != None %} 184 {%- if method.response_parameters != None %}
209 {%- set response_struct = method|response_struct_from_method %} 185 {%- set response_struct = method|response_struct_from_method %}
210 {{response_struct|name}} _{{response_struct|name}}Factory( 186 {{response_struct|name}} _{{response_struct|name}}Factory(
211 {%- for param in method.response_parameters -%} 187 {%- for param in method.response_parameters -%}
212 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %} 188 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %}
213 {%- endfor -%} 189 {%- endfor -%}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 set impl({{interface|name}} d) { 240 set impl({{interface|name}} d) {
265 assert(_impl == null); 241 assert(_impl == null);
266 _impl = d; 242 _impl = d;
267 } 243 }
268 244
269 String toString() { 245 String toString() {
270 var superString = super.toString(); 246 var superString = super.toString();
271 return "{{interface|name}}Stub($superString)"; 247 return "{{interface|name}}Stub($superString)";
272 } 248 }
273 } 249 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/stub.dart ('k') | services/dart/dart_apptests/pingpong_apptests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698