v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-collator.cc
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_INTL_SUPPORT
6#error Internationalization is expected to be enabled.
7#endif // V8_INTL_SUPPORT
8
10
17#include "unicode/coll.h"
18#include "unicode/locid.h"
19#include "unicode/strenum.h"
20#include "unicode/ucol.h"
21#include "unicode/udata.h"
22#include "unicode/uloc.h"
23#include "unicode/utypes.h"
24
25namespace v8 {
26namespace internal {
27
28namespace {
29
30enum class Usage {
31 SORT,
32 SEARCH,
33};
34
35enum class Sensitivity {
36 kBase,
37 kAccent,
38 kCase,
39 kVariant,
41};
42
43// enum for "caseFirst" option.
44enum class CaseFirst { kUndefined, kUpper, kLower, kFalse };
45
46Maybe<CaseFirst> GetCaseFirst(Isolate* isolate,
47 DirectHandle<JSReceiver> options,
48 const char* method_name) {
50 isolate, options, "caseFirst", method_name, {"upper", "lower", "false"},
51 {CaseFirst::kUpper, CaseFirst::kLower, CaseFirst::kFalse},
52 CaseFirst::kUndefined);
53}
54
55// TODO(gsathya): Consider internalizing the value strings.
56void CreateDataPropertyForOptions(Isolate* isolate,
57 DirectHandle<JSObject> options,
58 DirectHandle<String> key, const char* value) {
59 DCHECK_NOT_NULL(value);
60 DirectHandle<String> value_str =
61 isolate->factory()->NewStringFromAsciiChecked(value);
62
63 // This is a brand new JSObject that shouldn't already have the same
64 // key so this shouldn't fail.
65 Maybe<bool> maybe = JSReceiver::CreateDataProperty(
66 isolate, options, key, value_str, Just(kDontThrow));
67 DCHECK(maybe.FromJust());
68 USE(maybe);
69}
70
71void CreateDataPropertyForOptions(Isolate* isolate,
72 DirectHandle<JSObject> options,
73 DirectHandle<String> key, bool value) {
74 DirectHandle<Object> value_obj = isolate->factory()->ToBoolean(value);
75
76 // This is a brand new JSObject that shouldn't already have the same
77 // key so this shouldn't fail.
78 Maybe<bool> maybe = JSReceiver::CreateDataProperty(
79 isolate, options, key, value_obj, Just(kDontThrow));
80 DCHECK(maybe.FromJust());
81 USE(maybe);
82}
83
84} // anonymous namespace
85
86// static
88 Isolate* isolate, DirectHandle<JSCollator> collator) {
90 isolate->factory()->NewJSObject(isolate->object_function());
91
92 icu::Collator* icu_collator = collator->icu_collator()->raw();
93 DCHECK_NOT_NULL(icu_collator);
94
95 UErrorCode status = U_ZERO_ERROR;
96 bool numeric =
97 icu_collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON;
98 DCHECK(U_SUCCESS(status));
99
100 const char* case_first = nullptr;
101 status = U_ZERO_ERROR;
102 switch (icu_collator->getAttribute(UCOL_CASE_FIRST, status)) {
103 case UCOL_LOWER_FIRST:
104 case_first = "lower";
105 break;
106 case UCOL_UPPER_FIRST:
107 case_first = "upper";
108 break;
109 default:
110 case_first = "false";
111 }
112 DCHECK(U_SUCCESS(status));
113
114 const char* sensitivity = nullptr;
115 status = U_ZERO_ERROR;
116 switch (icu_collator->getAttribute(UCOL_STRENGTH, status)) {
117 case UCOL_PRIMARY: {
118 DCHECK(U_SUCCESS(status));
119 status = U_ZERO_ERROR;
120 // case level: true + s1 -> case, s1 -> base.
121 if (UCOL_ON == icu_collator->getAttribute(UCOL_CASE_LEVEL, status)) {
122 sensitivity = "case";
123 } else {
124 sensitivity = "base";
125 }
126 DCHECK(U_SUCCESS(status));
127 break;
128 }
129 case UCOL_SECONDARY:
130 sensitivity = "accent";
131 break;
132 case UCOL_TERTIARY:
133 sensitivity = "variant";
134 break;
135 case UCOL_QUATERNARY:
136 // We shouldn't get quaternary and identical from ICU, but if we do
137 // put them into variant.
138 sensitivity = "variant";
139 break;
140 default:
141 sensitivity = "variant";
142 }
143 DCHECK(U_SUCCESS(status));
144
145 status = U_ZERO_ERROR;
146 bool ignore_punctuation = icu_collator->getAttribute(UCOL_ALTERNATE_HANDLING,
147 status) == UCOL_SHIFTED;
148 DCHECK(U_SUCCESS(status));
149
150 status = U_ZERO_ERROR;
151
152 icu::Locale icu_locale(icu_collator->getLocale(ULOC_VALID_LOCALE, status));
153 DCHECK(U_SUCCESS(status));
154
155 const char* collation = "default";
156 const char* usage = "sort";
157 const char* collation_key = "co";
158 status = U_ZERO_ERROR;
159 std::string collation_value =
160 icu_locale.getUnicodeKeywordValue<std::string>(collation_key, status);
161
162 std::string locale;
163 if (U_SUCCESS(status)) {
164 if (collation_value == "search") {
165 usage = "search";
166
167 // Search is disallowed as a collation value per spec. Let's
168 // use `default`, instead.
169 //
170 // https://tc39.github.io/ecma402/#sec-properties-of-intl-collator-instances
171 collation = "default";
172
173 // We clone the icu::Locale because we don't want the
174 // icu_collator to be affected when we remove the collation key
175 // below.
176 icu::Locale new_icu_locale = icu_locale;
177
178 // The spec forbids the search as a collation value in the
179 // locale tag, so let's filter it out.
180 status = U_ZERO_ERROR;
181 new_icu_locale.setUnicodeKeywordValue(collation_key, nullptr, status);
182 DCHECK(U_SUCCESS(status));
183
184 locale = Intl::ToLanguageTag(new_icu_locale).FromJust();
185 } else {
186 collation = collation_value.c_str();
187 locale = Intl::ToLanguageTag(icu_locale).FromJust();
188 }
189 } else {
190 locale = Intl::ToLanguageTag(icu_locale).FromJust();
191 }
192
193 // 5. For each row of Table 2, except the header row, in table order, do
194 // ...
195 // Table 2: Resolved Options of Collator Instances
196 // Internal Slot Property Extension Key
197 // [[Locale] "locale"
198 // [[Usage] "usage"
199 // [[Sensitivity]] "sensitivity"
200 // [[IgnorePunctuation]] "ignorePunctuation"
201 // [[Collation]] "collation"
202 // [[Numeric]] "numeric" kn
203 // [[CaseFirst]] "caseFirst" kf
204
205 // If the collator return the locale differ from what got requested, we stored
206 // it in the collator->locale. Otherwise, we just use the one from the
207 // collator.
208 if (collator->locale()->length() != 0) {
209 // Get the locale from collator->locale() since we know in some cases
210 // collator won't be able to return the requested one, such as zh_CN.
211 DirectHandle<String> locale_from_collator(collator->locale(), isolate);
213 isolate, options, isolate->factory()->locale_string(),
214 locale_from_collator, Just(kDontThrow));
215 DCHECK(maybe.FromJust());
216 USE(maybe);
217 } else {
218 // Just return from the collator for most of the cases that we can recover
219 // from the collator.
220 CreateDataPropertyForOptions(
221 isolate, options, isolate->factory()->locale_string(), locale.c_str());
222 }
223
224 CreateDataPropertyForOptions(isolate, options,
225 isolate->factory()->usage_string(), usage);
226 CreateDataPropertyForOptions(
227 isolate, options, isolate->factory()->sensitivity_string(), sensitivity);
228 CreateDataPropertyForOptions(isolate, options,
229 isolate->factory()->ignorePunctuation_string(),
230 ignore_punctuation);
231 CreateDataPropertyForOptions(
232 isolate, options, isolate->factory()->collation_string(), collation);
233 CreateDataPropertyForOptions(isolate, options,
234 isolate->factory()->numeric_string(), numeric);
235 CreateDataPropertyForOptions(
236 isolate, options, isolate->factory()->caseFirst_string(), case_first);
237 return options;
238}
239
240namespace {
241
242CaseFirst ToCaseFirst(const char* str) {
243 if (strcmp(str, "upper") == 0) return CaseFirst::kUpper;
244 if (strcmp(str, "lower") == 0) return CaseFirst::kLower;
245 if (strcmp(str, "false") == 0) return CaseFirst::kFalse;
246 return CaseFirst::kUndefined;
247}
248
249UColAttributeValue ToUColAttributeValue(CaseFirst case_first) {
250 switch (case_first) {
251 case CaseFirst::kUpper:
252 return UCOL_UPPER_FIRST;
253 case CaseFirst::kLower:
254 return UCOL_LOWER_FIRST;
255 case CaseFirst::kFalse:
256 case CaseFirst::kUndefined:
257 return UCOL_OFF;
258 }
259}
260
261void SetNumericOption(icu::Collator* icu_collator, bool numeric) {
262 DCHECK_NOT_NULL(icu_collator);
263 UErrorCode status = U_ZERO_ERROR;
264 icu_collator->setAttribute(UCOL_NUMERIC_COLLATION,
265 numeric ? UCOL_ON : UCOL_OFF, status);
266 DCHECK(U_SUCCESS(status));
267}
268
269void SetCaseFirstOption(icu::Collator* icu_collator, CaseFirst case_first) {
270 DCHECK_NOT_NULL(icu_collator);
271 UErrorCode status = U_ZERO_ERROR;
272 icu_collator->setAttribute(UCOL_CASE_FIRST, ToUColAttributeValue(case_first),
273 status);
274 DCHECK(U_SUCCESS(status));
275}
276
277} // anonymous namespace
278
279// static
281 DirectHandle<Object> locales,
282 DirectHandle<Object> options_obj,
283 const char* service) {
284 // 1. Let requestedLocales be ? CanonicalizeLocaleList(locales).
285 Maybe<std::vector<std::string>> maybe_requested_locales =
286 Intl::CanonicalizeLocaleList(isolate, locales);
287 MAYBE_RETURN(maybe_requested_locales, Handle<JSCollator>());
288 std::vector<std::string> requested_locales =
289 maybe_requested_locales.FromJust();
290
291 // 2. Set options to ? CoerceOptionsToObject(options).
294 isolate, options, CoerceOptionsToObject(isolate, options_obj, service));
295
296 // 4. Let usage be ? GetOption(options, "usage", "string", « "sort",
297 // "search" », "sort").
299 isolate, options, "usage", service, {"sort", "search"},
300 {Usage::SORT, Usage::SEARCH}, Usage::SORT);
302 Usage usage = maybe_usage.FromJust();
303
304 // 9. Let matcher be ? GetOption(options, "localeMatcher", "string",
305 // « "lookup", "best fit" », "best fit").
306 // 10. Set opt.[[localeMatcher]] to matcher.
307 Maybe<Intl::MatcherOption> maybe_locale_matcher =
308 Intl::GetLocaleMatcher(isolate, options, service);
309 MAYBE_RETURN(maybe_locale_matcher, MaybeHandle<JSCollator>());
310 Intl::MatcherOption matcher = maybe_locale_matcher.FromJust();
311
312 // x. Let _collation_ be ? GetOption(_options_, *"collation"*, *"string"*,
313 // *undefined*, *undefined*).
314 std::unique_ptr<char[]> collation_str = nullptr;
315 const std::vector<const char*> empty_values = {};
316 Maybe<bool> maybe_collation = GetStringOption(
317 isolate, options, "collation", empty_values, service, &collation_str);
318 MAYBE_RETURN(maybe_collation, MaybeHandle<JSCollator>());
319 // x. If _collation_ is not *undefined*, then
320 if (maybe_collation.FromJust() && collation_str != nullptr) {
321 // 1. If _collation_ does not match the Unicode Locale Identifier `type`
322 // nonterminal, throw a *RangeError* exception.
323 if (!JSLocale::Is38AlphaNumList(collation_str.get())) {
325 isolate,
326 NewRangeError(MessageTemplate::kInvalid,
327 isolate->factory()->collation_string(),
328 isolate->factory()->NewStringFromAsciiChecked(
329 collation_str.get())),
331 }
332 }
333 // x. Set _opt_.[[co]] to _collation_.
334
335 // 11. Let numeric be ? GetOption(options, "numeric", "boolean",
336 // undefined, undefined).
337 // 12. If numeric is not undefined, then
338 // a. Let numeric be ! ToString(numeric).
339 //
340 // Note: We omit the ToString(numeric) operation as it's not
341 // observable. GetBoolOption returns a Boolean and
342 // ToString(Boolean) is not side-effecting.
343 //
344 // 13. Set opt.[[kn]] to numeric.
345 bool numeric;
346 Maybe<bool> found_numeric =
347 GetBoolOption(isolate, options, "numeric", service, &numeric);
348 MAYBE_RETURN(found_numeric, MaybeHandle<JSCollator>());
349
350 // 14. Let caseFirst be ? GetOption(options, "caseFirst", "string",
351 // « "upper", "lower", "false" », undefined).
352 Maybe<CaseFirst> maybe_case_first = GetCaseFirst(isolate, options, service);
353 MAYBE_RETURN(maybe_case_first, MaybeHandle<JSCollator>());
354 CaseFirst case_first = maybe_case_first.FromJust();
355
356 // The relevant unicode extensions accepted by Collator as specified here:
357 // https://tc39.github.io/ecma402/#sec-intl-collator-internal-slots
358 //
359 // 16. Let relevantExtensionKeys be %Collator%.[[RelevantExtensionKeys]].
360 std::set<std::string> relevant_extension_keys{"co", "kn", "kf"};
361
362 // 17. Let r be ResolveLocale(%Collator%.[[AvailableLocales]],
363 // requestedLocales, opt, %Collator%.[[RelevantExtensionKeys]],
364 // localeData).
365 Maybe<Intl::ResolvedLocale> maybe_resolve_locale =
367 requested_locales, matcher, relevant_extension_keys);
368 if (maybe_resolve_locale.IsNothing()) {
369 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError));
370 }
371 Intl::ResolvedLocale r = maybe_resolve_locale.FromJust();
372
373 // 18. Set collator.[[Locale]] to r.[[locale]].
374 icu::Locale icu_locale = r.icu_locale;
375 DCHECK(!icu_locale.isBogus());
376
377 // 19. Let collation be r.[[co]].
378 UErrorCode status = U_ZERO_ERROR;
379 if (collation_str != nullptr) {
380 auto co_extension_it = r.extensions.find("co");
381 if (co_extension_it != r.extensions.end() &&
382 co_extension_it->second != collation_str.get()) {
383 icu_locale.setUnicodeKeywordValue("co", nullptr, status);
384 DCHECK(U_SUCCESS(status));
385 }
386 }
387
388 // 5. Set collator.[[Usage]] to usage.
389 //
390 // 6. If usage is "sort", then
391 // a. Let localeData be %Collator%.[[SortLocaleData]].
392 // 7. Else,
393 // a. Let localeData be %Collator%.[[SearchLocaleData]].
394 //
395 // The Intl spec doesn't allow us to use "search" as an extension
396 // value for collation as per:
397 // https://tc39.github.io/ecma402/#sec-intl-collator-internal-slots
398 //
399 // But the only way to pass the value "search" for collation from
400 // the options object to ICU is to use the 'co' extension keyword.
401 //
402 // This will need to be filtered out when creating the
403 // resolvedOptions object.
404 if (usage == Usage::SEARCH) {
405 UErrorCode set_status = U_ZERO_ERROR;
406 icu_locale.setUnicodeKeywordValue("co", "search", set_status);
407 DCHECK(U_SUCCESS(set_status));
408 } else {
409 if (collation_str != nullptr &&
410 Intl::IsValidCollation(icu_locale, collation_str.get())) {
411 icu_locale.setUnicodeKeywordValue("co", collation_str.get(), status);
412 DCHECK(U_SUCCESS(status));
413 }
414 }
415
416 // 20. If collation is null, let collation be "default".
417 // 21. Set collator.[[Collation]] to collation.
418 //
419 // We don't store the collation value as per the above two steps
420 // here. The collation value can be looked up from icu::Collator on
421 // demand, as part of Intl.Collator.prototype.resolvedOptions.
422
423 std::unique_ptr<icu::Collator> icu_collator(
424 icu::Collator::createInstance(icu_locale, status));
425 if (U_FAILURE(status) || icu_collator == nullptr) {
426 status = U_ZERO_ERROR;
427 // Remove extensions and try again.
428 icu::Locale no_extension_locale(icu_locale.getBaseName());
429 icu_collator.reset(
430 icu::Collator::createInstance(no_extension_locale, status));
431
432 if (U_FAILURE(status) || icu_collator == nullptr) {
433 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError));
434 }
435 }
436 DCHECK(U_SUCCESS(status));
437
438 icu::Locale collator_locale(
439 icu_collator->getLocale(ULOC_VALID_LOCALE, status));
440
441 // 22. If relevantExtensionKeys contains "kn", then
442 // a. Set collator.[[Numeric]] to ! SameValue(r.[[kn]], "true").
443 //
444 // If the numeric value is passed in through the options object,
445 // then we use it. Otherwise, we check if the numeric value is
446 // passed in through the unicode extensions.
447 status = U_ZERO_ERROR;
448 if (found_numeric.FromJust()) {
449 SetNumericOption(icu_collator.get(), numeric);
450 } else {
451 auto kn_extension_it = r.extensions.find("kn");
452 if (kn_extension_it != r.extensions.end()) {
453 SetNumericOption(icu_collator.get(), (kn_extension_it->second == "true"));
454 }
455 }
456
457 // 23. If relevantExtensionKeys contains "kf", then
458 // a. Set collator.[[CaseFirst]] to r.[[kf]].
459 //
460 // If the caseFirst value is passed in through the options object,
461 // then we use it. Otherwise, we check if the caseFirst value is
462 // passed in through the unicode extensions.
463 if (case_first != CaseFirst::kUndefined) {
464 SetCaseFirstOption(icu_collator.get(), case_first);
465 } else {
466 auto kf_extension_it = r.extensions.find("kf");
467 if (kf_extension_it != r.extensions.end()) {
468 SetCaseFirstOption(icu_collator.get(),
469 ToCaseFirst(kf_extension_it->second.c_str()));
470 }
471 }
472
473 // Normalization is always on, by the spec. We are free to optimize
474 // if the strings are already normalized (but we don't have a way to tell
475 // that right now).
476 status = U_ZERO_ERROR;
477 icu_collator->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
478 DCHECK(U_SUCCESS(status));
479
480 // 24. Let sensitivity be ? GetOption(options, "sensitivity",
481 // "string", « "base", "accent", "case", "variant" », undefined).
482 Maybe<Sensitivity> maybe_sensitivity =
483 GetStringOption<Sensitivity>(isolate, options, "sensitivity", service,
484 {"base", "accent", "case", "variant"},
485 {Sensitivity::kBase, Sensitivity::kAccent,
486 Sensitivity::kCase, Sensitivity::kVariant},
487 Sensitivity::kUndefined);
488 MAYBE_RETURN(maybe_sensitivity, MaybeHandle<JSCollator>());
489 Sensitivity sensitivity = maybe_sensitivity.FromJust();
490
491 // 25. If sensitivity is undefined, then
492 if (sensitivity == Sensitivity::kUndefined) {
493 // 25. a. If usage is "sort", then
494 if (usage == Usage::SORT) {
495 // 25. a. i. Let sensitivity be "variant".
496 sensitivity = Sensitivity::kVariant;
497 }
498 }
499 // 26. Set collator.[[Sensitivity]] to sensitivity.
500 switch (sensitivity) {
501 case Sensitivity::kBase:
502 icu_collator->setStrength(icu::Collator::PRIMARY);
503 break;
504 case Sensitivity::kAccent:
505 icu_collator->setStrength(icu::Collator::SECONDARY);
506 break;
507 case Sensitivity::kCase:
508 icu_collator->setStrength(icu::Collator::PRIMARY);
509 status = U_ZERO_ERROR;
510 icu_collator->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
511 DCHECK(U_SUCCESS(status));
512 break;
513 case Sensitivity::kVariant:
514 icu_collator->setStrength(icu::Collator::TERTIARY);
515 break;
516 case Sensitivity::kUndefined:
517 break;
518 }
519
520 // 27.Let ignorePunctuation be ? GetOption(options,
521 // "ignorePunctuation", "boolean", undefined, false).
522 bool ignore_punctuation = false;
523 Maybe<bool> found_ignore_punctuation = GetBoolOption(
524 isolate, options, "ignorePunctuation", service, &ignore_punctuation);
525 MAYBE_RETURN(found_ignore_punctuation, MaybeHandle<JSCollator>());
526
527 // 28. Set collator.[[IgnorePunctuation]] to ignorePunctuation.
528
529 // Note: The following implementation does not strictly follow the spec text
530 // due to https://github.com/tc39/ecma402/issues/832
531 // If the ignorePunctuation is not defined, instead of fall back
532 // to default false, we just depend on ICU to default based on the
533 // built in locale collation rule, which in "th" locale that is true
534 // but false on other locales.
535 if (found_ignore_punctuation.FromJust()) {
536 status = U_ZERO_ERROR;
537 icu_collator->setAttribute(
538 UCOL_ALTERNATE_HANDLING,
539 ignore_punctuation ? UCOL_SHIFTED : UCOL_NON_IGNORABLE, status);
540 DCHECK(U_SUCCESS(status));
541 }
542
543 DirectHandle<Managed<icu::Collator>> managed_collator =
544 Managed<icu::Collator>::From(isolate, 0, std::move(icu_collator));
545
546 // We only need to do so if it is different from the collator would return.
547 DirectHandle<String> locale_str =
548 isolate->factory()->NewStringFromAsciiChecked(
549 (collator_locale != icu_locale) ? r.locale.c_str() : "");
550 // Now all properties are ready, so we can allocate the result object.
551 Handle<JSCollator> collator =
552 Cast<JSCollator>(isolate->factory()->NewFastOrSlowJSObjectFromMap(map));
554 collator->set_icu_collator(*managed_collator);
555 collator->set_locale(*locale_str);
556
557 // 29. Return collator.
558 return collator;
559}
560
561namespace {
562
563class CollatorAvailableLocales {
564 public:
565 CollatorAvailableLocales() {
566 int32_t num_locales = 0;
567 const icu::Locale* icu_available_locales =
568 icu::Collator::getAvailableLocales(num_locales);
569 std::vector<std::string> locales;
570 locales.reserve(num_locales);
571 for (int32_t i = 0; i < num_locales; ++i) {
572 locales.push_back(
573 Intl::ToLanguageTag(icu_available_locales[i]).FromJust());
574 }
575#define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
576 set_ = Intl::BuildLocaleSet(locales, U_ICUDATA_COLL, nullptr);
577#undef U_ICUDATA_COLL
578 }
579 virtual ~CollatorAvailableLocales() = default;
580 const std::set<std::string>& Get() const { return set_; }
581
582 private:
583 std::set<std::string> set_;
584};
585
586} // namespace
587
588const std::set<std::string>& JSCollator::GetAvailableLocales() {
591 return available_locales.Pointer()->Get();
592}
593
594} // namespace internal
595} // namespace v8
V8_INLINE T FromJust() const &
Definition v8-maybe.h:64
V8_INLINE bool IsNothing() const
Definition v8-maybe.h:35
static Maybe< std::vector< std::string > > CanonicalizeLocaleList(Isolate *isolate, DirectHandle< Object > locales, bool only_return_one_result=false)
static bool IsValidCollation(const icu::Locale &locale, const std::string &value)
static Maybe< ResolvedLocale > ResolveLocale(Isolate *isolate, const std::set< std::string > &available_locales, const std::vector< std::string > &requested_locales, MatcherOption options, const std::set< std::string > &relevant_extension_keys)
static std::set< std::string > BuildLocaleSet(const std::vector< std::string > &locales, const char *path, const char *validate_key)
static V8_WARN_UNUSED_RESULT Maybe< MatcherOption > GetLocaleMatcher(Isolate *isolate, DirectHandle< JSReceiver > options, const char *method_name)
static Maybe< std::string > ToLanguageTag(const icu::Locale &locale)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< JSCollator > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options, const char *service)
static DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSCollator > collator)
static bool Is38AlphaNumList(const std::string &value)
Definition js-locale.cc:206
static V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > key, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
static DirectHandle< Managed< CppType > > From(Isolate *isolate, size_t estimated_size, std::shared_ptr< CppType > shared_ptr, AllocationType allocation_type=AllocationType::kYoung)
Definition managed-inl.h:27
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
Definition isolate.h:300
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:291
#define THROW_NEW_ERROR(isolate, call)
Definition isolate.h:307
#define MAYBE_RETURN(call, value)
Definition isolate.h:408
#define U_ICUDATA_COLL
DirectHandle< JSReceiver > options
#define LAZY_INSTANCE_INITIALIZER
ZoneVector< InstructionOperand > * set_
int r
Definition mul-fft.cc:298
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
Definition graph.h:1231
static constexpr uint32_t kFalse
V8_WARN_UNUSED_RESULT Maybe< bool > GetBoolOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const char *method_name, bool *result)
MaybeDirectHandle< JSReceiver > CoerceOptionsToObject(Isolate *isolate, DirectHandle< Object > options, const char *method_name)
Maybe< bool > GetStringOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const std::vector< const char * > &values, const char *method_name, std::unique_ptr< char[]> *result)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
Maybe< T > Just(const T &t)
Definition v8-maybe.h:117
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK(condition)
Definition logging.h:482
#define USE(...)
Definition macros.h:293
typename LazyStaticInstance< T, CreateTrait, InitOnceTrait, DestroyTrait >::type type