Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: src/js/icu-case-mapping.js

Issue 1812673005: Use ICU case conversion/transliterator for case conversion behind a flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: move toLocale{U,L}Case behind --icu-case-mapping, too; adjust test status accordingly. roll back st… Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/js/i18n.js ('k') | src/js/prologue.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/icu-case-mapping.js
diff --git a/src/js/icu-case-mapping.js b/src/js/icu-case-mapping.js
new file mode 100644
index 0000000000000000000000000000000000000000..d9abbb1ea83d6bc79bed11545a78be41d08565e3
--- /dev/null
+++ b/src/js/icu-case-mapping.js
@@ -0,0 +1,57 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function(global, utils) {
+"use strict";
+
+%CheckIsBootstrapping();
+
+var GlobalString = global.String;
+var OverrideFunction = utils.OverrideFunction;
+var MakeTypeError;
+var LocaleConvertCase = utils.ImportNow("LocaleConvertCase");
Dan Ehrenberg 2016/05/04 00:13:08 Rather than using ImportNow (generally dispreferre
jungshik at Google 2016/05/04 19:02:58 Done.
+
+utils.Import(function(from) {
+ MakeTypeError = from.MakeTypeError;
+});
+
+OverrideFunction(GlobalString.prototype, 'toLowerCase', function() {
jungshik at Google 2016/05/04 19:02:58 offline, you're worried about actually defining fu
Dan Ehrenberg 2016/05/04 19:06:37 That's what I was suggesting, though if you found
+ if (!IS_UNDEFINED(new.target)) {
+ throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
+ }
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
+ var s = TO_STRING(this);
+ return %StringToLowerCaseI18N(s);
+ }
+);
+
+OverrideFunction(GlobalString.prototype, 'toUpperCase', function() {
+ if (!IS_UNDEFINED(new.target)) {
+ throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
+ }
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
+ var s = TO_STRING(this);
+ return %StringToUpperCaseI18N(s);
+ }
+);
+
+OverrideFunction(GlobalString.prototype, 'toLocaleLowerCase', function() {
+ if (!IS_UNDEFINED(new.target)) {
+ throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
+ }
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
+ return LocaleConvertCase(TO_STRING(this), arguments[0], false);
+ }
+);
+
+OverrideFunction(GlobalString.prototype, 'toLocaleUpperCase', function() {
+ if (!IS_UNDEFINED(new.target)) {
+ throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
+ }
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
+ return LocaleConvertCase(TO_STRING(this), arguments[0], true);
+ }
+);
+
+})
« no previous file with comments | « src/js/i18n.js ('k') | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698