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
This commit is contained in:
sgjesse@google.com
2011-10-06 07:57:34 +00:00
parent b0af113468
commit cc0ffa0766
3 changed files with 30 additions and 17 deletions
+11 -6
View File
@@ -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;
}
+11
View File
@@ -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;
}
+8 -11
View File
@@ -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