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

Side by Side Diff: runtime/bin/string_stream.dart

Issue 10938010: Switch from interfaces to abstract classes in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Interface for decoders decoding binary data into string data. The 5 // Interface for decoders decoding binary data into string data. The
6 // decoder keeps track of line breaks during decoding. 6 // decoder keeps track of line breaks during decoding.
7 interface _StringDecoder { 7 abstract class _StringDecoder {
8 // Add more binary data to be decoded. The ownership of the buffer 8 // Add more binary data to be decoded. The ownership of the buffer
9 // is transfered to the decoder and the caller most not modify it any more. 9 // is transfered to the decoder and the caller most not modify it any more.
10 int write(List<int> buffer); 10 int write(List<int> buffer);
11 11
12 // Returns whether any decoded data is available. 12 // Returns whether any decoded data is available.
13 bool isEmpty(); 13 bool isEmpty();
14 14
15 // Returns the number of available decoded characters. 15 // Returns the number of available decoded characters.
16 int available(); 16 int available();
17 17
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 while (_bufferList.length > 0) { 228 while (_bufferList.length > 0) {
229 int byte = _bufferList.next(); 229 int byte = _bufferList.next();
230 addChar(byte); 230 addChar(byte);
231 } 231 }
232 return true; 232 return true;
233 } 233 }
234 } 234 }
235 235
236 236
237 // Interface for encoders encoding string data into binary data. 237 // Interface for encoders encoding string data into binary data.
238 interface _StringEncoder { 238 abstract class _StringEncoder {
239 List<int> encodeString(String string); 239 List<int> encodeString(String string);
240 } 240 }
241 241
242 242
243 // Utility class for encoding a string into UTF-8 byte stream. 243 // Utility class for encoding a string into UTF-8 byte stream.
244 class _UTF8Encoder implements _StringEncoder { 244 class _UTF8Encoder implements _StringEncoder {
245 List<int> encodeString(String string) { 245 List<int> encodeString(String string) {
246 int size = _encodingSize(string); 246 int size = _encodingSize(string);
247 List<int> result = new Uint8List(size); 247 List<int> result = new Uint8List(size);
248 _encodeString(string, result); 248 _encodeString(string, result);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 339
340 class EncoderException implements Exception { 340 class EncoderException implements Exception {
341 const EncoderException([String this.message]); 341 const EncoderException([String this.message]);
342 String toString() => "EncoderException: $message"; 342 String toString() => "EncoderException: $message";
343 final String message; 343 final String message;
344 } 344 }
345 345
346 346
347 class _StringInputStream implements StringInputStream { 347 class _StringInputStream implements StringInputStream {
348 _StringInputStream(InputStream this._input, 348 _StringInputStream(InputStream this._input, Encoding this._encoding) {
349 [Encoding encoding = Encoding.UTF_8])
350 : _encoding = encoding {
351 _decoder = _StringDecoders.decoder(encoding); 349 _decoder = _StringDecoders.decoder(encoding);
352 _input.onData = _onData; 350 _input.onData = _onData;
353 _input.onClosed = _onClosed; 351 _input.onClosed = _onClosed;
354 } 352 }
355 353
356 String read() { 354 String read() {
357 String result = _decoder.decoded; 355 String result = _decoder.decoded;
358 _checkInstallDataHandler(); 356 _checkInstallDataHandler();
359 return result; 357 return result;
360 } 358 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 bool _inputClosed = false; // Is the underlying input stream closed? 513 bool _inputClosed = false; // Is the underlying input stream closed?
516 bool _closed = false; // Is this stream closed. 514 bool _closed = false; // Is this stream closed.
517 bool _eof = false; // Has all data been read from the decoder? 515 bool _eof = false; // Has all data been read from the decoder?
518 Timer _scheduledDataCallback; 516 Timer _scheduledDataCallback;
519 Timer _scheduledLineCallback; 517 Timer _scheduledLineCallback;
520 Timer _scheduledCloseCallback; 518 Timer _scheduledCloseCallback;
521 Function _clientDataHandler; 519 Function _clientDataHandler;
522 Function _clientLineHandler; 520 Function _clientLineHandler;
523 Function _clientCloseHandler; 521 Function _clientCloseHandler;
524 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698