| OLD | NEW |
| 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 * Error thrown by JSON serialization if an object cannot be serialized. | 8 * Error thrown by JSON serialization if an object cannot be serialized. |
| 9 * | 9 * |
| 10 * The [unsupportedObject] field holds that object that failed to be serialized. | 10 * The [unsupportedObject] field holds that object that failed to be serialized. |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 * The JSON text is UTF-8 encoded and written to [Uint8List] buffers. | 896 * The JSON text is UTF-8 encoded and written to [Uint8List] buffers. |
| 897 * The buffers are then passed back to a user provided callback method. | 897 * The buffers are then passed back to a user provided callback method. |
| 898 */ | 898 */ |
| 899 class _JsonUtf8Stringifier extends _JsonStringifier { | 899 class _JsonUtf8Stringifier extends _JsonStringifier { |
| 900 final int bufferSize; | 900 final int bufferSize; |
| 901 final Function addChunk; | 901 final Function addChunk; |
| 902 Uint8List buffer; | 902 Uint8List buffer; |
| 903 int index = 0; | 903 int index = 0; |
| 904 | 904 |
| 905 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) | 905 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) |
| 906 : super(toEncodable), | 906 : this.bufferSize = bufferSize, |
| 907 this.bufferSize = bufferSize, | 907 buffer = new Uint8List(bufferSize), |
| 908 buffer = new Uint8List(bufferSize); | 908 super(toEncodable); |
| 909 | 909 |
| 910 /** | 910 /** |
| 911 * Convert [object] to UTF-8 encoded JSON. | 911 * Convert [object] to UTF-8 encoded JSON. |
| 912 * | 912 * |
| 913 * Calls [addChunk] with slices of UTF-8 code units. | 913 * Calls [addChunk] with slices of UTF-8 code units. |
| 914 * These will typically have size [bufferSize], but may be shorter. | 914 * These will typically have size [bufferSize], but may be shorter. |
| 915 * The buffers are not reused, so the [addChunk] call may keep and reuse | 915 * The buffers are not reused, so the [addChunk] call may keep and reuse |
| 916 * the chunks. | 916 * the chunks. |
| 917 * | 917 * |
| 918 * If [indent] is non-`null`, the result will be "pretty-printed" with | 918 * If [indent] is non-`null`, the result will be "pretty-printed" with |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 buffer.setRange(index, end, indent); | 1061 buffer.setRange(index, end, indent); |
| 1062 index = end; | 1062 index = end; |
| 1063 } else { | 1063 } else { |
| 1064 for (int i = 0; i < indentLength; i++) { | 1064 for (int i = 0; i < indentLength; i++) { |
| 1065 writeByte(indent[i]); | 1065 writeByte(indent[i]); |
| 1066 } | 1066 } |
| 1067 } | 1067 } |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 } | 1070 } |
| OLD | NEW |