OLD | NEW |
1 dart_library.library('dart/convert', null, /* Imports */[ | 1 dart_library.library('dart/convert', null, /* Imports */[ |
2 "dart/_runtime", | 2 "dart/_runtime", |
3 'dart/core', | 3 'dart/core', |
4 'dart/async', | 4 'dart/async', |
5 'dart/typed_data', | 5 'dart/typed_data', |
6 'dart/_internal', | 6 'dart/_internal', |
7 'dart/collection' | 7 'dart/collection' |
8 ], /* Lazy imports */[ | 8 ], /* Lazy imports */[ |
9 ], function(exports, dart, core, async, typed_data, _internal, collection) { | 9 ], function(exports, dart, core, async, typed_data, _internal, collection) { |
10 'use strict'; | 10 'use strict'; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 } | 59 } |
60 dart.setSignature(Encoding, { | 60 dart.setSignature(Encoding, { |
61 constructors: () => ({Encoding: [Encoding, []]}), | 61 constructors: () => ({Encoding: [Encoding, []]}), |
62 methods: () => ({decodeStream: [async.Future$(core.String), [async.Stream$(c
ore.List$(core.int))]]}), | 62 methods: () => ({decodeStream: [async.Future$(core.String), [async.Stream$(c
ore.List$(core.int))]]}), |
63 statics: () => ({getByName: [Encoding, [core.String]]}), | 63 statics: () => ({getByName: [Encoding, [core.String]]}), |
64 names: ['getByName'] | 64 names: ['getByName'] |
65 }); | 65 }); |
66 let _allowInvalid = Symbol('_allowInvalid'); | 66 let _allowInvalid = Symbol('_allowInvalid'); |
67 class AsciiCodec extends Encoding { | 67 class AsciiCodec extends Encoding { |
68 AsciiCodec(opts) { | 68 AsciiCodec({allowInvalid = false} = {}) { |
69 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | |
70 this[_allowInvalid] = allowInvalid; | 69 this[_allowInvalid] = allowInvalid; |
71 super.Encoding(); | 70 super.Encoding(); |
72 } | 71 } |
73 get name() { | 72 get name() { |
74 return "us-ascii"; | 73 return "us-ascii"; |
75 } | 74 } |
76 decode(bytes, opts) { | 75 decode(bytes, {allowInvalid = null} = {}) { |
77 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; | |
78 if (allowInvalid == null) | 76 if (allowInvalid == null) |
79 allowInvalid = this[_allowInvalid]; | 77 allowInvalid = this[_allowInvalid]; |
80 if (dart.notNull(allowInvalid)) { | 78 if (dart.notNull(allowInvalid)) { |
81 return dart.const(new AsciiDecoder({allowInvalid: true})).convert(bytes)
; | 79 return dart.const(new AsciiDecoder({allowInvalid: true})).convert(bytes)
; |
82 } else { | 80 } else { |
83 return dart.const(new AsciiDecoder({allowInvalid: false})).convert(bytes
); | 81 return dart.const(new AsciiDecoder({allowInvalid: false})).convert(bytes
); |
84 } | 82 } |
85 } | 83 } |
86 get encoder() { | 84 get encoder() { |
87 return dart.const(new AsciiEncoder()); | 85 return dart.const(new AsciiEncoder()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 269 } |
272 dart.setSignature(_UnicodeSubsetDecoder, { | 270 dart.setSignature(_UnicodeSubsetDecoder, { |
273 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b
ool, core.int]]}), | 271 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b
ool, core.int]]}), |
274 methods: () => ({ | 272 methods: () => ({ |
275 convert: [core.String, [core.List$(core.int)], [core.int, core.int]], | 273 convert: [core.String, [core.List$(core.int)], [core.int, core.int]], |
276 [_convertInvalid]: [core.String, [core.List$(core.int), core.int, core.int
]], | 274 [_convertInvalid]: [core.String, [core.List$(core.int), core.int, core.int
]], |
277 bind: [async.Stream$(core.String), [async.Stream$(core.List$(core.int))]] | 275 bind: [async.Stream$(core.String), [async.Stream$(core.List$(core.int))]] |
278 }) | 276 }) |
279 }); | 277 }); |
280 class AsciiDecoder extends _UnicodeSubsetDecoder { | 278 class AsciiDecoder extends _UnicodeSubsetDecoder { |
281 AsciiDecoder(opts) { | 279 AsciiDecoder({allowInvalid = false} = {}) { |
282 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | |
283 super._UnicodeSubsetDecoder(allowInvalid, _ASCII_MASK); | 280 super._UnicodeSubsetDecoder(allowInvalid, _ASCII_MASK); |
284 } | 281 } |
285 startChunkedConversion(sink) { | 282 startChunkedConversion(sink) { |
286 let stringSink = null; | 283 let stringSink = null; |
287 if (dart.is(sink, StringConversionSink)) { | 284 if (dart.is(sink, StringConversionSink)) { |
288 stringSink = sink; | 285 stringSink = sink; |
289 } else { | 286 } else { |
290 stringSink = StringConversionSink.from(sink); | 287 stringSink = StringConversionSink.from(sink); |
291 } | 288 } |
292 if (dart.notNull(this[_allowInvalid])) { | 289 if (dart.notNull(this[_allowInvalid])) { |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 } | 771 } |
775 } | 772 } |
776 dart.setSignature(_HtmlEscapeSink, { | 773 dart.setSignature(_HtmlEscapeSink, { |
777 constructors: () => ({_HtmlEscapeSink: [_HtmlEscapeSink, [HtmlEscape, String
ConversionSink]]}), | 774 constructors: () => ({_HtmlEscapeSink: [_HtmlEscapeSink, [HtmlEscape, String
ConversionSink]]}), |
778 methods: () => ({ | 775 methods: () => ({ |
779 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]], | 776 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]], |
780 close: [dart.void, []] | 777 close: [dart.void, []] |
781 }) | 778 }) |
782 }); | 779 }); |
783 class JsonUnsupportedObjectError extends core.Error { | 780 class JsonUnsupportedObjectError extends core.Error { |
784 JsonUnsupportedObjectError(unsupportedObject, opts) { | 781 JsonUnsupportedObjectError(unsupportedObject, {cause = null} = {}) { |
785 let cause = opts && 'cause' in opts ? opts.cause : null; | |
786 this.unsupportedObject = unsupportedObject; | 782 this.unsupportedObject = unsupportedObject; |
787 this.cause = cause; | 783 this.cause = cause; |
788 super.Error(); | 784 super.Error(); |
789 } | 785 } |
790 toString() { | 786 toString() { |
791 if (this.cause != null) { | 787 if (this.cause != null) { |
792 return "Converting object to an encodable object failed."; | 788 return "Converting object to an encodable object failed."; |
793 } else { | 789 } else { |
794 return "Converting object did not return an encodable object."; | 790 return "Converting object did not return an encodable object."; |
795 } | 791 } |
796 } | 792 } |
797 } | 793 } |
798 dart.setSignature(JsonUnsupportedObjectError, { | 794 dart.setSignature(JsonUnsupportedObjectError, { |
799 constructors: () => ({JsonUnsupportedObjectError: [JsonUnsupportedObjectErro
r, [dart.dynamic], {cause: dart.dynamic}]}) | 795 constructors: () => ({JsonUnsupportedObjectError: [JsonUnsupportedObjectErro
r, [dart.dynamic], {cause: dart.dynamic}]}) |
800 }); | 796 }); |
801 class JsonCyclicError extends JsonUnsupportedObjectError { | 797 class JsonCyclicError extends JsonUnsupportedObjectError { |
802 JsonCyclicError(object) { | 798 JsonCyclicError(object) { |
803 super.JsonUnsupportedObjectError(object); | 799 super.JsonUnsupportedObjectError(object); |
804 } | 800 } |
805 toString() { | 801 toString() { |
806 return "Cyclic error in JSON stringify"; | 802 return "Cyclic error in JSON stringify"; |
807 } | 803 } |
808 } | 804 } |
809 dart.setSignature(JsonCyclicError, { | 805 dart.setSignature(JsonCyclicError, { |
810 constructors: () => ({JsonCyclicError: [JsonCyclicError, [core.Object]]}) | 806 constructors: () => ({JsonCyclicError: [JsonCyclicError, [core.Object]]}) |
811 }); | 807 }); |
812 let _reviver = Symbol('_reviver'); | 808 let _reviver = Symbol('_reviver'); |
813 let _toEncodable$ = Symbol('_toEncodable'); | 809 let _toEncodable$ = Symbol('_toEncodable'); |
814 class JsonCodec extends Codec$(core.Object, core.String) { | 810 class JsonCodec extends Codec$(core.Object, core.String) { |
815 JsonCodec(opts) { | 811 JsonCodec({reviver = null, toEncodable = null} = {}) { |
816 let reviver = opts && 'reviver' in opts ? opts.reviver : null; | |
817 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; | |
818 this[_reviver] = reviver; | 812 this[_reviver] = reviver; |
819 this[_toEncodable$] = toEncodable; | 813 this[_toEncodable$] = toEncodable; |
820 super.Codec(); | 814 super.Codec(); |
821 } | 815 } |
822 withReviver(reviver) { | 816 withReviver(reviver) { |
823 this.JsonCodec({reviver: reviver}); | 817 this.JsonCodec({reviver: reviver}); |
824 } | 818 } |
825 decode(source, opts) { | 819 decode(source, {reviver = null} = {}) { |
826 let reviver = opts && 'reviver' in opts ? opts.reviver : null; | |
827 if (reviver == null) | 820 if (reviver == null) |
828 reviver = this[_reviver]; | 821 reviver = this[_reviver]; |
829 if (reviver == null) | 822 if (reviver == null) |
830 return this.decoder.convert(source); | 823 return this.decoder.convert(source); |
831 return new JsonDecoder(reviver).convert(source); | 824 return new JsonDecoder(reviver).convert(source); |
832 } | 825 } |
833 encode(value, opts) { | 826 encode(value, {toEncodable = null} = {}) { |
834 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; | |
835 if (toEncodable == null) | 827 if (toEncodable == null) |
836 toEncodable = this[_toEncodable$]; | 828 toEncodable = this[_toEncodable$]; |
837 if (toEncodable == null) | 829 if (toEncodable == null) |
838 return this.encoder.convert(value); | 830 return this.encoder.convert(value); |
839 return new JsonEncoder(dart.as(toEncodable, __CastType0)).convert(value); | 831 return new JsonEncoder(dart.as(toEncodable, __CastType0)).convert(value); |
840 } | 832 } |
841 get encoder() { | 833 get encoder() { |
842 if (this[_toEncodable$] == null) | 834 if (this[_toEncodable$] == null) |
843 return dart.const(new JsonEncoder()); | 835 return dart.const(new JsonEncoder()); |
844 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core
.Object, [core.Object]))); | 836 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core
.Object, [core.Object]))); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 } | 1545 } |
1554 } | 1546 } |
1555 dart.setSignature(_JsonUtf8StringifierPretty, { | 1547 dart.setSignature(_JsonUtf8StringifierPretty, { |
1556 constructors: () => ({_JsonUtf8StringifierPretty: [_JsonUtf8StringifierPrett
y, [dart.dynamic, core.List$(core.int), dart.dynamic, dart.dynamic]]}), | 1548 constructors: () => ({_JsonUtf8StringifierPretty: [_JsonUtf8StringifierPrett
y, [dart.dynamic, core.List$(core.int), dart.dynamic, dart.dynamic]]}), |
1557 methods: () => ({writeIndentation: [dart.void, [core.int]]}) | 1549 methods: () => ({writeIndentation: [dart.void, [core.int]]}) |
1558 }); | 1550 }); |
1559 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.Obj
ect, [core.Object])); | 1551 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.Obj
ect, [core.Object])); |
1560 let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(dart.dyn
amic, [dart.dynamic])); | 1552 let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(dart.dyn
amic, [dart.dynamic])); |
1561 let __CastType4 = dart.typedef('__CastType4', () => dart.functionType(dart.dyn
amic, [core.Object])); | 1553 let __CastType4 = dart.typedef('__CastType4', () => dart.functionType(dart.dyn
amic, [core.Object])); |
1562 class Latin1Codec extends Encoding { | 1554 class Latin1Codec extends Encoding { |
1563 Latin1Codec(opts) { | 1555 Latin1Codec({allowInvalid = false} = {}) { |
1564 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | |
1565 this[_allowInvalid] = allowInvalid; | 1556 this[_allowInvalid] = allowInvalid; |
1566 super.Encoding(); | 1557 super.Encoding(); |
1567 } | 1558 } |
1568 get name() { | 1559 get name() { |
1569 return "iso-8859-1"; | 1560 return "iso-8859-1"; |
1570 } | 1561 } |
1571 decode(bytes, opts) { | 1562 decode(bytes, {allowInvalid = null} = {}) { |
1572 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; | |
1573 if (allowInvalid == null) | 1563 if (allowInvalid == null) |
1574 allowInvalid = this[_allowInvalid]; | 1564 allowInvalid = this[_allowInvalid]; |
1575 if (dart.notNull(allowInvalid)) { | 1565 if (dart.notNull(allowInvalid)) { |
1576 return dart.const(new Latin1Decoder({allowInvalid: true})).convert(bytes
); | 1566 return dart.const(new Latin1Decoder({allowInvalid: true})).convert(bytes
); |
1577 } else { | 1567 } else { |
1578 return dart.const(new Latin1Decoder({allowInvalid: false})).convert(byte
s); | 1568 return dart.const(new Latin1Decoder({allowInvalid: false})).convert(byte
s); |
1579 } | 1569 } |
1580 } | 1570 } |
1581 get encoder() { | 1571 get encoder() { |
1582 return dart.const(new Latin1Encoder()); | 1572 return dart.const(new Latin1Encoder()); |
(...skipping 10 matching lines...) Expand all Loading... |
1593 let _LATIN1_MASK = 255; | 1583 let _LATIN1_MASK = 255; |
1594 class Latin1Encoder extends _UnicodeSubsetEncoder { | 1584 class Latin1Encoder extends _UnicodeSubsetEncoder { |
1595 Latin1Encoder() { | 1585 Latin1Encoder() { |
1596 super._UnicodeSubsetEncoder(_LATIN1_MASK); | 1586 super._UnicodeSubsetEncoder(_LATIN1_MASK); |
1597 } | 1587 } |
1598 } | 1588 } |
1599 dart.setSignature(Latin1Encoder, { | 1589 dart.setSignature(Latin1Encoder, { |
1600 constructors: () => ({Latin1Encoder: [Latin1Encoder, []]}) | 1590 constructors: () => ({Latin1Encoder: [Latin1Encoder, []]}) |
1601 }); | 1591 }); |
1602 class Latin1Decoder extends _UnicodeSubsetDecoder { | 1592 class Latin1Decoder extends _UnicodeSubsetDecoder { |
1603 Latin1Decoder(opts) { | 1593 Latin1Decoder({allowInvalid = false} = {}) { |
1604 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | |
1605 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK); | 1594 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK); |
1606 } | 1595 } |
1607 startChunkedConversion(sink) { | 1596 startChunkedConversion(sink) { |
1608 let stringSink = null; | 1597 let stringSink = null; |
1609 if (dart.is(sink, StringConversionSink)) { | 1598 if (dart.is(sink, StringConversionSink)) { |
1610 stringSink = sink; | 1599 stringSink = sink; |
1611 } else { | 1600 } else { |
1612 stringSink = StringConversionSink.from(sink); | 1601 stringSink = StringConversionSink.from(sink); |
1613 } | 1602 } |
1614 if (!dart.notNull(this[_allowInvalid])) | 1603 if (!dart.notNull(this[_allowInvalid])) |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 methods: () => ({ | 2051 methods: () => ({ |
2063 close: [dart.void, []], | 2052 close: [dart.void, []], |
2064 add: [dart.void, [core.List$(core.int)]], | 2053 add: [dart.void, [core.List$(core.int)]], |
2065 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool
]] | 2054 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool
]] |
2066 }) | 2055 }) |
2067 }); | 2056 }); |
2068 let UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533; | 2057 let UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533; |
2069 let UNICODE_BOM_CHARACTER_RUNE = 65279; | 2058 let UNICODE_BOM_CHARACTER_RUNE = 65279; |
2070 let _allowMalformed = Symbol('_allowMalformed'); | 2059 let _allowMalformed = Symbol('_allowMalformed'); |
2071 class Utf8Codec extends Encoding { | 2060 class Utf8Codec extends Encoding { |
2072 Utf8Codec(opts) { | 2061 Utf8Codec({allowMalformed = false} = {}) { |
2073 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; | |
2074 this[_allowMalformed] = allowMalformed; | 2062 this[_allowMalformed] = allowMalformed; |
2075 super.Encoding(); | 2063 super.Encoding(); |
2076 } | 2064 } |
2077 get name() { | 2065 get name() { |
2078 return "utf-8"; | 2066 return "utf-8"; |
2079 } | 2067 } |
2080 decode(codeUnits, opts) { | 2068 decode(codeUnits, {allowMalformed = null} = {}) { |
2081 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : null; | |
2082 if (allowMalformed == null) | 2069 if (allowMalformed == null) |
2083 allowMalformed = this[_allowMalformed]; | 2070 allowMalformed = this[_allowMalformed]; |
2084 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits
); | 2071 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits
); |
2085 } | 2072 } |
2086 get encoder() { | 2073 get encoder() { |
2087 return new Utf8Encoder(); | 2074 return new Utf8Encoder(); |
2088 } | 2075 } |
2089 get decoder() { | 2076 get decoder() { |
2090 return new Utf8Decoder({allowMalformed: this[_allowMalformed]}); | 2077 return new Utf8Decoder({allowMalformed: this[_allowMalformed]}); |
2091 } | 2078 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 } | 2314 } |
2328 } | 2315 } |
2329 dart.setSignature(_Utf8EncoderSink, { | 2316 dart.setSignature(_Utf8EncoderSink, { |
2330 constructors: () => ({_Utf8EncoderSink: [_Utf8EncoderSink, [ByteConversionSi
nk]]}), | 2317 constructors: () => ({_Utf8EncoderSink: [_Utf8EncoderSink, [ByteConversionSi
nk]]}), |
2331 methods: () => ({ | 2318 methods: () => ({ |
2332 close: [dart.void, []], | 2319 close: [dart.void, []], |
2333 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]] | 2320 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]] |
2334 }) | 2321 }) |
2335 }); | 2322 }); |
2336 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { | 2323 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { |
2337 Utf8Decoder(opts) { | 2324 Utf8Decoder({allowMalformed = false} = {}) { |
2338 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; | |
2339 this[_allowMalformed] = allowMalformed; | 2325 this[_allowMalformed] = allowMalformed; |
2340 super.Converter(); | 2326 super.Converter(); |
2341 } | 2327 } |
2342 convert(codeUnits, start, end) { | 2328 convert(codeUnits, start, end) { |
2343 if (start === void 0) | 2329 if (start === void 0) |
2344 start = 0; | 2330 start = 0; |
2345 if (end === void 0) | 2331 if (end === void 0) |
2346 end = null; | 2332 end = null; |
2347 let length = codeUnits[dartx.length]; | 2333 let length = codeUnits[dartx.length]; |
2348 core.RangeError.checkValidRange(start, end, length); | 2334 core.RangeError.checkValidRange(start, end, length); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 exports.LineSplitter = LineSplitter; | 2881 exports.LineSplitter = LineSplitter; |
2896 exports.StringConversionSink = StringConversionSink; | 2882 exports.StringConversionSink = StringConversionSink; |
2897 exports.ClosableStringSink = ClosableStringSink; | 2883 exports.ClosableStringSink = ClosableStringSink; |
2898 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN
E; | 2884 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN
E; |
2899 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; | 2885 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; |
2900 exports.Utf8Codec = Utf8Codec; | 2886 exports.Utf8Codec = Utf8Codec; |
2901 exports.UTF8 = UTF8; | 2887 exports.UTF8 = UTF8; |
2902 exports.Utf8Encoder = Utf8Encoder; | 2888 exports.Utf8Encoder = Utf8Encoder; |
2903 exports.Utf8Decoder = Utf8Decoder; | 2889 exports.Utf8Decoder = Utf8Decoder; |
2904 }); | 2890 }); |
OLD | NEW |