Index: sdk/lib/io/io_sink.dart |
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart |
index a6d9f534a8531d7e761314770cbd1285c5f5343b..0c2752244994d403db9773487ce45177bf22ba35 100644 |
--- a/sdk/lib/io/io_sink.dart |
+++ b/sdk/lib/io/io_sink.dart |
@@ -8,7 +8,7 @@ part of dart.io; |
* Helper class to wrap a [StreamConsumer<List<int>>] and provide |
* utility functions for writing to the StreamConsumer directly. The |
* [IOSink] buffers the input given by all [StringSink] methods and will delay |
- * a [addStream] until the buffer is flushed. |
+ * an [addStream] until the buffer is flushed. |
* |
* When the [IOSink] is bound to a stream (through [addStream]) any call |
* to the [IOSink] will throw a [StateError]. When the [addStream] completes, |
@@ -18,6 +18,7 @@ part of dart.io; |
* ignored. Use the [done] future to be notified when the [IOSink] is closed. |
*/ |
abstract class IOSink implements StreamSink<List<int>>, StringSink { |
+ // TODO(ajohnsen): Make _encodingMutable an argument. |
factory IOSink(StreamConsumer<List<int>> target, |
{Encoding encoding: UTF8}) |
=> new _IOSinkImpl(target, encoding); |
@@ -29,14 +30,68 @@ abstract class IOSink implements StreamSink<List<int>>, StringSink { |
Encoding encoding; |
/** |
- * Writes the bytes uninterpreted to the consumer. While the call is |
- * synchronous, the data may be buffered until the underlying resource is |
- * ready. The data should not be modified after a call to [add]. |
+ * Adds [data] to the target consumer, ignoring [encoding]. |
+ * |
+ * The [encoding] does not apply to this method, and the `data` list is passed |
+ * directly to the target consumer as a stream event. |
+ * |
+ * This function must not be called when a stream is currently being added |
+ * using [addStream]. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
+ * |
+ * The data list should not be modified after it has been passed to `add`. |
*/ |
void add(List<int> data); |
/** |
- * Writes an error to the consumer. |
+ * Converts [obj] to a String by invoking [Object.toString] and |
+ * [add]s the encoding of the result to the target consumer. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
+ */ |
+ void write(Object obj); |
+ |
+ /** |
+ * Iterates over the given [objects] and [write]s them in sequence. |
+ * |
+ * If [separator] is provided, a `write` with the `separator` is performed |
+ * between any two elements of `objects`. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
+ */ |
+ void writeAll(Iterable objects, [String separator = ""]); |
+ |
+ /** |
+ * Converts [obj] to a String by invoking [Object.toString] and |
+ * writes the result to `this`, followed by a newline. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
+ */ |
+ void writeln([Object obj = ""]); |
+ |
+ /** |
+ * Writes the [charCode] to `this`. |
+ * |
+ * This method is equivalent to `write(new String.fromCharCode(charCode))`. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
+ */ |
+ void writeCharCode(int charCode); |
+ |
+ /** |
+ * Passes the error to the target consumer as an error event. |
+ * |
+ * This function must not be called when a stream is currently being added |
+ * using [addStream]. |
+ * |
+ * This operation is non-blocking. See [flush] or [done] for how to get any |
+ * errors generated by this call. |
*/ |
void addError(error, [StackTrace stackTrace]); |
@@ -57,13 +112,14 @@ abstract class IOSink implements StreamSink<List<int>>, StringSink { |
Future flush(); |
/** |
- * Close the target. |
+ * Close the target consumer. |
*/ |
Future close(); |
/** |
- * Get a future that will complete when all synchronous have completed, or an |
- * error happened. This future is identical to the future returned from close. |
+ * Get a future that will complete when the consumer closes, or when an |
+ * error occurs. This future is identical to the future returned by |
+ * [close]. |
*/ |
Future get done; |
} |