| 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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 * The JSON text is UTF-8 encoded and written to [Uint8List] buffers. | 864 * The JSON text is UTF-8 encoded and written to [Uint8List] buffers. |
| 865 * The buffers are then passed back to a user provided callback method. | 865 * The buffers are then passed back to a user provided callback method. |
| 866 */ | 866 */ |
| 867 class _JsonUtf8Stringifier extends _JsonStringifier { | 867 class _JsonUtf8Stringifier extends _JsonStringifier { |
| 868 final int bufferSize; | 868 final int bufferSize; |
| 869 final Function addChunk; | 869 final Function addChunk; |
| 870 Uint8List buffer; | 870 Uint8List buffer; |
| 871 int index = 0; | 871 int index = 0; |
| 872 | 872 |
| 873 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) | 873 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) |
| 874 : super(toEncodable), | 874 : this.bufferSize = bufferSize, |
| 875 this.bufferSize = bufferSize, | 875 buffer = new Uint8List(bufferSize), |
| 876 buffer = new Uint8List(bufferSize); | 876 super(toEncodable) |
| 877 ; |
| 877 | 878 |
| 878 /** | 879 /** |
| 879 * Convert [object] to UTF-8 encoded JSON. | 880 * Convert [object] to UTF-8 encoded JSON. |
| 880 * | 881 * |
| 881 * Calls [addChunk] with slices of UTF-8 code units. | 882 * Calls [addChunk] with slices of UTF-8 code units. |
| 882 * These will typically have size [bufferSize], but may be shorter. | 883 * These will typically have size [bufferSize], but may be shorter. |
| 883 * The buffers are not reused, so the [addChunk] call may keep and reuse | 884 * The buffers are not reused, so the [addChunk] call may keep and reuse |
| 884 * the chunks. | 885 * the chunks. |
| 885 * | 886 * |
| 886 * If [indent] is non-`null`, the result will be "pretty-printed" with | 887 * 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... |
| 1029 buffer.setRange(index, end, indent); | 1030 buffer.setRange(index, end, indent); |
| 1030 index = end; | 1031 index = end; |
| 1031 } else { | 1032 } else { |
| 1032 for (int i = 0; i < indentLength; i++) { | 1033 for (int i = 0; i < indentLength; i++) { |
| 1033 writeByte(indent[i]); | 1034 writeByte(indent[i]); |
| 1034 } | 1035 } |
| 1035 } | 1036 } |
| 1036 } | 1037 } |
| 1037 } | 1038 } |
| 1038 } | 1039 } |
| OLD | NEW |