From cc0ffa0766392aa8a441bc30f9869a2cb0a73b30 Mon Sep 17 00:00:00 2001 From: "sgjesse@google.com" Date: Thu, 6 Oct 2011 07:57:34 +0000 Subject: [PATCH] Minor changes to Socket and File * align the definition of the exception class with how ProcessException ended up * add constants for redability R=ager@google.com BUG= TEST= Review URL: https://chromereviews.googleplex.com/3551012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@98 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/bin/file.dart | 17 +++++++++++------ runtime/bin/socket.dart | 11 +++++++++++ runtime/bin/socket_impl.dart | 19 ++++++++----------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/runtime/bin/file.dart b/runtime/bin/file.dart index 4ca1e6e310c..58db9eacc06 100644 --- a/runtime/bin/file.dart +++ b/runtime/bin/file.dart @@ -2,12 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -class FileIOException implements Exception { - const FileIOException([String message = ""]) : _message = message; - String getMessage() { return _message; } - final String _message; -} - interface FileInputStream extends InputStream factory _FileInputStream { FileInputStream(File file); } @@ -63,3 +57,14 @@ interface File factory _File { class FileUtil { static bool fileExists(String name) native "File_Exists"; } + + +class FileIOException implements Exception { + const FileIOException([String this.message = ""]); + String toString() => "FileIOException: $message"; + + /* + * Contains the exception message. + */ + final String message; +} diff --git a/runtime/bin/socket.dart b/runtime/bin/socket.dart index 47de89f689d..78fffc95bb3 100644 --- a/runtime/bin/socket.dart +++ b/runtime/bin/socket.dart @@ -114,3 +114,14 @@ interface Socket factory _Socket { */ void close(); } + + +class SocketIOException implements Exception { + const SocketIOException([String this.message = ""]); + String toString() => "SocketIOException: $message"; + + /* + * Contains the exception message. + */ + final String message; +} diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart index af40dbf82c8..f047b5c1416 100644 --- a/runtime/bin/socket_impl.dart +++ b/runtime/bin/socket_impl.dart @@ -2,17 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -class SocketIOException { - const SocketIOException([String message = ""]) : message_ = message; - String getMessage() { return message_; } - final String message_; -} - /* * SocketNativeWrapper is defined in native and holds a field to store the * native socket object. */ -class SocketBase { +class _SocketBase { /* * Keep these constants in sync with the native poll event identifiers. @@ -21,9 +15,12 @@ class SocketBase { static final int _OUT_EVENT = 1; static final int _ERROR_EVENT = 2; static final int _CLOSE_EVENT = 3; + static final int _FIRST_EVENT = _IN_EVENT; + static final int _LAST_EVENT = _CLOSE_EVENT; + static final int _CLOSE_COMMAND = 4; - SocketBase () { + _SocketBase () { _handler = new ReceivePort(); _handlerMap = new List(_CLOSE_EVENT + 1); _handlerMask = 0; @@ -42,7 +39,7 @@ class SocketBase { assert(message.length == 1); _canActivateHandlers = false; int event_mask = message[0]; - for (int i = _IN_EVENT; i <= _CLOSE_EVENT; i++) { + for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { if (((event_mask & (1 << i)) != 0) && _handlerMap[i] !== null) { var handleEvent = _handlerMap[i]; /* @@ -131,7 +128,7 @@ class SocketBase { } -class _ServerSocket extends SocketBase implements ServerSocket { +class _ServerSocket extends _SocketBase implements ServerSocket { /* * Constructor for server socket. First a socket object is allocated * in which the native socket is stored. After that _createBind @@ -175,7 +172,7 @@ class _ServerSocket extends SocketBase implements ServerSocket { } -class _Socket extends SocketBase implements Socket { +class _Socket extends _SocketBase implements Socket { /* * Constructor for socket. First a socket object is allocated * in which the native socket is stored. After that _createConnect is