Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sdk/lib/convert/converter.dart

Issue 1847843002: Steps towards making the convert library strong-mode compliant. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Relax type and fix missed converters. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/convert/chunked_conversion.dart ('k') | sdk/lib/convert/encoding.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.convert; 5 part of dart.convert;
6 6
7 /** 7 /**
8 * A [Converter] converts data from one representation into another. 8 * A [Converter] converts data from one representation into another.
9 * 9 *
10 * It is recommended that implementations of `Converter` extend this class, 10 * It is recommended that implementations of `Converter` extend this class,
(...skipping 11 matching lines...) Expand all
22 * Fuses `this` with [other]. 22 * Fuses `this` with [other].
23 * 23 *
24 * Encoding with the resulting converter is equivalent to converting with 24 * Encoding with the resulting converter is equivalent to converting with
25 * `this` before converting with `other`. 25 * `this` before converting with `other`.
26 */ 26 */
27 Converter<S, dynamic> fuse(Converter<T, dynamic> other) { 27 Converter<S, dynamic> fuse(Converter<T, dynamic> other) {
28 return new _FusedConverter<S, T, dynamic>(this, other); 28 return new _FusedConverter<S, T, dynamic>(this, other);
29 } 29 }
30 30
31 /** 31 /**
32 * Starts a chunked conversion. 32 * Deprecated.
33 *
34 * Use the [ChunkedConverter] interface instead.
33 */ 35 */
36 @deprecated
34 ChunkedConversionSink startChunkedConversion(Sink sink) { 37 ChunkedConversionSink startChunkedConversion(Sink sink) {
35 throw new UnsupportedError( 38 throw new UnsupportedError(
36 "This converter does not support chunked conversions: $this"); 39 "This converter does not support chunked conversions: $this");
37 } 40 }
38 41
39 // Subclasses are encouraged to provide better types. 42 /**
43 * Deprecated.
44 *
45 * Use the [ChunkedConverter] interface instead.
46 */
47 @deprecated
40 Stream bind(Stream stream) { 48 Stream bind(Stream stream) {
41 return new Stream.eventTransformed( 49 return new Stream.eventTransformed(
42 stream, 50 stream,
43 (EventSink sink) => new _ConverterStreamEventSink(this, sink)); 51 (EventSink sink) => new _ConverterStreamEventSink(this, sink));
44 } 52 }
45 } 53 }
46 54
47 /** 55 /**
48 * Fuses two converters. 56 * Fuses two converters.
49 * 57 *
50 * For a non-chunked conversion converts the input in sequence. 58 * For a non-chunked conversion converts the input in sequence.
51 */ 59 */
52 class _FusedConverter<S, M, T> extends Converter<S, T> { 60 class _FusedConverter<S, M, T> extends Converter<S, T> {
53 final Converter _first; 61 final Converter<S, M> _first;
54 final Converter _second; 62 final Converter<M, T> _second;
55 63
56 _FusedConverter(this._first, this._second); 64 _FusedConverter(this._first, this._second);
57 65
58 T convert(S input) => _second.convert(_first.convert(input)); 66 T convert(S input) => _second.convert(_first.convert(input));
59
60 ChunkedConversionSink startChunkedConversion(Sink sink) {
61 return _first.startChunkedConversion(_second.startChunkedConversion(sink));
62 }
63 } 67 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/chunked_conversion.dart ('k') | sdk/lib/convert/encoding.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698