OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import "dart:_internal" show POWERS_OF_TEN; | 5 import "dart:_internal" show POWERS_OF_TEN; |
6 | 6 |
7 // JSON conversion. | 7 // JSON conversion. |
8 | 8 |
9 patch _parseJson(String json, reviver(var key, var value)) { | 9 patch _parseJson(String json, reviver(var key, var value)) { |
10 _BuildJsonListener listener; | 10 _BuildJsonListener listener; |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 // Allow intercepting of UTF-8 decoding when built-in lists are passed. | 34 // Allow intercepting of UTF-8 decoding when built-in lists are passed. |
35 /* patch */ | 35 /* patch */ |
36 static String _convertIntercepted( | 36 static String _convertIntercepted( |
37 bool allowMalformed, List<int> codeUnits, int start, int end) { | 37 bool allowMalformed, List<int> codeUnits, int start, int end) { |
38 return null; // This call was not intercepted. | 38 return null; // This call was not intercepted. |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 class _JsonUtf8Decoder extends Converter<List<int>, Object> { | 42 class _JsonUtf8Decoder extends |
| 43 ChunkedConverter<List<int>, Object, List<int>, Object> { |
43 final _Reviver _reviver; | 44 final _Reviver _reviver; |
44 final bool _allowMalformed; | 45 final bool _allowMalformed; |
45 | 46 |
46 _JsonUtf8Decoder(this._reviver, this._allowMalformed); | 47 _JsonUtf8Decoder(this._reviver, this._allowMalformed); |
47 | 48 |
48 dynamic convert(List<int> input) { | 49 Object convert(List<int> input) { |
49 var parser = _JsonUtf8DecoderSink._createParser(_reviver, _allowMalformed); | 50 var parser = _JsonUtf8DecoderSink._createParser(_reviver, _allowMalformed); |
50 parser.chunk = input; | 51 parser.chunk = input; |
51 parser.chunkEnd = input.length; | 52 parser.chunkEnd = input.length; |
52 parser.parse(0); | 53 parser.parse(0); |
53 return parser.result; | 54 return parser.result; |
54 } | 55 } |
55 | 56 |
56 ByteConversionSink startChunkedConversion(Sink<Object> sink) { | 57 ByteConversionSink startChunkedConversion(Sink<Object> sink) { |
57 return new _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed); | 58 return new _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed); |
58 } | 59 } |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 _parser.parse(start); | 1766 _parser.parse(start); |
1766 } | 1767 } |
1767 | 1768 |
1768 void close() { | 1769 void close() { |
1769 _parser.close(); | 1770 _parser.close(); |
1770 var decoded = _parser.result; | 1771 var decoded = _parser.result; |
1771 _sink.add(decoded); | 1772 _sink.add(decoded); |
1772 _sink.close(); | 1773 _sink.close(); |
1773 } | 1774 } |
1774 } | 1775 } |
OLD | NEW |