Commit c4311e52 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Remove intl.(h|cc)

Fold methods from intl.* to objects/intl-objects.*
Move Isolate* to the first parameter for some method
Move ICUSerice type under Intl
Hide ICUTimeZoneCache under a CreateTimeZoneCache factory method.

Bug: v8:5751
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ie6f6a1ceee789333a077c1965de8e11d8c15c175
Reviewed-on: https://chromium-review.googlesource.com/c/1293109
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56873}
parent 66daabcc
...@@ -2150,8 +2150,6 @@ v8_source_set("v8_base") { ...@@ -2150,8 +2150,6 @@ v8_source_set("v8_base") {
"src/interpreter/interpreter-intrinsics.h", "src/interpreter/interpreter-intrinsics.h",
"src/interpreter/interpreter.cc", "src/interpreter/interpreter.cc",
"src/interpreter/interpreter.h", "src/interpreter/interpreter.h",
"src/intl.cc",
"src/intl.h",
"src/isolate-data.h", "src/isolate-data.h",
"src/isolate-inl.h", "src/isolate-inl.h",
"src/isolate.cc", "src/isolate.cc",
...@@ -2976,8 +2974,6 @@ v8_source_set("v8_base") { ...@@ -2976,8 +2974,6 @@ v8_source_set("v8_base") {
sources -= [ sources -= [
"src/builtins/builtins-intl.cc", "src/builtins/builtins-intl.cc",
"src/char-predicates.cc", "src/char-predicates.cc",
"src/intl.cc",
"src/intl.h",
"src/objects/intl-objects.cc", "src/objects/intl-objects.cc",
"src/objects/intl-objects.h", "src/objects/intl-objects.h",
"src/objects/js-break-iterator-inl.h", "src/objects/js-break-iterator-inl.h",
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "src/builtins/builtins.h" #include "src/builtins/builtins.h"
#include "src/date.h" #include "src/date.h"
#include "src/elements.h" #include "src/elements.h"
#include "src/intl.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/intl-objects.h" #include "src/objects/intl-objects.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
...@@ -50,7 +49,7 @@ BUILTIN(StringPrototypeToUpperCaseIntl) { ...@@ -50,7 +49,7 @@ BUILTIN(StringPrototypeToUpperCaseIntl) {
HandleScope scope(isolate); HandleScope scope(isolate);
TO_THIS_STRING(string, "String.prototype.toUpperCase"); TO_THIS_STRING(string, "String.prototype.toUpperCase");
string = String::Flatten(isolate, string); string = String::Flatten(isolate, string);
RETURN_RESULT_OR_FAILURE(isolate, ConvertCase(string, true, isolate)); RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToUpper(isolate, string));
} }
BUILTIN(StringPrototypeNormalizeIntl) { BUILTIN(StringPrototypeNormalizeIntl) {
...@@ -98,27 +97,22 @@ BUILTIN(StringPrototypeNormalizeIntl) { ...@@ -98,27 +97,22 @@ BUILTIN(StringPrototypeNormalizeIntl) {
icu::UnicodeString result; icu::UnicodeString result;
std::unique_ptr<uc16[]> sap; std::unique_ptr<uc16[]> sap;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
{ icu::UnicodeString input = Intl::ToICUUnicodeString(isolate, string);
DisallowHeapAllocation no_gc; // Getting a singleton. Should not free it.
String::FlatContent flat = string->GetFlatContent(); const icu::Normalizer2* normalizer =
const UChar* src = GetUCharBufferFromFlat(flat, &sap, length); icu::Normalizer2::getInstance(nullptr, form_name, form_mode, status);
icu::UnicodeString input(false, src, length); DCHECK(U_SUCCESS(status));
// Getting a singleton. Should not free it. CHECK_NOT_NULL(normalizer);
const icu::Normalizer2* normalizer = int32_t normalized_prefix_length =
icu::Normalizer2::getInstance(nullptr, form_name, form_mode, status); normalizer->spanQuickCheckYes(input, status);
DCHECK(U_SUCCESS(status)); // Quick return if the input is already normalized.
CHECK_NOT_NULL(normalizer); if (length == normalized_prefix_length) return *string;
int32_t normalized_prefix_length = icu::UnicodeString unnormalized =
normalizer->spanQuickCheckYes(input, status); input.tempSubString(normalized_prefix_length);
// Quick return if the input is already normalized. // Read-only alias of the normalized prefix.
if (length == normalized_prefix_length) return *string; result.setTo(false, input.getBuffer(), normalized_prefix_length);
icu::UnicodeString unnormalized = // copy-on-write; normalize the suffix and append to |result|.
input.tempSubString(normalized_prefix_length); normalizer->normalizeSecondAndAppend(result, unnormalized, status);
// Read-only alias of the normalized prefix.
result.setTo(false, input.getBuffer(), normalized_prefix_length);
// copy-on-write; normalize the suffix and append to |result|.
normalizer->normalizeSecondAndAppend(result, unnormalized, status);
}
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
THROW_NEW_ERROR_RETURN_FAILURE(isolate, THROW_NEW_ERROR_RETURN_FAILURE(isolate,
...@@ -137,8 +131,9 @@ BUILTIN(V8BreakIteratorSupportedLocalesOf) { ...@@ -137,8 +131,9 @@ BUILTIN(V8BreakIteratorSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kBreakIterator, isolate,
locales, options)); Intl::SupportedLocalesOf(isolate, Intl::ICUService::kBreakIterator,
locales, options));
} }
BUILTIN(NumberFormatSupportedLocalesOf) { BUILTIN(NumberFormatSupportedLocalesOf) {
...@@ -147,8 +142,8 @@ BUILTIN(NumberFormatSupportedLocalesOf) { ...@@ -147,8 +142,8 @@ BUILTIN(NumberFormatSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kNumberFormat, isolate, Intl::SupportedLocalesOf(
locales, options)); isolate, Intl::ICUService::kNumberFormat, locales, options));
} }
BUILTIN(NumberFormatPrototypeFormatToParts) { BUILTIN(NumberFormatPrototypeFormatToParts) {
...@@ -189,7 +184,7 @@ BUILTIN(DateTimeFormatSupportedLocalesOf) { ...@@ -189,7 +184,7 @@ BUILTIN(DateTimeFormatSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kDateFormat, isolate, Intl::SupportedLocalesOf(isolate, Intl::ICUService::kDateFormat,
locales, options)); locales, options));
} }
...@@ -540,8 +535,9 @@ BUILTIN(ListFormatSupportedLocalesOf) { ...@@ -540,8 +535,9 @@ BUILTIN(ListFormatSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kListFormatter, isolate,
locales, options)); Intl::SupportedLocalesOf(isolate, Intl::ICUService::kListFormatter,
locales, options));
} }
namespace { namespace {
...@@ -647,9 +643,9 @@ BUILTIN(RelativeTimeFormatSupportedLocalesOf) { ...@@ -647,9 +643,9 @@ BUILTIN(RelativeTimeFormatSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Intl::SupportedLocalesOf(
Intl::SupportedLocalesOf(isolate, ICUService::kRelativeDateTimeFormatter, isolate, Intl::ICUService::kRelativeDateTimeFormatter,
locales, options)); locales, options));
} }
BUILTIN(RelativeTimeFormatPrototypeFormat) { BUILTIN(RelativeTimeFormatPrototypeFormat) {
...@@ -911,7 +907,7 @@ BUILTIN(PluralRulesSupportedLocalesOf) { ...@@ -911,7 +907,7 @@ BUILTIN(PluralRulesSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kPluralRules, isolate, Intl::SupportedLocalesOf(isolate, Intl::ICUService::kPluralRules,
locales, options)); locales, options));
} }
...@@ -961,8 +957,8 @@ BUILTIN(CollatorSupportedLocalesOf) { ...@@ -961,8 +957,8 @@ BUILTIN(CollatorSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kCollator, locales, isolate, Intl::SupportedLocalesOf(isolate, Intl::ICUService::kCollator,
options)); locales, options));
} }
BUILTIN(CollatorPrototypeCompare) { BUILTIN(CollatorPrototypeCompare) {
...@@ -1117,7 +1113,7 @@ BUILTIN(SegmenterSupportedLocalesOf) { ...@@ -1117,7 +1113,7 @@ BUILTIN(SegmenterSupportedLocalesOf) {
Handle<Object> options = args.atOrUndefined(isolate, 2); Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Intl::SupportedLocalesOf(isolate, ICUService::kSegmenter, isolate, Intl::SupportedLocalesOf(isolate, Intl::ICUService::kSegmenter,
locales, options)); locales, options));
} }
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
#include "src/conversions.h" #include "src/conversions.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects.h"
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
#include "src/intl.h" #include "src/objects/intl-objects.h"
#endif #endif
#include "src/objects.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -30,8 +29,7 @@ DateCache::DateCache() ...@@ -30,8 +29,7 @@ DateCache::DateCache()
: stamp_(nullptr), : stamp_(nullptr),
tz_cache_( tz_cache_(
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
FLAG_icu_timezone_data ? new ICUTimezoneCache() Intl::CreateTimeZoneCache()
: base::OS::CreateTimezoneCache()
#else #else
base::OS::CreateTimezoneCache() base::OS::CreateTimezoneCache()
#endif #endif
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#endif // V8_INTERPRETED_REGEXP #endif // V8_INTERPRETED_REGEXP
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
#include "src/intl.h" #include "src/objects/intl-objects.h"
#endif // V8_INTL_SUPPORT #endif // V8_INTL_SUPPORT
namespace v8 { namespace v8 {
...@@ -815,11 +815,12 @@ ExternalReference ExternalReference::check_object_type() { ...@@ -815,11 +815,12 @@ ExternalReference ExternalReference::check_object_type() {
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
ExternalReference ExternalReference::intl_convert_one_byte_to_lower() { ExternalReference ExternalReference::intl_convert_one_byte_to_lower() {
return ExternalReference(Redirect(FUNCTION_ADDR(ConvertOneByteToLower))); return ExternalReference(
Redirect(FUNCTION_ADDR(Intl::ConvertOneByteToLower)));
} }
ExternalReference ExternalReference::intl_to_latin1_lower_table() { ExternalReference ExternalReference::intl_to_latin1_lower_table() {
uint8_t* ptr = const_cast<uint8_t*>(ToLatin1LowerTable()); uint8_t* ptr = const_cast<uint8_t*>(Intl::ToLatin1LowerTable());
return ExternalReference(reinterpret_cast<Address>(ptr)); return ExternalReference(reinterpret_cast<Address>(ptr));
} }
#endif // V8_INTL_SUPPORT #endif // V8_INTL_SUPPORT
......
This diff is collapsed.
// Copyright 2013 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.
#ifndef V8_INTL_SUPPORT
#error Internationalization is expected to be enabled.
#endif // V8_INTL_SUPPORT
#ifndef V8_INTL_H_
#define V8_INTL_H_
#include <string>
#include "src/base/timezone-cache.h"
#include "src/objects.h"
#include "src/objects/string.h"
#include "unicode/uversion.h"
namespace U_ICU_NAMESPACE {
class TimeZone;
}
namespace v8 {
namespace internal {
enum class ICUService {
kBreakIterator,
kCollator,
kDateFormat,
kNumberFormat,
kPluralRules,
kRelativeDateTimeFormatter,
kListFormatter,
kSegmenter
};
const UChar* GetUCharBufferFromFlat(const String::FlatContent& flat,
std::unique_ptr<uc16[]>* dest,
int32_t length);
MaybeHandle<String> LocaleConvertCase(Handle<String> s, Isolate* isolate,
bool is_to_upper, const char* lang);
MaybeHandle<String> ConvertToLower(Handle<String> s, Isolate* isolate);
MaybeHandle<String> ConvertToUpper(Handle<String> s, Isolate* isolate);
MaybeHandle<String> ConvertCase(Handle<String> s, bool is_upper,
Isolate* isolate);
V8_WARN_UNUSED_RESULT String* ConvertOneByteToLower(String* src, String* dst);
const uint8_t* ToLatin1LowerTable();
// ICUTimezoneCache calls out to ICU for TimezoneCache
// functionality in a straightforward way.
class ICUTimezoneCache : public base::TimezoneCache {
public:
ICUTimezoneCache();
~ICUTimezoneCache() override;
const char* LocalTimezone(double time_ms) override;
double DaylightSavingsOffset(double time_ms) override;
double LocalTimeOffset(double time_ms, bool is_utc) override;
void Clear() override;
private:
icu::TimeZone* GetTimeZone();
bool GetOffsets(double time_ms, bool is_utc, int32_t* raw_offset,
int32_t* dst_offset);
icu::TimeZone* timezone_;
std::string timezone_name_;
std::string dst_timezone_name_;
};
} // namespace internal
} // namespace v8
#endif // V8_INTL_H_
This diff is collapsed.
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <set> #include <set>
#include <string> #include <string>
#include "src/base/timezone-cache.h"
#include "src/contexts.h" #include "src/contexts.h"
#include "src/intl.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/managed.h" #include "src/objects/managed.h"
#include "unicode/locid.h" #include "unicode/locid.h"
...@@ -41,6 +41,17 @@ class Intl { ...@@ -41,6 +41,17 @@ class Intl {
kLength kLength
}; };
enum class ICUService {
kBreakIterator,
kCollator,
kDateFormat,
kNumberFormat,
kPluralRules,
kRelativeDateTimeFormatter,
kListFormatter,
kSegmenter
};
// Gets the ICU locales for a given service. If there is a locale with a // Gets the ICU locales for a given service. If there is a locale with a
// script tag then the locales also include a locale without the script; eg, // script tag then the locales also include a locale without the script; eg,
// pa_Guru_IN (language=Panjabi, script=Gurmukhi, country-India) would include // pa_Guru_IN (language=Panjabi, script=Gurmukhi, country-India) would include
...@@ -117,6 +128,12 @@ class Intl { ...@@ -117,6 +128,12 @@ class Intl {
Isolate* isolate, Handle<String> s, bool is_upper, Isolate* isolate, Handle<String> s, bool is_upper,
Handle<Object> locales); Handle<Object> locales);
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToUpper(
Isolate* isolate, Handle<String> s);
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToLower(
Isolate* isolate, Handle<String> s);
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> StringLocaleCompare( V8_WARN_UNUSED_RESULT static MaybeHandle<Object> StringLocaleCompare(
Isolate* isolate, Handle<String> s1, Handle<String> s2, Isolate* isolate, Handle<String> s1, Handle<String> s2,
Handle<Object> locales, Handle<Object> options); Handle<Object> locales, Handle<Object> options);
...@@ -198,6 +215,16 @@ class Intl { ...@@ -198,6 +215,16 @@ class Intl {
static Managed<icu::UnicodeString>* SetTextToBreakIterator( static Managed<icu::UnicodeString>* SetTextToBreakIterator(
Isolate* isolate, Handle<String> text, Isolate* isolate, Handle<String> text,
icu::BreakIterator* break_iterator); icu::BreakIterator* break_iterator);
static base::TimezoneCache* CreateTimeZoneCache();
// Convert a Handle<String> to icu::UnicodeString
static icu::UnicodeString ToICUUnicodeString(Isolate* isolate,
Handle<String> string);
static const uint8_t* ToLatin1LowerTable();
static String* ConvertOneByteToLower(String* src, String* dst);
}; };
} // namespace internal } // namespace internal
......
...@@ -60,7 +60,7 @@ MaybeHandle<JSV8BreakIterator> JSV8BreakIterator::Initialize( ...@@ -60,7 +60,7 @@ MaybeHandle<JSV8BreakIterator> JSV8BreakIterator::Initialize(
} }
} }
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kBreakIterator); Intl::GetAvailableLocales(Intl::ICUService::kBreakIterator);
Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales, Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales,
requested_locales, matcher, {}); requested_locales, matcher, {});
......
...@@ -309,7 +309,7 @@ MaybeHandle<JSCollator> JSCollator::Initialize(Isolate* isolate, ...@@ -309,7 +309,7 @@ MaybeHandle<JSCollator> JSCollator::Initialize(Isolate* isolate,
// requestedLocales, opt, %Collator%.[[RelevantExtensionKeys]], // requestedLocales, opt, %Collator%.[[RelevantExtensionKeys]],
// localeData). // localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kCollator); Intl::GetAvailableLocales(Intl::ICUService::kCollator);
Intl::ResolvedLocale r = Intl::ResolvedLocale r =
Intl::ResolveLocale(isolate, available_locales, requested_locales, Intl::ResolveLocale(isolate, available_locales, requested_locales,
matcher, relevant_extension_keys); matcher, relevant_extension_keys);
......
...@@ -785,7 +785,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize( ...@@ -785,7 +785,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize(
// requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]], // requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]],
// localeData). // localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kDateFormat); Intl::GetAvailableLocales(Intl::ICUService::kDateFormat);
Intl::ResolvedLocale r = Intl::ResolveLocale( Intl::ResolvedLocale r = Intl::ResolveLocale(
isolate, available_locales, requested_locales, locale_matcher, {"nu"}); isolate, available_locales, requested_locales, locale_matcher, {"nu"});
......
...@@ -203,7 +203,7 @@ MaybeHandle<JSListFormat> JSListFormat::Initialize( ...@@ -203,7 +203,7 @@ MaybeHandle<JSListFormat> JSListFormat::Initialize(
// 15. Let r be ResolveLocale(%ListFormat%.[[AvailableLocales]], // 15. Let r be ResolveLocale(%ListFormat%.[[AvailableLocales]],
// requestedLocales, opt, undefined, localeData). // requestedLocales, opt, undefined, localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kListFormatter); Intl::GetAvailableLocales(Intl::ICUService::kListFormatter);
Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales, Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales,
requested_locales, matcher, {}); requested_locales, matcher, {});
...@@ -353,13 +353,7 @@ Maybe<bool> ToUnicodeStringArray(Isolate* isolate, Handle<JSArray> array, ...@@ -353,13 +353,7 @@ Maybe<bool> ToUnicodeStringArray(Isolate* isolate, Handle<JSArray> array,
} }
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
Handle<String> string = Handle<String>::cast(accessor->Get(array, i)); Handle<String> string = Handle<String>::cast(accessor->Get(array, i));
DisallowHeapAllocation no_gc; items[i] = Intl::ToICUUnicodeString(isolate, string);
string = String::Flatten(isolate, string);
std::unique_ptr<uc16[]> sap;
items[i] =
icu::UnicodeString(GetUCharBufferFromFlat(string->GetFlatContent(),
&sap, string->length()),
string->length());
} }
return Just(true); return Just(true);
} }
......
...@@ -235,7 +235,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::Initialize( ...@@ -235,7 +235,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::Initialize(
// requestedLocales, opt, %NumberFormat%.[[RelevantExtensionKeys]], // requestedLocales, opt, %NumberFormat%.[[RelevantExtensionKeys]],
// localeData). // localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kNumberFormat); Intl::GetAvailableLocales(Intl::ICUService::kNumberFormat);
std::set<std::string> relevant_extension_keys{"nu"}; std::set<std::string> relevant_extension_keys{"nu"};
Intl::ResolvedLocale r = Intl::ResolvedLocale r =
Intl::ResolveLocale(isolate, available_locales, requested_locales, Intl::ResolveLocale(isolate, available_locales, requested_locales,
......
...@@ -152,7 +152,7 @@ MaybeHandle<JSPluralRules> JSPluralRules::Initialize( ...@@ -152,7 +152,7 @@ MaybeHandle<JSPluralRules> JSPluralRules::Initialize(
// requestedLocales, opt, %PluralRules%.[[RelevantExtensionKeys]], // requestedLocales, opt, %PluralRules%.[[RelevantExtensionKeys]],
// localeData). // localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kPluralRules); Intl::GetAvailableLocales(Intl::ICUService::kPluralRules);
Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales, Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales,
requested_locales, matcher, {}); requested_locales, matcher, {});
......
...@@ -103,7 +103,7 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::Initialize( ...@@ -103,7 +103,7 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::Initialize(
// requestedLocales, opt, // requestedLocales, opt,
// %RelativeTimeFormat%.[[RelevantExtensionKeys]], localeData). // %RelativeTimeFormat%.[[RelevantExtensionKeys]], localeData).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kRelativeDateTimeFormatter); Intl::GetAvailableLocales(Intl::ICUService::kRelativeDateTimeFormatter);
Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales, Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales,
requested_locales, matcher, {}); requested_locales, matcher, {});
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <string> #include <string>
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/intl.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/intl-objects.h" #include "src/objects/intl-objects.h"
......
...@@ -86,7 +86,7 @@ MaybeHandle<JSSegmenter> JSSegmenter::Initialize( ...@@ -86,7 +86,7 @@ MaybeHandle<JSSegmenter> JSSegmenter::Initialize(
// 9. Let r be ResolveLocale(%Segmenter%.[[AvailableLocales]], // 9. Let r be ResolveLocale(%Segmenter%.[[AvailableLocales]],
// requestedLocales, opt, %Segmenter%.[[RelevantExtensionKeys]]). // requestedLocales, opt, %Segmenter%.[[RelevantExtensionKeys]]).
std::set<std::string> available_locales = std::set<std::string> available_locales =
Intl::GetAvailableLocales(ICUService::kSegmenter); Intl::GetAvailableLocales(Intl::ICUService::kSegmenter);
Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales, Intl::ResolvedLocale r = Intl::ResolveLocale(isolate, available_locales,
requested_locales, matcher, {}); requested_locales, matcher, {});
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "src/date.h" #include "src/date.h"
#include "src/global-handles.h" #include "src/global-handles.h"
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/intl.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/objects/intl-objects.h" #include "src/objects/intl-objects.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
...@@ -103,7 +102,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) { ...@@ -103,7 +102,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) {
DCHECK_EQ(args.length(), 1); DCHECK_EQ(args.length(), 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0); CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
s = String::Flatten(isolate, s); s = String::Flatten(isolate, s);
RETURN_RESULT_OR_FAILURE(isolate, ConvertToLower(s, isolate)); RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToLower(isolate, s));
} }
RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) { RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) {
...@@ -111,7 +110,7 @@ RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) { ...@@ -111,7 +110,7 @@ RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) {
DCHECK_EQ(args.length(), 1); DCHECK_EQ(args.length(), 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0); CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
s = String::Flatten(isolate, s); s = String::Flatten(isolate, s);
RETURN_RESULT_OR_FAILURE(isolate, ConvertToUpper(s, isolate)); RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToUpper(isolate, s));
} }
RUNTIME_FUNCTION(Runtime_DateCacheVersion) { RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
......
...@@ -211,23 +211,24 @@ TEST(GetBoolOption) { ...@@ -211,23 +211,24 @@ TEST(GetBoolOption) {
TEST(GetAvailableLocales) { TEST(GetAvailableLocales) {
std::set<std::string> locales; std::set<std::string> locales;
locales = Intl::GetAvailableLocales(ICUService::kBreakIterator); locales = Intl::GetAvailableLocales(Intl::ICUService::kBreakIterator);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
CHECK(!locales.count("abcdefg")); CHECK(!locales.count("abcdefg"));
locales = Intl::GetAvailableLocales(ICUService::kCollator); locales = Intl::GetAvailableLocales(Intl::ICUService::kCollator);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
locales = Intl::GetAvailableLocales(ICUService::kDateFormat); locales = Intl::GetAvailableLocales(Intl::ICUService::kDateFormat);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
locales = Intl::GetAvailableLocales(ICUService::kNumberFormat); locales = Intl::GetAvailableLocales(Intl::ICUService::kNumberFormat);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
locales = Intl::GetAvailableLocales(ICUService::kPluralRules); locales = Intl::GetAvailableLocales(Intl::ICUService::kPluralRules);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
locales = Intl::GetAvailableLocales(ICUService::kRelativeDateTimeFormatter); locales =
Intl::GetAvailableLocales(Intl::ICUService::kRelativeDateTimeFormatter);
CHECK(locales.count("en-US")); CHECK(locales.count("en-US"));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment