OLD | NEW |
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 | 5 |
6 class _SocketBase { | 6 class _SocketBase { |
7 // Bit flags used when communicating between the eventhandler and | 7 // Bit flags used when communicating between the eventhandler and |
8 // dart code. The EVENT flags are used to indicate events of | 8 // dart code. The EVENT flags are used to indicate events of |
9 // interest when sending a message from dart code to the | 9 // interest when sending a message from dart code to the |
10 // eventhandler. When receiving a message from the eventhandler the | 10 // eventhandler. When receiving a message from the eventhandler the |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 throw new IndexOutOfRangeException(bytes); | 404 throw new IndexOutOfRangeException(bytes); |
405 } | 405 } |
406 if ((offset + bytes) > buffer.length) { | 406 if ((offset + bytes) > buffer.length) { |
407 throw new IndexOutOfRangeException(offset + bytes); | 407 throw new IndexOutOfRangeException(offset + bytes); |
408 } | 408 } |
409 // When using the Dart C API to access raw data, using a ByteArray is | 409 // When using the Dart C API to access raw data, using a ByteArray is |
410 // currently much faster. This function will make a copy of the | 410 // currently much faster. This function will make a copy of the |
411 // supplied List to a ByteArray if it isn't already. | 411 // supplied List to a ByteArray if it isn't already. |
412 List outBuffer; | 412 List outBuffer; |
413 int outOffset = offset; | 413 int outOffset = offset; |
414 if (buffer is ByteArray || buffer is ObjectArray) { | 414 if (buffer is Uint8List || buffer is ObjectArray) { |
415 outBuffer = buffer; | 415 outBuffer = buffer; |
416 } else { | 416 } else { |
417 outBuffer = new ByteArray(bytes); | 417 outBuffer = new Uint8List(bytes); |
418 outOffset = 0; | 418 outOffset = 0; |
419 int j = offset; | 419 int j = offset; |
420 for (int i = 0; i < bytes; i++) { | 420 for (int i = 0; i < bytes; i++) { |
421 int value = buffer[j]; | 421 int value = buffer[j]; |
422 if (value is! int) { | 422 if (value is! int) { |
423 throw new FileIOException( | 423 throw new FileIOException( |
424 "List element is not an integer at index $j"); | 424 "List element is not an integer at index $j"); |
425 } | 425 } |
426 outBuffer[i] = value; | 426 outBuffer[i] = value; |
427 j++; | 427 j++; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 bool _seenFirstOutEvent = false; | 589 bool _seenFirstOutEvent = false; |
590 bool _pipe = false; | 590 bool _pipe = false; |
591 Function _clientConnectHandler; | 591 Function _clientConnectHandler; |
592 Function _clientWriteHandler; | 592 Function _clientWriteHandler; |
593 SocketInputStream _inputStream; | 593 SocketInputStream _inputStream; |
594 SocketOutputStream _outputStream; | 594 SocketOutputStream _outputStream; |
595 String _remoteHost; | 595 String _remoteHost; |
596 int _remotePort; | 596 int _remotePort; |
597 static SendPort _socketService; | 597 static SendPort _socketService; |
598 } | 598 } |
OLD | NEW |