OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 %SetNativeFlag(boundMethod); | 274 %SetNativeFlag(boundMethod); |
275 this[internalName] = boundMethod; | 275 this[internalName] = boundMethod; |
276 } | 276 } |
277 return this[internalName]; | 277 return this[internalName]; |
278 } | 278 } |
279 | 279 |
280 %FunctionSetName(getter, methodName); | 280 %FunctionSetName(getter, methodName); |
281 %FunctionRemovePrototype(getter); | 281 %FunctionRemovePrototype(getter); |
282 %SetNativeFlag(getter); | 282 %SetNativeFlag(getter); |
283 | 283 |
284 $Object.defineProperty(obj.prototype, methodName, { | 284 ObjectDefineProperty(obj.prototype, methodName, { |
285 get: getter, | 285 get: getter, |
286 enumerable: false, | 286 enumerable: false, |
287 configurable: true | 287 configurable: true |
288 }); | 288 }); |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 /** | 292 /** |
293 * Returns an intersection of locales and service supported locales. | 293 * Returns an intersection of locales and service supported locales. |
294 * Parameter locales is treated as a priority list. | 294 * Parameter locales is treated as a priority list. |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 return extension === ''? '' : '-u' + extension; | 609 return extension === ''? '' : '-u' + extension; |
610 } | 610 } |
611 | 611 |
612 | 612 |
613 /** | 613 /** |
614 * Converts all OwnProperties into | 614 * Converts all OwnProperties into |
615 * configurable: false, writable: false, enumerable: true. | 615 * configurable: false, writable: false, enumerable: true. |
616 */ | 616 */ |
617 function freezeArray(array) { | 617 function freezeArray(array) { |
618 array.forEach(function(element, index) { | 618 array.forEach(function(element, index) { |
619 $Object.defineProperty(array, index, {value: element, | 619 ObjectDefineProperty(array, index, {value: element, |
620 configurable: false, | 620 configurable: false, |
621 writable: false, | 621 writable: false, |
622 enumerable: true}); | 622 enumerable: true}); |
623 }); | 623 }); |
624 | 624 |
625 $Object.defineProperty(array, 'length', {value: array.length, | 625 ObjectDefineProperty(array, 'length', {value: array.length, |
626 writable: false}); | 626 writable: false}); |
627 | |
628 return array; | 627 return array; |
629 } | 628 } |
630 | 629 |
631 | 630 |
632 /** | 631 /** |
633 * It's sometimes desireable to leave user requested locale instead of ICU | 632 * It's sometimes desireable to leave user requested locale instead of ICU |
634 * supported one (zh-TW is equivalent to zh-Hant-TW, so we should keep shorter | 633 * supported one (zh-TW is equivalent to zh-Hant-TW, so we should keep shorter |
635 * one, if that was what user requested). | 634 * one, if that was what user requested). |
636 * This function returns user specified tag if its maximized form matches ICU | 635 * This function returns user specified tag if its maximized form matches ICU |
637 * resolved locale. If not we return ICU result. | 636 * resolved locale. If not we return ICU result. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 677 |
679 return available; | 678 return available; |
680 } | 679 } |
681 | 680 |
682 | 681 |
683 /** | 682 /** |
684 * Defines a property and sets writable and enumerable to true. | 683 * Defines a property and sets writable and enumerable to true. |
685 * Configurable is false by default. | 684 * Configurable is false by default. |
686 */ | 685 */ |
687 function defineWEProperty(object, property, value) { | 686 function defineWEProperty(object, property, value) { |
688 $Object.defineProperty(object, property, | 687 ObjectDefineProperty(object, property, |
689 {value: value, writable: true, enumerable: true}); | 688 {value: value, writable: true, enumerable: true}); |
690 } | 689 } |
691 | 690 |
692 | 691 |
693 /** | 692 /** |
694 * Adds property to an object if the value is not undefined. | 693 * Adds property to an object if the value is not undefined. |
695 * Sets configurable descriptor to false. | 694 * Sets configurable descriptor to false. |
696 */ | 695 */ |
697 function addWEPropertyIfDefined(object, property, value) { | 696 function addWEPropertyIfDefined(object, property, value) { |
698 if (value !== undefined) { | 697 if (value !== undefined) { |
699 defineWEProperty(object, property, value); | 698 defineWEProperty(object, property, value); |
700 } | 699 } |
701 } | 700 } |
702 | 701 |
703 | 702 |
704 /** | 703 /** |
705 * Defines a property and sets writable, enumerable and configurable to true. | 704 * Defines a property and sets writable, enumerable and configurable to true. |
706 */ | 705 */ |
707 function defineWECProperty(object, property, value) { | 706 function defineWECProperty(object, property, value) { |
708 $Object.defineProperty(object, property, | 707 ObjectDefineProperty(object, property, |
709 {value: value, | 708 {value: value, |
710 writable: true, | 709 writable: true, |
711 enumerable: true, | 710 enumerable: true, |
712 configurable: true}); | 711 configurable: true}); |
713 } | 712 } |
714 | 713 |
715 | 714 |
716 /** | 715 /** |
717 * Adds property to an object if the value is not undefined. | 716 * Adds property to an object if the value is not undefined. |
718 * Sets all descriptors to true. | 717 * Sets all descriptors to true. |
719 */ | 718 */ |
720 function addWECPropertyIfDefined(object, property, value) { | 719 function addWECPropertyIfDefined(object, property, value) { |
721 if (value !== undefined) { | 720 if (value !== undefined) { |
722 defineWECProperty(object, property, value); | 721 defineWECProperty(object, property, value); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 } else if (internalOptions.usage === 'search') { | 940 } else if (internalOptions.usage === 'search') { |
942 extension = '-u-co-search'; | 941 extension = '-u-co-search'; |
943 } | 942 } |
944 defineWEProperty(internalOptions, 'collation', collation); | 943 defineWEProperty(internalOptions, 'collation', collation); |
945 | 944 |
946 var requestedLocale = locale.locale + extension; | 945 var requestedLocale = locale.locale + extension; |
947 | 946 |
948 // We define all properties C++ code may produce, to prevent security | 947 // We define all properties C++ code may produce, to prevent security |
949 // problems. If malicious user decides to redefine Object.prototype.locale | 948 // problems. If malicious user decides to redefine Object.prototype.locale |
950 // we can't just use plain x.locale = 'us' or in C++ Set("locale", "us"). | 949 // we can't just use plain x.locale = 'us' or in C++ Set("locale", "us"). |
951 // Object.defineProperties will either succeed defining or throw an error. | 950 // ObjectDefineProperties will either succeed defining or throw an error. |
952 var resolved = $Object.defineProperties({}, { | 951 var resolved = ObjectDefineProperties({}, { |
953 caseFirst: {writable: true}, | 952 caseFirst: {writable: true}, |
954 collation: {value: internalOptions.collation, writable: true}, | 953 collation: {value: internalOptions.collation, writable: true}, |
955 ignorePunctuation: {writable: true}, | 954 ignorePunctuation: {writable: true}, |
956 locale: {writable: true}, | 955 locale: {writable: true}, |
957 numeric: {writable: true}, | 956 numeric: {writable: true}, |
958 requestedLocale: {value: requestedLocale, writable: true}, | 957 requestedLocale: {value: requestedLocale, writable: true}, |
959 sensitivity: {writable: true}, | 958 sensitivity: {writable: true}, |
960 strength: {writable: true}, | 959 strength: {writable: true}, |
961 usage: {value: internalOptions.usage, writable: true} | 960 usage: {value: internalOptions.usage, writable: true} |
962 }); | 961 }); |
963 | 962 |
964 var internalCollator = %CreateCollator(requestedLocale, | 963 var internalCollator = %CreateCollator(requestedLocale, |
965 internalOptions, | 964 internalOptions, |
966 resolved); | 965 resolved); |
967 | 966 |
968 // Writable, configurable and enumerable are set to false by default. | 967 // Writable, configurable and enumerable are set to false by default. |
969 %MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator); | 968 %MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator); |
970 $Object.defineProperty(collator, 'resolved', {value: resolved}); | 969 ObjectDefineProperty(collator, 'resolved', {value: resolved}); |
971 | 970 |
972 return collator; | 971 return collator; |
973 } | 972 } |
974 | 973 |
975 | 974 |
976 /** | 975 /** |
977 * Constructs Intl.Collator object given optional locales and options | 976 * Constructs Intl.Collator object given optional locales and options |
978 * parameters. | 977 * parameters. |
979 * | 978 * |
980 * @constructor | 979 * @constructor |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 defineWEProperty(internalOptions, 'useGrouping', getOption( | 1156 defineWEProperty(internalOptions, 'useGrouping', getOption( |
1158 'useGrouping', 'boolean', undefined, true)); | 1157 'useGrouping', 'boolean', undefined, true)); |
1159 | 1158 |
1160 // ICU prefers options to be passed using -u- extension key/values for | 1159 // ICU prefers options to be passed using -u- extension key/values for |
1161 // number format, so we need to build that. | 1160 // number format, so we need to build that. |
1162 var extensionMap = parseExtension(locale.extension); | 1161 var extensionMap = parseExtension(locale.extension); |
1163 var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP, | 1162 var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP, |
1164 getOption, internalOptions); | 1163 getOption, internalOptions); |
1165 | 1164 |
1166 var requestedLocale = locale.locale + extension; | 1165 var requestedLocale = locale.locale + extension; |
1167 var resolved = $Object.defineProperties({}, { | 1166 var resolved = ObjectDefineProperties({}, { |
1168 currency: {writable: true}, | 1167 currency: {writable: true}, |
1169 currencyDisplay: {writable: true}, | 1168 currencyDisplay: {writable: true}, |
1170 locale: {writable: true}, | 1169 locale: {writable: true}, |
1171 maximumFractionDigits: {writable: true}, | 1170 maximumFractionDigits: {writable: true}, |
1172 minimumFractionDigits: {writable: true}, | 1171 minimumFractionDigits: {writable: true}, |
1173 minimumIntegerDigits: {writable: true}, | 1172 minimumIntegerDigits: {writable: true}, |
1174 numberingSystem: {writable: true}, | 1173 numberingSystem: {writable: true}, |
1175 requestedLocale: {value: requestedLocale, writable: true}, | 1174 requestedLocale: {value: requestedLocale, writable: true}, |
1176 style: {value: internalOptions.style, writable: true}, | 1175 style: {value: internalOptions.style, writable: true}, |
1177 useGrouping: {writable: true} | 1176 useGrouping: {writable: true} |
1178 }); | 1177 }); |
1179 if (internalOptions.hasOwnProperty('minimumSignificantDigits')) { | 1178 if (internalOptions.hasOwnProperty('minimumSignificantDigits')) { |
1180 defineWEProperty(resolved, 'minimumSignificantDigits', undefined); | 1179 defineWEProperty(resolved, 'minimumSignificantDigits', undefined); |
1181 } | 1180 } |
1182 if (internalOptions.hasOwnProperty('maximumSignificantDigits')) { | 1181 if (internalOptions.hasOwnProperty('maximumSignificantDigits')) { |
1183 defineWEProperty(resolved, 'maximumSignificantDigits', undefined); | 1182 defineWEProperty(resolved, 'maximumSignificantDigits', undefined); |
1184 } | 1183 } |
1185 var formatter = %CreateNumberFormat(requestedLocale, | 1184 var formatter = %CreateNumberFormat(requestedLocale, |
1186 internalOptions, | 1185 internalOptions, |
1187 resolved); | 1186 resolved); |
1188 | 1187 |
1189 // We can't get information about number or currency style from ICU, so we | 1188 // We can't get information about number or currency style from ICU, so we |
1190 // assume user request was fulfilled. | 1189 // assume user request was fulfilled. |
1191 if (internalOptions.style === 'currency') { | 1190 if (internalOptions.style === 'currency') { |
1192 $Object.defineProperty(resolved, 'currencyDisplay', {value: currencyDisplay, | 1191 ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay, |
1193 writable: true}); | 1192 writable: true}); |
1194 } | 1193 } |
1195 | 1194 |
1196 %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter); | 1195 %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter); |
1197 $Object.defineProperty(numberFormat, 'resolved', {value: resolved}); | 1196 ObjectDefineProperty(numberFormat, 'resolved', {value: resolved}); |
1198 | 1197 |
1199 return numberFormat; | 1198 return numberFormat; |
1200 } | 1199 } |
1201 | 1200 |
1202 | 1201 |
1203 /** | 1202 /** |
1204 * Constructs Intl.NumberFormat object given optional locales and options | 1203 * Constructs Intl.NumberFormat object given optional locales and options |
1205 * parameters. | 1204 * parameters. |
1206 * | 1205 * |
1207 * @constructor | 1206 * @constructor |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 | 1458 |
1460 return options; | 1459 return options; |
1461 } | 1460 } |
1462 | 1461 |
1463 | 1462 |
1464 /** | 1463 /** |
1465 * Returns options with at least default values in it. | 1464 * Returns options with at least default values in it. |
1466 */ | 1465 */ |
1467 function toDateTimeOptions(options, required, defaults) { | 1466 function toDateTimeOptions(options, required, defaults) { |
1468 if (options === undefined) { | 1467 if (options === undefined) { |
1469 options = null; | 1468 options = {}; |
1470 } else { | 1469 } else { |
1471 options = toObject(options); | 1470 options = TO_OBJECT_INLINE(options); |
1472 } | 1471 } |
1473 | 1472 |
1474 options = $Object.apply(this, [options]); | |
1475 | |
1476 var needsDefault = true; | 1473 var needsDefault = true; |
1477 if ((required === 'date' || required === 'any') && | 1474 if ((required === 'date' || required === 'any') && |
1478 (options.weekday !== undefined || options.year !== undefined || | 1475 (options.weekday !== undefined || options.year !== undefined || |
1479 options.month !== undefined || options.day !== undefined)) { | 1476 options.month !== undefined || options.day !== undefined)) { |
1480 needsDefault = false; | 1477 needsDefault = false; |
1481 } | 1478 } |
1482 | 1479 |
1483 if ((required === 'time' || required === 'any') && | 1480 if ((required === 'time' || required === 'any') && |
1484 (options.hour !== undefined || options.minute !== undefined || | 1481 (options.hour !== undefined || options.minute !== undefined || |
1485 options.second !== undefined)) { | 1482 options.second !== undefined)) { |
1486 needsDefault = false; | 1483 needsDefault = false; |
1487 } | 1484 } |
1488 | 1485 |
1489 if (needsDefault && (defaults === 'date' || defaults === 'all')) { | 1486 if (needsDefault && (defaults === 'date' || defaults === 'all')) { |
1490 $Object.defineProperty(options, 'year', {value: 'numeric', | 1487 ObjectDefineProperty(options, 'year', {value: 'numeric', |
| 1488 writable: true, |
| 1489 enumerable: true, |
| 1490 configurable: true}); |
| 1491 ObjectDefineProperty(options, 'month', {value: 'numeric', |
| 1492 writable: true, |
| 1493 enumerable: true, |
| 1494 configurable: true}); |
| 1495 ObjectDefineProperty(options, 'day', {value: 'numeric', |
| 1496 writable: true, |
| 1497 enumerable: true, |
| 1498 configurable: true}); |
| 1499 } |
| 1500 |
| 1501 if (needsDefault && (defaults === 'time' || defaults === 'all')) { |
| 1502 ObjectDefineProperty(options, 'hour', {value: 'numeric', |
1491 writable: true, | 1503 writable: true, |
1492 enumerable: true, | 1504 enumerable: true, |
1493 configurable: true}); | 1505 configurable: true}); |
1494 $Object.defineProperty(options, 'month', {value: 'numeric', | 1506 ObjectDefineProperty(options, 'minute', {value: 'numeric', |
1495 writable: true, | |
1496 enumerable: true, | |
1497 configurable: true}); | |
1498 $Object.defineProperty(options, 'day', {value: 'numeric', | |
1499 writable: true, | |
1500 enumerable: true, | |
1501 configurable: true}); | |
1502 } | |
1503 | |
1504 if (needsDefault && (defaults === 'time' || defaults === 'all')) { | |
1505 $Object.defineProperty(options, 'hour', {value: 'numeric', | |
1506 writable: true, | |
1507 enumerable: true, | |
1508 configurable: true}); | |
1509 $Object.defineProperty(options, 'minute', {value: 'numeric', | |
1510 writable: true, | 1507 writable: true, |
1511 enumerable: true, | 1508 enumerable: true, |
1512 configurable: true}); | 1509 configurable: true}); |
1513 $Object.defineProperty(options, 'second', {value: 'numeric', | 1510 ObjectDefineProperty(options, 'second', {value: 'numeric', |
1514 writable: true, | 1511 writable: true, |
1515 enumerable: true, | 1512 enumerable: true, |
1516 configurable: true}); | 1513 configurable: true}); |
1517 } | 1514 } |
1518 | 1515 |
1519 return options; | 1516 return options; |
1520 } | 1517 } |
1521 | 1518 |
1522 | 1519 |
1523 /** | 1520 /** |
(...skipping 30 matching lines...) Expand all Loading... |
1554 var tz = canonicalizeTimeZoneID(options.timeZone); | 1551 var tz = canonicalizeTimeZoneID(options.timeZone); |
1555 | 1552 |
1556 // ICU prefers options to be passed using -u- extension key/values, so | 1553 // ICU prefers options to be passed using -u- extension key/values, so |
1557 // we need to build that. | 1554 // we need to build that. |
1558 var internalOptions = {}; | 1555 var internalOptions = {}; |
1559 var extensionMap = parseExtension(locale.extension); | 1556 var extensionMap = parseExtension(locale.extension); |
1560 var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP, | 1557 var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP, |
1561 getOption, internalOptions); | 1558 getOption, internalOptions); |
1562 | 1559 |
1563 var requestedLocale = locale.locale + extension; | 1560 var requestedLocale = locale.locale + extension; |
1564 var resolved = $Object.defineProperties({}, { | 1561 var resolved = ObjectDefineProperties({}, { |
1565 calendar: {writable: true}, | 1562 calendar: {writable: true}, |
1566 day: {writable: true}, | 1563 day: {writable: true}, |
1567 era: {writable: true}, | 1564 era: {writable: true}, |
1568 hour12: {writable: true}, | 1565 hour12: {writable: true}, |
1569 hour: {writable: true}, | 1566 hour: {writable: true}, |
1570 locale: {writable: true}, | 1567 locale: {writable: true}, |
1571 minute: {writable: true}, | 1568 minute: {writable: true}, |
1572 month: {writable: true}, | 1569 month: {writable: true}, |
1573 numberingSystem: {writable: true}, | 1570 numberingSystem: {writable: true}, |
1574 pattern: {writable: true}, | 1571 pattern: {writable: true}, |
1575 requestedLocale: {value: requestedLocale, writable: true}, | 1572 requestedLocale: {value: requestedLocale, writable: true}, |
1576 second: {writable: true}, | 1573 second: {writable: true}, |
1577 timeZone: {writable: true}, | 1574 timeZone: {writable: true}, |
1578 timeZoneName: {writable: true}, | 1575 timeZoneName: {writable: true}, |
1579 tz: {value: tz, writable: true}, | 1576 tz: {value: tz, writable: true}, |
1580 weekday: {writable: true}, | 1577 weekday: {writable: true}, |
1581 year: {writable: true} | 1578 year: {writable: true} |
1582 }); | 1579 }); |
1583 | 1580 |
1584 var formatter = %CreateDateTimeFormat( | 1581 var formatter = %CreateDateTimeFormat( |
1585 requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved); | 1582 requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved); |
1586 | 1583 |
1587 if (tz !== undefined && tz !== resolved.timeZone) { | 1584 if (tz !== undefined && tz !== resolved.timeZone) { |
1588 throw new $RangeError('Unsupported time zone specified ' + tz); | 1585 throw new $RangeError('Unsupported time zone specified ' + tz); |
1589 } | 1586 } |
1590 | 1587 |
1591 %MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter); | 1588 %MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter); |
1592 $Object.defineProperty(dateFormat, 'resolved', {value: resolved}); | 1589 ObjectDefineProperty(dateFormat, 'resolved', {value: resolved}); |
1593 | 1590 |
1594 return dateFormat; | 1591 return dateFormat; |
1595 } | 1592 } |
1596 | 1593 |
1597 | 1594 |
1598 /** | 1595 /** |
1599 * Constructs Intl.DateTimeFormat object given optional locales and options | 1596 * Constructs Intl.DateTimeFormat object given optional locales and options |
1600 * parameters. | 1597 * parameters. |
1601 * | 1598 * |
1602 * @constructor | 1599 * @constructor |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 } | 1773 } |
1777 | 1774 |
1778 var getOption = getGetOption(options, 'breakiterator'); | 1775 var getOption = getGetOption(options, 'breakiterator'); |
1779 | 1776 |
1780 var internalOptions = {}; | 1777 var internalOptions = {}; |
1781 | 1778 |
1782 defineWEProperty(internalOptions, 'type', getOption( | 1779 defineWEProperty(internalOptions, 'type', getOption( |
1783 'type', 'string', ['character', 'word', 'sentence', 'line'], 'word')); | 1780 'type', 'string', ['character', 'word', 'sentence', 'line'], 'word')); |
1784 | 1781 |
1785 var locale = resolveLocale('breakiterator', locales, options); | 1782 var locale = resolveLocale('breakiterator', locales, options); |
1786 var resolved = $Object.defineProperties({}, { | 1783 var resolved = ObjectDefineProperties({}, { |
1787 requestedLocale: {value: locale.locale, writable: true}, | 1784 requestedLocale: {value: locale.locale, writable: true}, |
1788 type: {value: internalOptions.type, writable: true}, | 1785 type: {value: internalOptions.type, writable: true}, |
1789 locale: {writable: true} | 1786 locale: {writable: true} |
1790 }); | 1787 }); |
1791 | 1788 |
1792 var internalIterator = %CreateBreakIterator(locale.locale, | 1789 var internalIterator = %CreateBreakIterator(locale.locale, |
1793 internalOptions, | 1790 internalOptions, |
1794 resolved); | 1791 resolved); |
1795 | 1792 |
1796 %MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator', | 1793 %MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator', |
1797 internalIterator); | 1794 internalIterator); |
1798 $Object.defineProperty(iterator, 'resolved', {value: resolved}); | 1795 ObjectDefineProperty(iterator, 'resolved', {value: resolved}); |
1799 | 1796 |
1800 return iterator; | 1797 return iterator; |
1801 } | 1798 } |
1802 | 1799 |
1803 | 1800 |
1804 /** | 1801 /** |
1805 * Constructs Intl.v8BreakIterator object given optional locales and options | 1802 * Constructs Intl.v8BreakIterator object given optional locales and options |
1806 * parameters. | 1803 * parameters. |
1807 * | 1804 * |
1808 * @constructor | 1805 * @constructor |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 return defaultObjects[service]; | 1951 return defaultObjects[service]; |
1955 } | 1952 } |
1956 return new savedObjects[service](locales, useOptions); | 1953 return new savedObjects[service](locales, useOptions); |
1957 } | 1954 } |
1958 | 1955 |
1959 | 1956 |
1960 /** | 1957 /** |
1961 * Compares this and that, and returns less than 0, 0 or greater than 0 value. | 1958 * Compares this and that, and returns less than 0, 0 or greater than 0 value. |
1962 * Overrides the built-in method. | 1959 * Overrides the built-in method. |
1963 */ | 1960 */ |
1964 $Object.defineProperty($String.prototype, 'localeCompare', { | 1961 ObjectDefineProperty($String.prototype, 'localeCompare', { |
1965 value: function(that) { | 1962 value: function(that) { |
1966 if (%_IsConstructCall()) { | 1963 if (%_IsConstructCall()) { |
1967 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 1964 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
1968 } | 1965 } |
1969 | 1966 |
1970 if (IS_NULL_OR_UNDEFINED(this)) { | 1967 if (IS_NULL_OR_UNDEFINED(this)) { |
1971 throw new $TypeError('Method invoked on undefined or null value.'); | 1968 throw new $TypeError('Method invoked on undefined or null value.'); |
1972 } | 1969 } |
1973 | 1970 |
1974 var locales = %_Arguments(1); | 1971 var locales = %_Arguments(1); |
(...skipping 10 matching lines...) Expand all Loading... |
1985 %SetNativeFlag($String.prototype.localeCompare); | 1982 %SetNativeFlag($String.prototype.localeCompare); |
1986 | 1983 |
1987 | 1984 |
1988 /** | 1985 /** |
1989 * Unicode normalization. This method is called with one argument that | 1986 * Unicode normalization. This method is called with one argument that |
1990 * specifies the normalization form. | 1987 * specifies the normalization form. |
1991 * If none is specified, "NFC" is assumed. | 1988 * If none is specified, "NFC" is assumed. |
1992 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 1989 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
1993 * a RangeError Exception. | 1990 * a RangeError Exception. |
1994 */ | 1991 */ |
1995 $Object.defineProperty($String.prototype, 'normalize', { | 1992 ObjectDefineProperty($String.prototype, 'normalize', { |
1996 value: function(that) { | 1993 value: function(that) { |
1997 if (%_IsConstructCall()) { | 1994 if (%_IsConstructCall()) { |
1998 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 1995 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
1999 } | 1996 } |
2000 | 1997 |
2001 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 1998 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
2002 | 1999 |
2003 var form = $String(%_Arguments(0) || 'NFC'); | 2000 var form = $String(%_Arguments(0) || 'NFC'); |
2004 | 2001 |
2005 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); | 2002 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); |
(...skipping 10 matching lines...) Expand all Loading... |
2016 }); | 2013 }); |
2017 %FunctionSetName($String.prototype.normalize, 'normalize'); | 2014 %FunctionSetName($String.prototype.normalize, 'normalize'); |
2018 %FunctionRemovePrototype($String.prototype.normalize); | 2015 %FunctionRemovePrototype($String.prototype.normalize); |
2019 %SetNativeFlag($String.prototype.normalize); | 2016 %SetNativeFlag($String.prototype.normalize); |
2020 | 2017 |
2021 | 2018 |
2022 /** | 2019 /** |
2023 * Formats a Number object (this) using locale and options values. | 2020 * Formats a Number object (this) using locale and options values. |
2024 * If locale or options are omitted, defaults are used. | 2021 * If locale or options are omitted, defaults are used. |
2025 */ | 2022 */ |
2026 $Object.defineProperty($Number.prototype, 'toLocaleString', { | 2023 ObjectDefineProperty($Number.prototype, 'toLocaleString', { |
2027 value: function() { | 2024 value: function() { |
2028 if (%_IsConstructCall()) { | 2025 if (%_IsConstructCall()) { |
2029 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 2026 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
2030 } | 2027 } |
2031 | 2028 |
2032 if (!(this instanceof $Number) && typeof(this) !== 'number') { | 2029 if (!(this instanceof $Number) && typeof(this) !== 'number') { |
2033 throw new $TypeError('Method invoked on an object that is not Number.'); | 2030 throw new $TypeError('Method invoked on an object that is not Number.'); |
2034 } | 2031 } |
2035 | 2032 |
2036 var locales = %_Arguments(0); | 2033 var locales = %_Arguments(0); |
(...skipping 29 matching lines...) Expand all Loading... |
2066 | 2063 |
2067 return formatDate(dateFormat, date); | 2064 return formatDate(dateFormat, date); |
2068 } | 2065 } |
2069 | 2066 |
2070 | 2067 |
2071 /** | 2068 /** |
2072 * Formats a Date object (this) using locale and options values. | 2069 * Formats a Date object (this) using locale and options values. |
2073 * If locale or options are omitted, defaults are used - both date and time are | 2070 * If locale or options are omitted, defaults are used - both date and time are |
2074 * present in the output. | 2071 * present in the output. |
2075 */ | 2072 */ |
2076 $Object.defineProperty($Date.prototype, 'toLocaleString', { | 2073 ObjectDefineProperty($Date.prototype, 'toLocaleString', { |
2077 value: function() { | 2074 value: function() { |
2078 if (%_IsConstructCall()) { | 2075 if (%_IsConstructCall()) { |
2079 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 2076 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
2080 } | 2077 } |
2081 | 2078 |
2082 var locales = %_Arguments(0); | 2079 var locales = %_Arguments(0); |
2083 var options = %_Arguments(1); | 2080 var options = %_Arguments(1); |
2084 return toLocaleDateTime( | 2081 return toLocaleDateTime( |
2085 this, locales, options, 'any', 'all', 'dateformatall'); | 2082 this, locales, options, 'any', 'all', 'dateformatall'); |
2086 }, | 2083 }, |
2087 writable: true, | 2084 writable: true, |
2088 configurable: true, | 2085 configurable: true, |
2089 enumerable: false | 2086 enumerable: false |
2090 }); | 2087 }); |
2091 %FunctionSetName($Date.prototype.toLocaleString, 'toLocaleString'); | 2088 %FunctionSetName($Date.prototype.toLocaleString, 'toLocaleString'); |
2092 %FunctionRemovePrototype($Date.prototype.toLocaleString); | 2089 %FunctionRemovePrototype($Date.prototype.toLocaleString); |
2093 %SetNativeFlag($Date.prototype.toLocaleString); | 2090 %SetNativeFlag($Date.prototype.toLocaleString); |
2094 | 2091 |
2095 | 2092 |
2096 /** | 2093 /** |
2097 * Formats a Date object (this) using locale and options values. | 2094 * Formats a Date object (this) using locale and options values. |
2098 * If locale or options are omitted, defaults are used - only date is present | 2095 * If locale or options are omitted, defaults are used - only date is present |
2099 * in the output. | 2096 * in the output. |
2100 */ | 2097 */ |
2101 $Object.defineProperty($Date.prototype, 'toLocaleDateString', { | 2098 ObjectDefineProperty($Date.prototype, 'toLocaleDateString', { |
2102 value: function() { | 2099 value: function() { |
2103 if (%_IsConstructCall()) { | 2100 if (%_IsConstructCall()) { |
2104 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 2101 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
2105 } | 2102 } |
2106 | 2103 |
2107 var locales = %_Arguments(0); | 2104 var locales = %_Arguments(0); |
2108 var options = %_Arguments(1); | 2105 var options = %_Arguments(1); |
2109 return toLocaleDateTime( | 2106 return toLocaleDateTime( |
2110 this, locales, options, 'date', 'date', 'dateformatdate'); | 2107 this, locales, options, 'date', 'date', 'dateformatdate'); |
2111 }, | 2108 }, |
2112 writable: true, | 2109 writable: true, |
2113 configurable: true, | 2110 configurable: true, |
2114 enumerable: false | 2111 enumerable: false |
2115 }); | 2112 }); |
2116 %FunctionSetName($Date.prototype.toLocaleDateString, 'toLocaleDateString'); | 2113 %FunctionSetName($Date.prototype.toLocaleDateString, 'toLocaleDateString'); |
2117 %FunctionRemovePrototype($Date.prototype.toLocaleDateString); | 2114 %FunctionRemovePrototype($Date.prototype.toLocaleDateString); |
2118 %SetNativeFlag($Date.prototype.toLocaleDateString); | 2115 %SetNativeFlag($Date.prototype.toLocaleDateString); |
2119 | 2116 |
2120 | 2117 |
2121 /** | 2118 /** |
2122 * Formats a Date object (this) using locale and options values. | 2119 * Formats a Date object (this) using locale and options values. |
2123 * If locale or options are omitted, defaults are used - only time is present | 2120 * If locale or options are omitted, defaults are used - only time is present |
2124 * in the output. | 2121 * in the output. |
2125 */ | 2122 */ |
2126 $Object.defineProperty($Date.prototype, 'toLocaleTimeString', { | 2123 ObjectDefineProperty($Date.prototype, 'toLocaleTimeString', { |
2127 value: function() { | 2124 value: function() { |
2128 if (%_IsConstructCall()) { | 2125 if (%_IsConstructCall()) { |
2129 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 2126 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
2130 } | 2127 } |
2131 | 2128 |
2132 var locales = %_Arguments(0); | 2129 var locales = %_Arguments(0); |
2133 var options = %_Arguments(1); | 2130 var options = %_Arguments(1); |
2134 return toLocaleDateTime( | 2131 return toLocaleDateTime( |
2135 this, locales, options, 'time', 'time', 'dateformattime'); | 2132 this, locales, options, 'time', 'time', 'dateformattime'); |
2136 }, | 2133 }, |
2137 writable: true, | 2134 writable: true, |
2138 configurable: true, | 2135 configurable: true, |
2139 enumerable: false | 2136 enumerable: false |
2140 }); | 2137 }); |
2141 %FunctionSetName($Date.prototype.toLocaleTimeString, 'toLocaleTimeString'); | 2138 %FunctionSetName($Date.prototype.toLocaleTimeString, 'toLocaleTimeString'); |
2142 %FunctionRemovePrototype($Date.prototype.toLocaleTimeString); | 2139 %FunctionRemovePrototype($Date.prototype.toLocaleTimeString); |
2143 %SetNativeFlag($Date.prototype.toLocaleTimeString); | 2140 %SetNativeFlag($Date.prototype.toLocaleTimeString); |
2144 | 2141 |
2145 return Intl; | 2142 return Intl; |
2146 }())}); | 2143 }())}); |
OLD | NEW |