| 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 #library("utils"); | 5 #library("utils"); |
| 6 | 6 |
| 7 #import("dart-ext:dart_archive"); | 7 #import("dart-ext:dart_archive"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 #import("archive.dart", prefix: "archive"); | 9 #import("archive.dart", prefix: "archive"); |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 /** | 23 /** |
| 24 * Send a message to the C extension. | 24 * Send a message to the C extension. |
| 25 * | 25 * |
| 26 * [requestType] is the specific request id to send. [id] is the id of the | 26 * [requestType] is the specific request id to send. [id] is the id of the |
| 27 * archive; it may be null for requests that don't operate on a specific | 27 * archive; it may be null for requests that don't operate on a specific |
| 28 * archive. [args] are arguments that will be passed on to the extension. They | 28 * archive. [args] are arguments that will be passed on to the extension. They |
| 29 * should all be C-safe. | 29 * should all be C-safe. |
| 30 * | 30 * |
| 31 * Returns a future that completes with the C extension's reply. | 31 * Returns a future that completes with the C extension's reply. |
| 32 */ | 32 */ |
| 33 Future call(int requestType, int id, [List args]) { | 33 Future call(int requestType, [int id, List args]) { |
| 34 var fullArgs = [requestType, id]; | 34 var fullArgs = [requestType, id]; |
| 35 if (args != null) fullArgs.addAll(args); | 35 if (args != null) fullArgs.addAll(args); |
| 36 return servicePort.call(listForC(fullArgs)).transform((response) { | 36 return servicePort.call(listForC(fullArgs)).transform((response) { |
| 37 var success = response[0]; | 37 var success = response[0]; |
| 38 var errno = response[1]; | 38 var errno = response[1]; |
| 39 var message = response[2]; | 39 var message = response[2]; |
| 40 | 40 |
| 41 if (!success) throw new ArchiveException(message, errno); | 41 if (!success) throw new ArchiveException(message, errno); |
| 42 return message; | 42 return message; |
| 43 }); | 43 }); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 /** The error code for the error, or null. */ | 100 /** The error code for the error, or null. */ |
| 101 final int errno; | 101 final int errno; |
| 102 | 102 |
| 103 ArchiveException(this.message, [this.errno]); | 103 ArchiveException(this.message, [this.errno]); |
| 104 | 104 |
| 105 String toString() { | 105 String toString() { |
| 106 if (errno == null) return "Archive error: $message"; | 106 if (errno == null) return "Archive error: $message"; |
| 107 return "Archive error $errno: $message"; | 107 return "Archive error $errno: $message"; |
| 108 } | 108 } |
| 109 } | 109 } |
| OLD | NEW |