| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ECMAScript 402 API implementation. | 5 // ECMAScript 402 API implementation. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Intl object is a single object that has some named properties, | 8 * Intl object is a single object that has some named properties, |
| 9 * all of which are constructors. | 9 * all of which are constructors. |
| 10 */ | 10 */ |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // DateTimeFormat.format needs to be 0 arg method, but can stil | 247 // DateTimeFormat.format needs to be 0 arg method, but can stil |
| 248 // receive optional dateValue param. If one was provided, pass it | 248 // receive optional dateValue param. If one was provided, pass it |
| 249 // along. | 249 // along. |
| 250 if (%_ArgumentsLength() > 0) { | 250 if (%_ArgumentsLength() > 0) { |
| 251 return implementation(that, %_Arguments(0)); | 251 return implementation(that, %_Arguments(0)); |
| 252 } else { | 252 } else { |
| 253 return implementation(that); | 253 return implementation(that); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 %FunctionSetName(boundMethod, internalName); | 257 SetFunctionName(boundMethod, internalName); |
| 258 %FunctionRemovePrototype(boundMethod); | 258 %FunctionRemovePrototype(boundMethod); |
| 259 %SetNativeFlag(boundMethod); | 259 %SetNativeFlag(boundMethod); |
| 260 this[internalName] = boundMethod; | 260 this[internalName] = boundMethod; |
| 261 } | 261 } |
| 262 return this[internalName]; | 262 return this[internalName]; |
| 263 } | 263 } |
| 264 | 264 |
| 265 %FunctionSetName(getter, methodName); | 265 SetFunctionName(getter, methodName); |
| 266 %FunctionRemovePrototype(getter); | 266 %FunctionRemovePrototype(getter); |
| 267 %SetNativeFlag(getter); | 267 %SetNativeFlag(getter); |
| 268 | 268 |
| 269 ObjectDefineProperty(obj.prototype, methodName, { | 269 ObjectDefineProperty(obj.prototype, methodName, { |
| 270 get: getter, | 270 get: getter, |
| 271 enumerable: false, | 271 enumerable: false, |
| 272 configurable: true | 272 configurable: true |
| 273 }); | 273 }); |
| 274 } | 274 } |
| 275 | 275 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 usage: coll.resolved.usage, | 983 usage: coll.resolved.usage, |
| 984 sensitivity: coll.resolved.sensitivity, | 984 sensitivity: coll.resolved.sensitivity, |
| 985 ignorePunctuation: coll.resolved.ignorePunctuation, | 985 ignorePunctuation: coll.resolved.ignorePunctuation, |
| 986 numeric: coll.resolved.numeric, | 986 numeric: coll.resolved.numeric, |
| 987 caseFirst: coll.resolved.caseFirst, | 987 caseFirst: coll.resolved.caseFirst, |
| 988 collation: coll.resolved.collation | 988 collation: coll.resolved.collation |
| 989 }; | 989 }; |
| 990 }, | 990 }, |
| 991 DONT_ENUM | 991 DONT_ENUM |
| 992 ); | 992 ); |
| 993 %FunctionSetName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions'); | 993 SetFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions'); |
| 994 %FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions); | 994 %FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions); |
| 995 %SetNativeFlag(Intl.Collator.prototype.resolvedOptions); | 995 %SetNativeFlag(Intl.Collator.prototype.resolvedOptions); |
| 996 | 996 |
| 997 | 997 |
| 998 /** | 998 /** |
| 999 * Returns the subset of the given locale list for which this locale list | 999 * Returns the subset of the given locale list for which this locale list |
| 1000 * has a matching (possibly fallback) locale. Locales appear in the same | 1000 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1001 * order in the returned list as in the input list. | 1001 * order in the returned list as in the input list. |
| 1002 * Options are optional parameter. | 1002 * Options are optional parameter. |
| 1003 */ | 1003 */ |
| 1004 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { | 1004 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { |
| 1005 if (%_IsConstructCall()) { | 1005 if (%_IsConstructCall()) { |
| 1006 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1006 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 return supportedLocalesOf('collator', locales, %_Arguments(1)); | 1009 return supportedLocalesOf('collator', locales, %_Arguments(1)); |
| 1010 }, | 1010 }, |
| 1011 DONT_ENUM | 1011 DONT_ENUM |
| 1012 ); | 1012 ); |
| 1013 %FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); | 1013 SetFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1014 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); | 1014 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); |
| 1015 %SetNativeFlag(Intl.Collator.supportedLocalesOf); | 1015 %SetNativeFlag(Intl.Collator.supportedLocalesOf); |
| 1016 | 1016 |
| 1017 | 1017 |
| 1018 /** | 1018 /** |
| 1019 * When the compare method is called with two arguments x and y, it returns a | 1019 * When the compare method is called with two arguments x and y, it returns a |
| 1020 * Number other than NaN that represents the result of a locale-sensitive | 1020 * Number other than NaN that represents the result of a locale-sensitive |
| 1021 * String comparison of x with y. | 1021 * String comparison of x with y. |
| 1022 * The result is intended to order String values in the sort order specified | 1022 * The result is intended to order String values in the sort order specified |
| 1023 * by the effective locale and collation options computed during construction | 1023 * by the effective locale and collation options computed during construction |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 | 1227 |
| 1228 if (format.resolved.hasOwnProperty('maximumSignificantDigits')) { | 1228 if (format.resolved.hasOwnProperty('maximumSignificantDigits')) { |
| 1229 defineWECProperty(result, 'maximumSignificantDigits', | 1229 defineWECProperty(result, 'maximumSignificantDigits', |
| 1230 format.resolved.maximumSignificantDigits); | 1230 format.resolved.maximumSignificantDigits); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 return result; | 1233 return result; |
| 1234 }, | 1234 }, |
| 1235 DONT_ENUM | 1235 DONT_ENUM |
| 1236 ); | 1236 ); |
| 1237 %FunctionSetName(Intl.NumberFormat.prototype.resolvedOptions, | 1237 SetFunctionName(Intl.NumberFormat.prototype.resolvedOptions, |
| 1238 'resolvedOptions'); | 1238 'resolvedOptions'); |
| 1239 %FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions); | 1239 %FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions); |
| 1240 %SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); | 1240 %SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); |
| 1241 | 1241 |
| 1242 | 1242 |
| 1243 /** | 1243 /** |
| 1244 * Returns the subset of the given locale list for which this locale list | 1244 * Returns the subset of the given locale list for which this locale list |
| 1245 * has a matching (possibly fallback) locale. Locales appear in the same | 1245 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1246 * order in the returned list as in the input list. | 1246 * order in the returned list as in the input list. |
| 1247 * Options are optional parameter. | 1247 * Options are optional parameter. |
| 1248 */ | 1248 */ |
| 1249 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { | 1249 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { |
| 1250 if (%_IsConstructCall()) { | 1250 if (%_IsConstructCall()) { |
| 1251 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1251 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 return supportedLocalesOf('numberformat', locales, %_Arguments(1)); | 1254 return supportedLocalesOf('numberformat', locales, %_Arguments(1)); |
| 1255 }, | 1255 }, |
| 1256 DONT_ENUM | 1256 DONT_ENUM |
| 1257 ); | 1257 ); |
| 1258 %FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1258 SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1259 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); | 1259 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); |
| 1260 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); | 1260 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); |
| 1261 | 1261 |
| 1262 | 1262 |
| 1263 /** | 1263 /** |
| 1264 * Returns a String value representing the result of calling ToNumber(value) | 1264 * Returns a String value representing the result of calling ToNumber(value) |
| 1265 * according to the effective locale and the formatting options of this | 1265 * according to the effective locale and the formatting options of this |
| 1266 * NumberFormat. | 1266 * NumberFormat. |
| 1267 */ | 1267 */ |
| 1268 function formatNumber(formatter, value) { | 1268 function formatNumber(formatter, value) { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 addWECPropertyIfDefined(result, 'weekday', fromPattern.weekday); | 1619 addWECPropertyIfDefined(result, 'weekday', fromPattern.weekday); |
| 1620 addWECPropertyIfDefined(result, 'hour12', fromPattern.hour12); | 1620 addWECPropertyIfDefined(result, 'hour12', fromPattern.hour12); |
| 1621 addWECPropertyIfDefined(result, 'hour', fromPattern.hour); | 1621 addWECPropertyIfDefined(result, 'hour', fromPattern.hour); |
| 1622 addWECPropertyIfDefined(result, 'minute', fromPattern.minute); | 1622 addWECPropertyIfDefined(result, 'minute', fromPattern.minute); |
| 1623 addWECPropertyIfDefined(result, 'second', fromPattern.second); | 1623 addWECPropertyIfDefined(result, 'second', fromPattern.second); |
| 1624 | 1624 |
| 1625 return result; | 1625 return result; |
| 1626 }, | 1626 }, |
| 1627 DONT_ENUM | 1627 DONT_ENUM |
| 1628 ); | 1628 ); |
| 1629 %FunctionSetName(Intl.DateTimeFormat.prototype.resolvedOptions, | 1629 SetFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions, |
| 1630 'resolvedOptions'); | 1630 'resolvedOptions'); |
| 1631 %FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions); | 1631 %FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions); |
| 1632 %SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); | 1632 %SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); |
| 1633 | 1633 |
| 1634 | 1634 |
| 1635 /** | 1635 /** |
| 1636 * Returns the subset of the given locale list for which this locale list | 1636 * Returns the subset of the given locale list for which this locale list |
| 1637 * has a matching (possibly fallback) locale. Locales appear in the same | 1637 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1638 * order in the returned list as in the input list. | 1638 * order in the returned list as in the input list. |
| 1639 * Options are optional parameter. | 1639 * Options are optional parameter. |
| 1640 */ | 1640 */ |
| 1641 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { | 1641 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { |
| 1642 if (%_IsConstructCall()) { | 1642 if (%_IsConstructCall()) { |
| 1643 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1643 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1644 } | 1644 } |
| 1645 | 1645 |
| 1646 return supportedLocalesOf('dateformat', locales, %_Arguments(1)); | 1646 return supportedLocalesOf('dateformat', locales, %_Arguments(1)); |
| 1647 }, | 1647 }, |
| 1648 DONT_ENUM | 1648 DONT_ENUM |
| 1649 ); | 1649 ); |
| 1650 %FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1650 SetFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1651 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); | 1651 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); |
| 1652 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); | 1652 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); |
| 1653 | 1653 |
| 1654 | 1654 |
| 1655 /** | 1655 /** |
| 1656 * Returns a String value representing the result of calling ToNumber(date) | 1656 * Returns a String value representing the result of calling ToNumber(date) |
| 1657 * according to the effective locale and the formatting options of this | 1657 * according to the effective locale and the formatting options of this |
| 1658 * DateTimeFormat. | 1658 * DateTimeFormat. |
| 1659 */ | 1659 */ |
| 1660 function formatDate(formatter, dateValue) { | 1660 function formatDate(formatter, dateValue) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale, | 1798 var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale, |
| 1799 segmenter.resolved.locale); | 1799 segmenter.resolved.locale); |
| 1800 | 1800 |
| 1801 return { | 1801 return { |
| 1802 locale: locale, | 1802 locale: locale, |
| 1803 type: segmenter.resolved.type | 1803 type: segmenter.resolved.type |
| 1804 }; | 1804 }; |
| 1805 }, | 1805 }, |
| 1806 DONT_ENUM | 1806 DONT_ENUM |
| 1807 ); | 1807 ); |
| 1808 %FunctionSetName(Intl.v8BreakIterator.prototype.resolvedOptions, | 1808 SetFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions, |
| 1809 'resolvedOptions'); | 1809 'resolvedOptions'); |
| 1810 %FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions); | 1810 %FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions); |
| 1811 %SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions); | 1811 %SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions); |
| 1812 | 1812 |
| 1813 | 1813 |
| 1814 /** | 1814 /** |
| 1815 * Returns the subset of the given locale list for which this locale list | 1815 * Returns the subset of the given locale list for which this locale list |
| 1816 * has a matching (possibly fallback) locale. Locales appear in the same | 1816 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1817 * order in the returned list as in the input list. | 1817 * order in the returned list as in the input list. |
| 1818 * Options are optional parameter. | 1818 * Options are optional parameter. |
| 1819 */ | 1819 */ |
| 1820 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', | 1820 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', |
| 1821 function(locales) { | 1821 function(locales) { |
| 1822 if (%_IsConstructCall()) { | 1822 if (%_IsConstructCall()) { |
| 1823 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1823 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 return supportedLocalesOf('breakiterator', locales, %_Arguments(1)); | 1826 return supportedLocalesOf('breakiterator', locales, %_Arguments(1)); |
| 1827 }, | 1827 }, |
| 1828 DONT_ENUM | 1828 DONT_ENUM |
| 1829 ); | 1829 ); |
| 1830 %FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); | 1830 SetFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1831 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); | 1831 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); |
| 1832 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); | 1832 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); |
| 1833 | 1833 |
| 1834 | 1834 |
| 1835 /** | 1835 /** |
| 1836 * Adopts text to segment using the iterator. Old text, if present, | 1836 * Adopts text to segment using the iterator. Old text, if present, |
| 1837 * gets discarded. | 1837 * gets discarded. |
| 1838 */ | 1838 */ |
| 1839 function adoptText(iterator, text) { | 1839 function adoptText(iterator, text) { |
| 1840 %BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(iterator), | 1840 %BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(iterator), |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 var locales = %_Arguments(0); | 2055 var locales = %_Arguments(0); |
| 2056 var options = %_Arguments(1); | 2056 var options = %_Arguments(1); |
| 2057 return toLocaleDateTime( | 2057 return toLocaleDateTime( |
| 2058 this, locales, options, 'time', 'time', 'dateformattime'); | 2058 this, locales, options, 'time', 'time', 'dateformattime'); |
| 2059 } | 2059 } |
| 2060 ); | 2060 ); |
| 2061 | 2061 |
| 2062 })(); | 2062 })(); |
| OLD | NEW |