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

Side by Side Diff: tests/stub-generator/src/MintMakerFullyIsolatedTest-generatedTest.dart

Issue 8437090: Change the handling of closing sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by ager@ Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // IsolateStubs=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse 5 // IsolateStubs=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse
6 6
7 #import("../../isolate/src/TestFramework.dart"); 7 #import("../../isolate/src/TestFramework.dart");
8 8
9 /* class = Purse (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintM akerFullyIsolatedTest.dart: 9) */ 9 /* class = Purse (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintM akerFullyIsolatedTest.dart: 9) */
10 10
11 interface Purse$Proxy extends Proxy { 11 interface Purse$Proxy {
12 Promise<int> queryBalance(); 12 Promise<int> queryBalance();
13 13
14 Purse$Proxy sproutPurse(); 14 Purse$Proxy sproutPurse();
15 15
16 Promise<int> deposit(int amount, Purse$Proxy source); 16 Promise<int> deposit(int amount, Purse$Proxy source);
17 } 17 }
18 18
19 class Purse$ProxyImpl extends ProxyImpl implements Purse$Proxy { 19 class Purse$ProxyImpl extends Proxy implements Purse$Proxy {
20 Purse$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { } 20 Purse$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
21 Purse$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null] )) { } 21 Purse$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null] )) { }
22 factory Purse$ProxyImpl.createIsolate() { 22 factory Purse$ProxyImpl.createIsolate() {
23 Proxy isolate = new Proxy.forIsolate(new Purse$Dispatcher$Isolate()); 23 Proxy isolate = new Proxy.forIsolate(new Purse$Dispatcher$Isolate());
24 return new Purse$ProxyImpl.forIsolate(isolate); 24 return new Purse$ProxyImpl.forIsolate(isolate);
25 } 25 }
26 factory Purse$ProxyImpl.localProxy(Purse obj) { 26 factory Purse$ProxyImpl.localProxy(Purse obj) {
27 return new Purse$ProxyImpl(new Promise<SendPort>.fromValue(Dispatcher.serve( new Purse$Dispatcher(obj)))); 27 return new Purse$ProxyImpl(new Promise<SendPort>.fromValue(Dispatcher.serve( new Purse$Dispatcher(obj))));
28 } 28 }
29 29
30 Promise<int> queryBalance() { 30 Promise<int> queryBalance() {
31 return this.call(["queryBalance"]); 31 return this.call(["queryBalance"]);
32 } 32 }
33 33
34 Purse$Proxy sproutPurse() { 34 Purse$Proxy sproutPurse() {
35 return new Purse$ProxyImpl(new PromiseProxy<SendPort>(this.call(["sproutPurs e"]))); 35 return new Purse$ProxyImpl(this.call(["sproutPurse"]));
36 } 36 }
37 37
38 Promise<int> deposit(int amount, Purse$Proxy source) { 38 Promise<int> deposit(int amount, Purse$Proxy source) {
39 return new PromiseProxy<int>(this.call(["deposit", amount, source])); 39 return this.call(["deposit", amount, source]);
40 } 40 }
41 } 41 }
42 42
43 class Purse$Dispatcher extends Dispatcher<Purse> { 43 class Purse$Dispatcher extends Dispatcher<Purse> {
44 Purse$Dispatcher(Purse thing) : super(thing) { } 44 Purse$Dispatcher(Purse thing) : super(thing) { }
45 45
46 void process(var message, void reply(var response)) { 46 void process(var message, void reply(var response)) {
47 String command = message[0]; 47 String command = message[0];
48 if (command == "Purse") { 48 if (command == "Purse") {
49 } else if (command == "queryBalance") { 49 } else if (command == "queryBalance") {
50 int queryBalance = target.queryBalance(); 50 int queryBalance = target.queryBalance();
51 reply(queryBalance); 51 reply(queryBalance);
52 } else if (command == "sproutPurse") { 52 } else if (command == "sproutPurse") {
53 Purse$Proxy sproutPurse = target.sproutPurse(); 53 Purse$Proxy sproutPurse = target.sproutPurse();
54 reply(sproutPurse); 54 reply(sproutPurse);
55 } else if (command == "deposit") { 55 } else if (command == "deposit") {
56 int amount = message[1]; 56 int amount = message[1];
57 List<Promise<SendPort>> promises = new List<Promise<SendPort>>(); 57 Purse$Proxy source = new Purse$ProxyImpl(new Promise<SendPort>.fromValue(m essage[2]));
58 promises.add(new PromiseProxy<SendPort>(new Promise<SendPort>.fromValue(me ssage[2])));
59 Purse$Proxy source = new Purse$ProxyImpl(promises[0]);
60 Promise<int> deposit = target.deposit(amount, source); 58 Promise<int> deposit = target.deposit(amount, source);
61 reply(deposit); 59 reply(deposit);
62 } else { 60 } else {
63 // TODO(kasperl,benl): Somehow throw an exception instead. 61 // TODO(kasperl,benl): Somehow throw an exception instead.
64 reply("Exception: command '" + command + "' not understood by Purse."); 62 reply("Exception: command '" + command + "' not understood by Purse.");
65 } 63 }
66 } 64 }
67 } 65 }
68 66
69 class Purse$Dispatcher$Isolate extends Isolate { 67 class Purse$Dispatcher$Isolate extends Isolate {
70 Purse$Dispatcher$Isolate() : super() { } 68 Purse$Dispatcher$Isolate() : super() { }
71 69
72 void main() { 70 void main() {
73 this.port.receive(void _(var message, SendPort replyTo) { 71 this.port.receive(void _(var message, SendPort replyTo) {
74 Purse thing = new Purse(); 72 Purse thing = new Purse();
75 SendPort port = Dispatcher.serve(new Purse$Dispatcher(thing)); 73 SendPort port = Dispatcher.serve(new Purse$Dispatcher(thing));
76 Proxy proxy = new Proxy.forPort(replyTo); 74 Proxy proxy = new Proxy.forPort(replyTo);
77 proxy.send([port]); 75 proxy.send([port]);
78 }); 76 });
79 } 77 }
80 } 78 }
81 79
82 /* class = PowerfulPurse (tests/stub-generator/src/MintMakerFullyIsolatedTest.da rt/MintMakerFullyIsolatedTest.dart: 18) */ 80 /* class = PowerfulPurse (tests/stub-generator/src/MintMakerFullyIsolatedTest.da rt/MintMakerFullyIsolatedTest.dart: 18) */
83 81
84 interface PowerfulPurse$Proxy extends Proxy { 82 interface PowerfulPurse$Proxy {
85 void init(Mint$Proxy mint, int balance); 83 void init(Mint$Proxy mint, int balance);
86 84
87 Promise<int> grab(int amount); 85 Promise<int> grab(int amount);
88 86
89 Purse$Proxy weak(); 87 Purse$Proxy weak();
90 } 88 }
91 89
92 class PowerfulPurse$ProxyImpl extends ProxyImpl implements PowerfulPurse$Proxy { 90 class PowerfulPurse$ProxyImpl extends Proxy implements PowerfulPurse$Proxy {
93 PowerfulPurse$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { } 91 PowerfulPurse$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
94 PowerfulPurse$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.cal l([null])) { } 92 PowerfulPurse$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.cal l([null])) { }
95 factory PowerfulPurse$ProxyImpl.createIsolate() { 93 factory PowerfulPurse$ProxyImpl.createIsolate() {
96 Proxy isolate = new Proxy.forIsolate(new PowerfulPurse$Dispatcher$Isolate()) ; 94 Proxy isolate = new Proxy.forIsolate(new PowerfulPurse$Dispatcher$Isolate()) ;
97 return new PowerfulPurse$ProxyImpl.forIsolate(isolate); 95 return new PowerfulPurse$ProxyImpl.forIsolate(isolate);
98 } 96 }
99 factory PowerfulPurse$ProxyImpl.localProxy(PowerfulPurse obj) { 97 factory PowerfulPurse$ProxyImpl.localProxy(PowerfulPurse obj) {
100 return new PowerfulPurse$ProxyImpl(new Promise<SendPort>.fromValue(Dispatche r.serve(new PowerfulPurse$Dispatcher(obj)))); 98 return new PowerfulPurse$ProxyImpl(new Promise<SendPort>.fromValue(Dispatche r.serve(new PowerfulPurse$Dispatcher(obj))));
101 } 99 }
102 100
(...skipping 10 matching lines...) Expand all
113 } 111 }
114 } 112 }
115 113
116 class PowerfulPurse$Dispatcher extends Dispatcher<PowerfulPurse> { 114 class PowerfulPurse$Dispatcher extends Dispatcher<PowerfulPurse> {
117 PowerfulPurse$Dispatcher(PowerfulPurse thing) : super(thing) { } 115 PowerfulPurse$Dispatcher(PowerfulPurse thing) : super(thing) { }
118 116
119 void process(var message, void reply(var response)) { 117 void process(var message, void reply(var response)) {
120 String command = message[0]; 118 String command = message[0];
121 if (command == "PowerfulPurse") { 119 if (command == "PowerfulPurse") {
122 } else if (command == "init") { 120 } else if (command == "init") {
123 List<Promise<SendPort>> promises = new List<Promise<SendPort>>(); 121 Mint$Proxy mint = new Mint$ProxyImpl(new Promise<SendPort>.fromValue(messa ge[1]));
124 promises.add(new PromiseProxy<SendPort>(new Promise<SendPort>.fromValue(me ssage[1])));
125 int balance = message[2]; 122 int balance = message[2];
126 Mint$Proxy mint = new Mint$ProxyImpl(promises[0]);
127 target.init(mint, balance); 123 target.init(mint, balance);
128 } else if (command == "grab") { 124 } else if (command == "grab") {
129 int amount = message[1]; 125 int amount = message[1];
130 int grab = target.grab(amount); 126 int grab = target.grab(amount);
131 reply(grab); 127 reply(grab);
132 } else if (command == "weak") { 128 } else if (command == "weak") {
133 Purse weak = target.weak(); 129 Purse weak = target.weak();
134 SendPort port = Dispatcher.serve(new Purse$Dispatcher(weak)); 130 SendPort port = Dispatcher.serve(new Purse$Dispatcher(weak));
135 reply(port); 131 reply(port);
136 } else { 132 } else {
(...skipping 11 matching lines...) Expand all
148 PowerfulPurse thing = new PowerfulPurse(); 144 PowerfulPurse thing = new PowerfulPurse();
149 SendPort port = Dispatcher.serve(new PowerfulPurse$Dispatcher(thing)); 145 SendPort port = Dispatcher.serve(new PowerfulPurse$Dispatcher(thing));
150 Proxy proxy = new Proxy.forPort(replyTo); 146 Proxy proxy = new Proxy.forPort(replyTo);
151 proxy.send([port]); 147 proxy.send([port]);
152 }); 148 });
153 } 149 }
154 } 150 }
155 151
156 /* class = Mint (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintMa kerFullyIsolatedTest.dart: 28) */ 152 /* class = Mint (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintMa kerFullyIsolatedTest.dart: 28) */
157 153
158 interface Mint$Proxy extends Proxy { 154 interface Mint$Proxy {
159 Purse$Proxy createPurse(int balance); 155 Purse$Proxy createPurse(int balance);
160 156
161 Promise<PowerfulPurse$Proxy> promote(Purse$Proxy purse); 157 Promise<PowerfulPurse$Proxy> promote(Purse$Proxy purse);
162 } 158 }
163 159
164 class Mint$ProxyImpl extends ProxyImpl implements Mint$Proxy { 160 class Mint$ProxyImpl extends Proxy implements Mint$Proxy {
165 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { } 161 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
166 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { } 162 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { }
167 factory Mint$ProxyImpl.createIsolate() { 163 factory Mint$ProxyImpl.createIsolate() {
168 Proxy isolate = new Proxy.forIsolate(new Mint$Dispatcher$Isolate()); 164 Proxy isolate = new Proxy.forIsolate(new Mint$Dispatcher$Isolate());
169 return new Mint$ProxyImpl.forIsolate(isolate); 165 return new Mint$ProxyImpl.forIsolate(isolate);
170 } 166 }
171 factory Mint$ProxyImpl.localProxy(Mint obj) { 167 factory Mint$ProxyImpl.localProxy(Mint obj) {
172 return new Mint$ProxyImpl(new Promise<SendPort>.fromValue(Dispatcher.serve(n ew Mint$Dispatcher(obj)))); 168 return new Mint$ProxyImpl(new Promise<SendPort>.fromValue(Dispatcher.serve(n ew Mint$Dispatcher(obj))));
173 } 169 }
174 170
175 Purse$Proxy createPurse(int balance) { 171 Purse$Proxy createPurse(int balance) {
176 return new Purse$ProxyImpl(new PromiseProxy<SendPort>(this.call(["createPurs e", balance]))); 172 return new Purse$ProxyImpl(this.call(["createPurse", balance]));
177 } 173 }
178 174
179 Promise<PowerfulPurse$Proxy> promote(Purse$Proxy purse) { 175 Promise<PowerfulPurse$Proxy> promote(Purse$Proxy purse) {
180 return new Promise<PowerfulPurse$Proxy>.fromValue(new PowerfulPurse$ProxyImp l(new PromiseProxy<SendPort>(new PromiseProxy<SendPort>(this.call(["promote", pu rse]))))); 176 return this.call(["promote", purse]);
181 } 177 }
182 } 178 }
183 179
184 class Mint$Dispatcher extends Dispatcher<Mint> { 180 class Mint$Dispatcher extends Dispatcher<Mint> {
185 Mint$Dispatcher(Mint thing) : super(thing) { } 181 Mint$Dispatcher(Mint thing) : super(thing) { }
186 182
187 void process(var message, void reply(var response)) { 183 void process(var message, void reply(var response)) {
188 String command = message[0]; 184 String command = message[0];
189 if (command == "Mint") { 185 if (command == "Mint") {
190 } else if (command == "createPurse") { 186 } else if (command == "createPurse") {
191 int balance = message[1]; 187 int balance = message[1];
192 Purse$Proxy createPurse = target.createPurse(balance); 188 Purse$Proxy createPurse = target.createPurse(balance);
193 reply(createPurse); 189 reply(createPurse);
194 } else if (command == "promote") { 190 } else if (command == "promote") {
195 List<Promise<SendPort>> promises = new List<Promise<SendPort>>(); 191 Purse$Proxy purse = new Purse$ProxyImpl(new Promise<SendPort>.fromValue(me ssage[1]));
196 promises.add(new PromiseProxy<SendPort>(new Promise<SendPort>.fromValue(me ssage[1])));
197 Purse$Proxy purse = new Purse$ProxyImpl(promises[0]);
198 Promise<PowerfulPurse$Proxy> promote = target.promote(purse); 192 Promise<PowerfulPurse$Proxy> promote = target.promote(purse);
199 reply(promote); 193 reply(promote);
200 } else { 194 } else {
201 // TODO(kasperl,benl): Somehow throw an exception instead. 195 // TODO(kasperl,benl): Somehow throw an exception instead.
202 reply("Exception: command '" + command + "' not understood by Mint."); 196 reply("Exception: command '" + command + "' not understood by Mint.");
203 } 197 }
204 } 198 }
205 } 199 }
206 200
207 class Mint$Dispatcher$Isolate extends Isolate { 201 class Mint$Dispatcher$Isolate extends Isolate {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 expect.succeeded(); 493 expect.succeeded();
500 print("##DONE##"); 494 print("##DONE##");
501 }); 495 });
502 } 496 }
503 497
504 } 498 }
505 499
506 main() { 500 main() {
507 runTests([MintMakerFullyIsolatedTest.testMain]); 501 runTests([MintMakerFullyIsolatedTest.testMain]);
508 } 502 }
OLDNEW
« no previous file with comments | « tests/standalone/src/SocketCloseTest.dart ('k') | tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698