OLD | NEW |
| (Empty) |
1 part of dart.convert; | |
2 class JsonUnsupportedObjectError extends Error {final unsupportedObject; | |
3 final cause; | |
4 JsonUnsupportedObjectError(this.unsupportedObject, { | |
5 this.cause} | |
6 ); | |
7 String toString() { | |
8 if (cause != null) { | |
9 return "Converting object to an encodable object failed."; | |
10 } | |
11 else { | |
12 return "Converting object did not return an encodable object."; | |
13 } | |
14 } | |
15 } | |
16 class JsonCyclicError extends JsonUnsupportedObjectError {JsonCyclicError(Objec
t object) : super(object); | |
17 String toString() => "Cyclic error in JSON stringify"; | |
18 } | |
19 const JsonCodec JSON = const JsonCodec(); | |
20 typedef _Reviver(var key, var value); | |
21 typedef _ToEncodable(var o); | |
22 class JsonCodec extends Codec<Object, String> {final _Reviver _reviver; | |
23 final _ToEncodable _toEncodable; | |
24 const JsonCodec({ | |
25 reviver(var key, var value), toEncodable(var object)} | |
26 ) : _reviver = reviver, _toEncodable = toEncodable; | |
27 JsonCodec.withReviver(reviver(var key, var value)) : this(reviver: reviver); | |
28 dynamic decode(String source, { | |
29 reviver(var key, var value)} | |
30 ) { | |
31 if (reviver == null) reviver = _reviver; | |
32 if (reviver == null) return decoder.convert(source); | |
33 return new JsonDecoder(reviver).convert(source); | |
34 } | |
35 String encode(Object value, { | |
36 toEncodable(var object)} | |
37 ) { | |
38 if (toEncodable == null) toEncodable = _toEncodable; | |
39 if (toEncodable == null) return encoder.convert(value); | |
40 return new JsonEncoder(DEVC$RT.cast(toEncodable, __CastType6, __CastType4, "Com
positeCast", """line 142, column 28 of dart:convert/json.dart: """, toEncodable
is __CastType4, false)).convert(value); | |
41 } | |
42 JsonEncoder get encoder { | |
43 if (_toEncodable == null) return const JsonEncoder(); | |
44 return new JsonEncoder(DEVC$RT.cast(_toEncodable, _ToEncodable, __CastType4, "C
ompositeCast", """line 147, column 28 of dart:convert/json.dart: """, _toEncodab
le is __CastType4, false)); | |
45 } | |
46 JsonDecoder get decoder { | |
47 if (_reviver == null) return const JsonDecoder(); | |
48 return new JsonDecoder(_reviver); | |
49 } | |
50 } | |
51 class JsonEncoder extends Converter<Object, String> {final String indent; | |
52 final Function _toEncodable; | |
53 const JsonEncoder([Object toEncodable(Object nonSerializable)]) : this.indent =
null, this._toEncodable = toEncodable; | |
54 const JsonEncoder.withIndent(this.indent, [Object toEncodable(Object nonSeriali
zable)]) : this._toEncodable = toEncodable; | |
55 String convert(Object object) => _JsonStringStringifier.stringify(object, DEVC$
RT.cast(_toEncodable, Function, __CastType6, "ImplicitCast", """line 243, column
48 of dart:convert/json.dart: """, _toEncodable is __CastType6, true), indent); | |
56 ChunkedConversionSink<Object> startChunkedConversion(Sink<String> sink) { | |
57 if (sink is! StringConversionSink) { | |
58 sink = new StringConversionSink.from(sink); | |
59 } | |
60 else if (sink is _Utf8EncoderSink) { | |
61 return new _JsonUtf8EncoderSink(sink._sink, _toEncodable, JsonUtf8Encoder._utf8E
ncode(indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); | |
62 } | |
63 return new _JsonEncoderSink(DEVC$RT.cast(sink, DEVC$RT.type((Sink<String> _) { | |
64 } | |
65 ), StringConversionSink, "ImplicitCast", """line 262, column 33 of dart:convert/
json.dart: """, sink is StringConversionSink, true), _toEncodable, indent); | |
66 } | |
67 Stream<String> bind(Stream<Object> stream) => super.bind(stream); | |
68 Converter<Object, dynamic> fuse(Converter<String, dynamic> other) { | |
69 if (other is Utf8Encoder) { | |
70 return new JsonUtf8Encoder(indent, DEVC$RT.cast(_toEncodable, Function, __CastTy
pe8, "CompositeCast", """line 270, column 42 of dart:convert/json.dart: """, _to
Encodable is __CastType8, false)); | |
71 } | |
72 return super.fuse(other); | |
73 } | |
74 } | |
75 class JsonUtf8Encoder extends Converter<Object, List<int>> {static const int DE
FAULT_BUFFER_SIZE = 256; | |
76 final List<int> _indent; | |
77 final Function _toEncodable; | |
78 final int _bufferSize; | |
79 JsonUtf8Encoder([String indent, toEncodable(Object object), int bufferSize = DE
FAULT_BUFFER_SIZE]) : _indent = _utf8Encode(indent), _toEncodable = toEncodable,
_bufferSize = bufferSize; | |
80 static List<int> _utf8Encode(String string) { | |
81 if (string == null) return null; | |
82 if (string.isEmpty) return new Uint8List(0); | |
83 checkAscii: { | |
84 for (int i = 0; i < string.length; i++) { | |
85 if (string.codeUnitAt(i) >= 0x80) break checkAscii; | |
86 } | |
87 return string.codeUnits; | |
88 } | |
89 return UTF8.encode(string); | |
90 } | |
91 List<int> convert(Object object) { | |
92 List<List<int>> bytes = <List<int>> []; | |
93 void addChunk(Uint8List chunk, int start, int end) { | |
94 if (start > 0 || end < chunk.length) { | |
95 int length = end - start; | |
96 chunk = new Uint8List.view(chunk.buffer, chunk.offsetInBytes + start, length); | |
97 } | |
98 bytes.add(chunk); | |
99 } | |
100 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func
tion, __CastType8, "CompositeCast", """line 352, column 36 of dart:convert/json.
dart: """, _toEncodable is __CastType8, false), _bufferSize, addChunk); | |
101 if (bytes.length == 1) return bytes[0]; | |
102 int length = 0; | |
103 for (int i = 0; i < bytes.length; i++) { | |
104 length += bytes[i].length; | |
105 } | |
106 Uint8List result = new Uint8List(length); | |
107 for (int i = 0, offset = 0; i < bytes.length; i++) { | |
108 var byteList = bytes[i]; | |
109 int end = offset + byteList.length; | |
110 result.setRange(offset, end, byteList); | |
111 offset = end; | |
112 } | |
113 return result; | |
114 } | |
115 ChunkedConversionSink<Object> startChunkedConversion(Sink<List<int>> sink) { | |
116 ByteConversionSink byteSink; | |
117 if (sink is ByteConversionSink) { | |
118 byteSink = sink; | |
119 } | |
120 else { | |
121 byteSink = new ByteConversionSink.from(sink); | |
122 } | |
123 return new _JsonUtf8EncoderSink(byteSink, _toEncodable, _indent, _bufferSize); | |
124 } | |
125 Stream<List<int>> bind(Stream<Object> stream) { | |
126 return super.bind(stream); | |
127 } | |
128 Converter<Object, dynamic> fuse(Converter<List<int>, dynamic> other) { | |
129 return super.fuse(other); | |
130 } | |
131 } | |
132 class _JsonEncoderSink extends ChunkedConversionSink<Object> {final String _ind
ent; | |
133 final Function _toEncodable; | |
134 final StringConversionSink _sink; | |
135 bool _isDone = false; | |
136 _JsonEncoderSink(this._sink, this._toEncodable, this._indent); | |
137 void add(Object o) { | |
138 if (_isDone) { | |
139 throw new StateError("Only one call to add allowed"); | |
140 } | |
141 _isDone = true; | |
142 ClosableStringSink stringSink = _sink.asStringSink(); | |
143 _JsonStringStringifier.printOn(o, stringSink, DEVC$RT.cast(_toEncodable, Functi
on, __CastType6, "ImplicitCast", """line 425, column 51 of dart:convert/json.dar
t: """, _toEncodable is __CastType6, true), _indent); | |
144 stringSink.close(); | |
145 } | |
146 void close() { | |
147 } | |
148 } | |
149 class _JsonUtf8EncoderSink extends ChunkedConversionSink<Object> {final ByteCon
versionSink _sink; | |
150 final List<int> _indent; | |
151 final Function _toEncodable; | |
152 final int _bufferSize; | |
153 bool _isDone = false; | |
154 _JsonUtf8EncoderSink(this._sink, this._toEncodable, this._indent, this._bufferS
ize); | |
155 void _addChunk(Uint8List chunk, int start, int end) { | |
156 _sink.addSlice(chunk, start, end, false); | |
157 } | |
158 void add(Object object) { | |
159 if (_isDone) { | |
160 throw new StateError("Only one call to add allowed"); | |
161 } | |
162 _isDone = true; | |
163 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func
tion, __CastType8, "CompositeCast", """line 455, column 53 of dart:convert/json.
dart: """, _toEncodable is __CastType8, false), _bufferSize, _addChunk); | |
164 _sink.close(); | |
165 } | |
166 void close() { | |
167 if (!_isDone) { | |
168 _isDone = true; | |
169 _sink.close(); | |
170 } | |
171 } | |
172 } | |
173 class JsonDecoder extends Converter<String, Object> {final _Reviver _reviver; | |
174 const JsonDecoder([reviver(var key, var value)]) : this._reviver = reviver; | |
175 dynamic convert(String input) => _parseJson(input, _reviver); | |
176 external StringConversionSink startChunkedConversion(Sink<Object> sink); | |
177 Stream<Object> bind(Stream<String> stream) => super.bind(stream); | |
178 } | |
179 external _parseJson(String source, reviver(key, value)) ; | |
180 Object _defaultToEncodable(object) => object.toJson(); | |
181 abstract class _JsonStringifier {static const int BACKSPACE = 0x08; | |
182 static const int TAB = 0x09; | |
183 static const int NEWLINE = 0x0a; | |
184 static const int CARRIAGE_RETURN = 0x0d; | |
185 static const int FORM_FEED = 0x0c; | |
186 static const int QUOTE = 0x22; | |
187 static const int CHAR_0 = 0x30; | |
188 static const int BACKSLASH = 0x5c; | |
189 static const int CHAR_b = 0x62; | |
190 static const int CHAR_f = 0x66; | |
191 static const int CHAR_n = 0x6e; | |
192 static const int CHAR_r = 0x72; | |
193 static const int CHAR_t = 0x74; | |
194 static const int CHAR_u = 0x75; | |
195 final List _seen = new List(); | |
196 final Function _toEncodable; | |
197 _JsonStringifier(Object _toEncodable(Object o)) : _toEncodable = (_toEncodable
!= null) ? _toEncodable : _defaultToEncodable; | |
198 void writeString(String characters); | |
199 void writeStringSlice(String characters, int start, int end); | |
200 void writeCharCode(int charCode); | |
201 void writeNumber(num number); | |
202 static int hexDigit(int x) => x < 10 ? 48 + x : 87 + x; | |
203 void writeStringContent(String s) { | |
204 int offset = 0; | |
205 final int length = s.length; | |
206 for (int i = 0; i < length; i++) { | |
207 int charCode = s.codeUnitAt(i); | |
208 if (charCode > BACKSLASH) continue; | |
209 if (charCode < 32) { | |
210 if (i > offset) writeStringSlice(s, offset, i); | |
211 offset = i + 1; | |
212 writeCharCode(BACKSLASH); | |
213 switch (charCode) {case BACKSPACE: writeCharCode(CHAR_b); | |
214 break; | |
215 case TAB: writeCharCode(CHAR_t); | |
216 break; | |
217 case NEWLINE: writeCharCode(CHAR_n); | |
218 break; | |
219 case FORM_FEED: writeCharCode(CHAR_f); | |
220 break; | |
221 case CARRIAGE_RETURN: writeCharCode(CHAR_r); | |
222 break; | |
223 default: writeCharCode(CHAR_u); | |
224 writeCharCode(CHAR_0); | |
225 writeCharCode(CHAR_0); | |
226 writeCharCode(hexDigit((charCode >> 4) & 0xf)); | |
227 writeCharCode(hexDigit(charCode & 0xf)); | |
228 break; | |
229 } | |
230 } | |
231 else if (charCode == QUOTE || charCode == BACKSLASH) { | |
232 if (i > offset) writeStringSlice(s, offset, i); | |
233 offset = i + 1; | |
234 writeCharCode(BACKSLASH); | |
235 writeCharCode(charCode); | |
236 } | |
237 } | |
238 if (offset == 0) { | |
239 writeString(s); | |
240 } | |
241 else if (offset < length) { | |
242 writeStringSlice(s, offset, length); | |
243 } | |
244 } | |
245 void _checkCycle(object) { | |
246 for (int i = 0; i < _seen.length; i++) { | |
247 if (identical(object, _seen[i])) { | |
248 throw new JsonCyclicError(object); | |
249 } | |
250 } | |
251 _seen.add(object); | |
252 } | |
253 void _removeSeen(object) { | |
254 assert (!_seen.isEmpty); assert (identical(_seen.last, object)); _seen.removeLas
t(); | |
255 } | |
256 void writeObject(object) { | |
257 if (writeJsonValue(object)) return; _checkCycle(object); | |
258 try { | |
259 var customJson = _toEncodable(object); | |
260 if (!writeJsonValue(customJson)) { | |
261 throw new JsonUnsupportedObjectError(object); | |
262 } | |
263 _removeSeen(object); | |
264 } | |
265 catch (e) { | |
266 throw new JsonUnsupportedObjectError(object, cause: e); | |
267 } | |
268 } | |
269 bool writeJsonValue(object) { | |
270 if (object is num) { | |
271 if (!object.isFinite) return false; | |
272 writeNumber(DEVC$RT.cast(object, dynamic, num, "DynamicCast", """line 673, colu
mn 19 of dart:convert/json.dart: """, object is num, true)); | |
273 return true; | |
274 } | |
275 else if (identical(object, true)) { | |
276 writeString('true'); | |
277 return true; | |
278 } | |
279 else if (identical(object, false)) { | |
280 writeString('false'); | |
281 return true; | |
282 } | |
283 else if (object == null) { | |
284 writeString('null'); | |
285 return true; | |
286 } | |
287 else if (object is String) { | |
288 writeString('"'); | |
289 writeStringContent(DEVC$RT.cast(object, dynamic, String, "DynamicCast", """line
686, column 26 of dart:convert/json.dart: """, object is String, true)); | |
290 writeString('"'); | |
291 return true; | |
292 } | |
293 else if (object is List) { | |
294 _checkCycle(object); | |
295 writeList(DEVC$RT.cast(object, dynamic, DEVC$RT.type((List<dynamic> _) { | |
296 } | |
297 ), "DynamicCast", """line 691, column 17 of dart:convert/json.dart: """, object
is List<dynamic>, true)); | |
298 _removeSeen(object); | |
299 return true; | |
300 } | |
301 else if (object is Map) { | |
302 _checkCycle(object); | |
303 writeMap(DEVC$RT.cast(object, dynamic, DEVC$RT.type((Map<String, Object> _) { | |
304 } | |
305 ), "CompositeCast", """line 696, column 16 of dart:convert/json.dart: """, objec
t is Map<String, Object>, false)); | |
306 _removeSeen(object); | |
307 return true; | |
308 } | |
309 else { | |
310 return false; | |
311 } | |
312 } | |
313 void writeList(List list) { | |
314 writeString('['); | |
315 if (list.length > 0) { | |
316 writeObject(list[0]); | |
317 for (int i = 1; i < list.length; i++) { | |
318 writeString(','); | |
319 writeObject(list[i]); | |
320 } | |
321 } | |
322 writeString(']'); | |
323 } | |
324 void writeMap(Map<String, Object> map) { | |
325 writeString('{'); | |
326 String separator = '"'; | |
327 map.forEach((String key, value) { | |
328 writeString(separator); | |
329 separator = ',"'; | |
330 writeStringContent(key); | |
331 writeString('":'); | |
332 writeObject(value); | |
333 } | |
334 ); | |
335 writeString('}'); | |
336 } | |
337 } | |
338 abstract class _JsonPrettyPrintMixin implements _JsonStringifier {int _indentLe
vel = 0; | |
339 void writeIndentation(indentLevel); | |
340 void writeList(List list) { | |
341 if (list.isEmpty) { | |
342 writeString('[]'); | |
343 } | |
344 else { | |
345 writeString('[\n'); | |
346 _indentLevel++; | |
347 writeIndentation(_indentLevel); | |
348 writeObject(list[0]); | |
349 for (int i = 1; i < list.length; i++) { | |
350 writeString(',\n'); | |
351 writeIndentation(_indentLevel); | |
352 writeObject(list[i]); | |
353 } | |
354 writeString('\n'); | |
355 _indentLevel--; | |
356 writeIndentation(_indentLevel); | |
357 writeString(']'); | |
358 } | |
359 } | |
360 void writeMap(Map map) { | |
361 if (map.isEmpty) { | |
362 writeString('{}'); | |
363 } | |
364 else { | |
365 writeString('{\n'); | |
366 _indentLevel++; | |
367 bool first = true; | |
368 map.forEach((String key, Object value) { | |
369 if (!first) { | |
370 writeString(",\n"); | |
371 } | |
372 writeIndentation(_indentLevel); | |
373 writeString('"'); | |
374 writeStringContent(key); | |
375 writeString('": '); | |
376 writeObject(value); | |
377 first = false; | |
378 } | |
379 ); | |
380 writeString('\n'); | |
381 _indentLevel--; | |
382 writeIndentation(_indentLevel); | |
383 writeString('}'); | |
384 } | |
385 } | |
386 } | |
387 class _JsonStringStringifier extends _JsonStringifier {final StringSink _sink; | |
388 _JsonStringStringifier(this._sink, _toEncodable) : super(DEVC$RT.cast(_toEncoda
ble, dynamic, __CastType4, "CompositeCast", """line 798, column 60 of dart:conve
rt/json.dart: """, _toEncodable is __CastType4, false)); | |
389 static String stringify(object, toEncodable(object), String indent) { | |
390 StringBuffer output = new StringBuffer(); | |
391 printOn(object, output, toEncodable, indent); | |
392 return output.toString(); | |
393 } | |
394 static void printOn(object, StringSink output, toEncodable(object), String inde
nt) { | |
395 var stringifier; | |
396 if (indent == null) { | |
397 stringifier = new _JsonStringStringifier(output, toEncodable); | |
398 } | |
399 else { | |
400 stringifier = new _JsonStringStringifierPretty(output, toEncodable, indent); | |
401 } | |
402 stringifier.writeObject(object); | |
403 } | |
404 void writeNumber(num number) { | |
405 _sink.write(number.toString()); | |
406 } | |
407 void writeString(String string) { | |
408 _sink.write(string); | |
409 } | |
410 void writeStringSlice(String string, int start, int end) { | |
411 _sink.write(string.substring(start, end)); | |
412 } | |
413 void writeCharCode(int charCode) { | |
414 _sink.writeCharCode(charCode); | |
415 } | |
416 } | |
417 class _JsonStringStringifierPretty extends _JsonStringStringifier with _JsonPre
ttyPrintMixin {final String _indent; | |
418 _JsonStringStringifierPretty(StringSink sink, Function toEncodable, this._inden
t) : super(sink, toEncodable); | |
419 void writeIndentation(int count) { | |
420 for (int i = 0; i < count; i++) writeString(_indent); | |
421 } | |
422 } | |
423 class _JsonUtf8Stringifier extends _JsonStringifier {final int bufferSize; | |
424 final Function addChunk; | |
425 Uint8List buffer; | |
426 int index = 0; | |
427 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) : this.bufferS
ize = bufferSize, buffer = new Uint8List(bufferSize), super(DEVC$RT.cast(toEncod
able, dynamic, __CastType4, "CompositeCast", """line 876, column 15 of dart:conv
ert/json.dart: """, toEncodable is __CastType4, false)); | |
428 static void stringify(Object object, List<int> indent, toEncodableFunction(Obje
ct o), int bufferSize, void addChunk(Uint8List chunk, int start, int end)) { | |
429 _JsonUtf8Stringifier stringifier; | |
430 if (indent != null) { | |
431 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent, buffer
Size, addChunk); | |
432 } | |
433 else { | |
434 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize, addChunk
); | |
435 } | |
436 stringifier.writeObject(object); | |
437 stringifier.flush(); | |
438 } | |
439 void flush() { | |
440 if (index > 0) { | |
441 addChunk(buffer, 0, index); | |
442 } | |
443 buffer = null; | |
444 index = 0; | |
445 } | |
446 void writeNumber(num number) { | |
447 writeAsciiString(number.toString()); | |
448 } | |
449 void writeAsciiString(String string) { | |
450 for (int i = 0; i < string.length; i++) { | |
451 int char = string.codeUnitAt(i); | |
452 assert (char <= 0x7f); writeByte(char); | |
453 } | |
454 } | |
455 void writeString(String string) { | |
456 writeStringSlice(string, 0, string.length); | |
457 } | |
458 void writeStringSlice(String string, int start, int end) { | |
459 for (int i = start; i < end; i++) { | |
460 int char = string.codeUnitAt(i); | |
461 if (char <= 0x7f) { | |
462 writeByte(char); | |
463 } | |
464 else { | |
465 if ((char & 0xFC00) == 0xD800 && i + 1 < end) { | |
466 int nextChar = string.codeUnitAt(i + 1); | |
467 if ((nextChar & 0xFC00) == 0xDC00) { | |
468 char = 0x10000 + ((char & 0x3ff) << 10) + (nextChar & 0x3ff); | |
469 writeFourByteCharCode(char); | |
470 i++; | |
471 continue; | |
472 } | |
473 } | |
474 writeMultiByteCharCode(char); | |
475 } | |
476 } | |
477 } | |
478 void writeCharCode(int charCode) { | |
479 if (charCode <= 0x7f) { | |
480 writeByte(charCode); | |
481 return;} | |
482 writeMultiByteCharCode(charCode); | |
483 } | |
484 void writeMultiByteCharCode(int charCode) { | |
485 if (charCode <= 0x7ff) { | |
486 writeByte(0xC0 | (charCode >> 6)); | |
487 writeByte(0x80 | (charCode & 0x3f)); | |
488 return;} | |
489 if (charCode <= 0xffff) { | |
490 writeByte(0xE0 | (charCode >> 12)); | |
491 writeByte(0x80 | ((charCode >> 6) & 0x3f)); | |
492 writeByte(0x80 | (charCode & 0x3f)); | |
493 return;} | |
494 writeFourByteCharCode(charCode); | |
495 } | |
496 void writeFourByteCharCode(int charCode) { | |
497 assert (charCode <= 0x10ffff); writeByte(0xF0 | (charCode >> 18)); | |
498 writeByte(0x80 | ((charCode >> 12) & 0x3f)); | |
499 writeByte(0x80 | ((charCode >> 6) & 0x3f)); | |
500 writeByte(0x80 | (charCode & 0x3f)); | |
501 } | |
502 void writeByte(int byte) { | |
503 assert (byte <= 0xff); if (index == buffer.length) { | |
504 addChunk(buffer, 0, index); | |
505 buffer = new Uint8List(bufferSize); | |
506 index = 0; | |
507 } | |
508 buffer[index++] = byte; | |
509 } | |
510 } | |
511 class _JsonUtf8StringifierPretty extends _JsonUtf8Stringifier with _JsonPrettyP
rintMixin {final List<int> indent; | |
512 _JsonUtf8StringifierPretty(toEncodableFunction, this.indent, bufferSize, addChu
nk) : super(toEncodableFunction, DEVC$RT.cast(bufferSize, dynamic, int, "Dynamic
Cast", """line 1013, column 36 of dart:convert/json.dart: """, bufferSize is int
, true), DEVC$RT.cast(addChunk, dynamic, Function, "DynamicCast", """line 1013,
column 48 of dart:convert/json.dart: """, addChunk is Function, true)); | |
513 void writeIndentation(int count) { | |
514 List<int> indent = this.indent; | |
515 int indentLength = indent.length; | |
516 if (indentLength == 1) { | |
517 int char = indent[0]; | |
518 while (count > 0) { | |
519 writeByte(char); | |
520 count -= 1; | |
521 } | |
522 return;} | |
523 while (count > 0) { | |
524 count--; | |
525 int end = index + indentLength; | |
526 if (end <= buffer.length) { | |
527 buffer.setRange(index, end, indent); | |
528 index = end; | |
529 } | |
530 else { | |
531 for (int i = 0; i < indentLength; i++) { | |
532 writeByte(indent[i]); | |
533 } | |
534 } | |
535 } | |
536 } | |
537 } | |
538 typedef Object __CastType4(Object __u5); | |
539 typedef dynamic __CastType6(dynamic __u7); | |
540 typedef dynamic __CastType8(Object __u9); | |
OLD | NEW |