From 84833a59bafdbdd19d7d63a00062b36caa5aa105 Mon Sep 17 00:00:00 2001 From: "jkummerow@chromium.org" Date: Wed, 3 Jul 2013 15:30:27 +0000 Subject: [PATCH] Mark i18n functions as native and set proper names BUG=v8:2745 R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/18075004 Patch from Jochen Eisinger . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15478 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/extensions/i18n/break-iterator.js | 5 +++++ src/extensions/i18n/collator.js | 4 ++++ src/extensions/i18n/date-format.js | 5 +++++ src/extensions/i18n/footer.js | 4 ---- src/extensions/i18n/i18n-utils.js | 10 +++++++--- src/extensions/i18n/number-format.js | 5 +++++ src/extensions/i18n/overrides.js | 10 ++++++++++ 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/extensions/i18n/break-iterator.js b/src/extensions/i18n/break-iterator.js index 9369082..eefd8c2 100644 --- a/src/extensions/i18n/break-iterator.js +++ b/src/extensions/i18n/break-iterator.js @@ -118,7 +118,10 @@ function initializeBreakIterator(iterator, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.v8BreakIterator.prototype.resolvedOptions, + 'resolvedOptions'); %FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions); +%SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions); /** @@ -136,7 +139,9 @@ function initializeBreakIterator(iterator, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); +%SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); /** diff --git a/src/extensions/i18n/collator.js b/src/extensions/i18n/collator.js index 021164a..3483515 100644 --- a/src/extensions/i18n/collator.js +++ b/src/extensions/i18n/collator.js @@ -168,7 +168,9 @@ function initializeCollator(collator, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions'); %FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions); +%SetNativeFlag(Intl.Collator.prototype.resolvedOptions); /** @@ -186,7 +188,9 @@ function initializeCollator(collator, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); +%SetNativeFlag(Intl.Collator.supportedLocalesOf); /** diff --git a/src/extensions/i18n/date-format.js b/src/extensions/i18n/date-format.js index a91103e..04e7a7c 100644 --- a/src/extensions/i18n/date-format.js +++ b/src/extensions/i18n/date-format.js @@ -377,7 +377,10 @@ function initializeDateTimeFormat(dateFormat, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.DateTimeFormat.prototype.resolvedOptions, + 'resolvedOptions'); %FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions); +%SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); /** @@ -395,7 +398,9 @@ function initializeDateTimeFormat(dateFormat, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); +%SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); /** diff --git a/src/extensions/i18n/footer.js b/src/extensions/i18n/footer.js index a08153c..ac33f1e 100644 --- a/src/extensions/i18n/footer.js +++ b/src/extensions/i18n/footer.js @@ -38,7 +38,3 @@ CLEANUP_RE.test(''); return Intl; }()); - -// Alias v8Intl to Intl so we don't break existing applications. -// TODO(cira): Remove in a couple of months (starting at Oct 1st 2012). -var v8Intl = Intl; diff --git a/src/extensions/i18n/i18n-utils.js b/src/extensions/i18n/i18n-utils.js index c15a7d3..d7e9486 100644 --- a/src/extensions/i18n/i18n-utils.js +++ b/src/extensions/i18n/i18n-utils.js @@ -73,13 +73,17 @@ function addBoundMethod(obj, methodName, implementation, length) { } } } + %FunctionSetName(boundMethod, internalName); %FunctionRemovePrototype(boundMethod); + %SetNativeFlag(boundMethod); this[internalName] = boundMethod; } return this[internalName]; } + %FunctionSetName(getter, methodName); %FunctionRemovePrototype(getter); + %SetNativeFlag(getter); Object.defineProperty(obj.prototype, methodName, { get: getter, @@ -185,7 +189,7 @@ function getGetOption(options, caller) { 'Default options are missing.'); } - function getOption(property, type, values, defaultValue) { + var getOption = function getOption(property, type, values, defaultValue) { if (options[property] !== undefined) { var value = options[property]; switch (type) { @@ -362,11 +366,11 @@ function toObject(value) { function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) { var extension = ''; - function updateExtension(key, value) { + var updateExtension = function updateExtension(key, value) { return '-' + key + '-' + String(value); } - function updateProperty(property, type, value) { + var updateProperty = function updateProperty(property, type, value) { if (type === 'boolean' && (typeof value === 'string')) { value = (value === 'true') ? true : false; } diff --git a/src/extensions/i18n/number-format.js b/src/extensions/i18n/number-format.js index 5f5285d..1cd3db1 100644 --- a/src/extensions/i18n/number-format.js +++ b/src/extensions/i18n/number-format.js @@ -237,7 +237,10 @@ function initializeNumberFormat(numberFormat, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.NumberFormat.prototype.resolvedOptions, + 'resolvedOptions'); %FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions); +%SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); /** @@ -255,7 +258,9 @@ function initializeNumberFormat(numberFormat, locales, options) { }, ATTRIBUTES.DONT_ENUM ); +%FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); +%SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); /** diff --git a/src/extensions/i18n/overrides.js b/src/extensions/i18n/overrides.js index 58e22aa..b2d60b3 100644 --- a/src/extensions/i18n/overrides.js +++ b/src/extensions/i18n/overrides.js @@ -91,7 +91,9 @@ Object.defineProperty(String.prototype, 'localeCompare', { configurable: true, enumerable: false }); +%FunctionSetName(String.prototype.localeCompare, 'localeCompare'); %FunctionRemovePrototype(String.prototype.localeCompare); +%SetNativeFlag(String.prototype.localeCompare); /** @@ -117,7 +119,9 @@ Object.defineProperty(Number.prototype, 'toLocaleString', { configurable: true, enumerable: false }); +%FunctionSetName(Number.prototype.toLocaleString, 'toLocaleString'); %FunctionRemovePrototype(Number.prototype.toLocaleString); +%SetNativeFlag(Number.prototype.toLocaleString); /** @@ -161,7 +165,9 @@ Object.defineProperty(Date.prototype, 'toLocaleString', { configurable: true, enumerable: false }); +%FunctionSetName(Date.prototype.toLocaleString, 'toLocaleString'); %FunctionRemovePrototype(Date.prototype.toLocaleString); +%SetNativeFlag(Date.prototype.toLocaleString); /** @@ -184,7 +190,9 @@ Object.defineProperty(Date.prototype, 'toLocaleDateString', { configurable: true, enumerable: false }); +%FunctionSetName(Date.prototype.toLocaleDateString, 'toLocaleDateString'); %FunctionRemovePrototype(Date.prototype.toLocaleDateString); +%SetNativeFlag(Date.prototype.toLocaleDateString); /** @@ -207,4 +215,6 @@ Object.defineProperty(Date.prototype, 'toLocaleTimeString', { configurable: true, enumerable: false }); +%FunctionSetName(Date.prototype.toLocaleTimeString, 'toLocaleTimeString'); %FunctionRemovePrototype(Date.prototype.toLocaleTimeString); +%SetNativeFlag(Date.prototype.toLocaleTimeString); -- 2.7.4