OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 part of dart.fletch.os; | 5 part of dart.dartino.os; |
6 | 6 |
7 // The event source is ready for reading. | 7 // The event source is ready for reading. |
8 const int READ_EVENT = 1 << 0; | 8 const int READ_EVENT = 1 << 0; |
9 // The event source is ready for writing. | 9 // The event source is ready for writing. |
10 const int WRITE_EVENT = 1 << 1; | 10 const int WRITE_EVENT = 1 << 1; |
11 // The event source has been closed. | 11 // The event source has been closed. |
12 const int CLOSE_EVENT = 1 << 2; | 12 const int CLOSE_EVENT = 1 << 2; |
13 // The event source signaled an error. | 13 // The event source signaled an error. |
14 const int ERROR_EVENT = 1 << 3; | 14 const int ERROR_EVENT = 1 << 3; |
15 | 15 |
(...skipping 20 matching lines...) Expand all Loading... |
36 * | 36 * |
37 * An [ArgumentError] is thrown if the event source is not supported. | 37 * An [ArgumentError] is thrown if the event source is not supported. |
38 * A [StateError] is thrown if the port could not be registered. | 38 * A [StateError] is thrown if the port could not be registered. |
39 */ | 39 */ |
40 void registerPortForNextEvent(Object id, Port port, int mask) { | 40 void registerPortForNextEvent(Object id, Port port, int mask) { |
41 if (port is! Port) throw new ArgumentError(port); | 41 if (port is! Port) throw new ArgumentError(port); |
42 if (mask is! int) throw new ArgumentError(mask); | 42 if (mask is! int) throw new ArgumentError(mask); |
43 _eventHandlerAdd(id, port, mask); | 43 _eventHandlerAdd(id, port, mask); |
44 } | 44 } |
45 | 45 |
46 @fletch.native static void _eventHandlerAdd(Object id, Port port, | 46 @dartino.native static void _eventHandlerAdd(Object id, Port port, |
47 int event_kinds) { | 47 int event_kinds) { |
48 switch (fletch.nativeError) { | 48 switch (dartino.nativeError) { |
49 case fletch.wrongArgumentType: | 49 case dartino.wrongArgumentType: |
50 // We check the other arguments in [registerPortForNextEvent], so it | 50 // We check the other arguments in [registerPortForNextEvent], so it |
51 // must be the id that is wrong. | 51 // must be the id that is wrong. |
52 throw new ArgumentError(id); | 52 throw new ArgumentError(id); |
53 case fletch.indexOutOfBounds: | 53 case dartino.indexOutOfBounds: |
54 // We get index out of bounds when we could not register the port. | 54 // We get index out of bounds when we could not register the port. |
55 throw new StateError("The port could not be registered."); | 55 throw new StateError("The port could not be registered."); |
56 case fletch.illegalState: | 56 case dartino.illegalState: |
57 // We get an illegal state when the flags were not supported. | 57 // We get an illegal state when the flags were not supported. |
58 throw new StateError("Operation not supported."); | 58 throw new StateError("Operation not supported."); |
59 default: | 59 default: |
60 throw fletch.nativeError; | 60 throw dartino.nativeError; |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 final EventHandler eventHandler = new EventHandler._internal(); | 65 final EventHandler eventHandler = new EventHandler._internal(); |
OLD | NEW |