5 #ifndef V8_INTL_SUPPORT 6 #error Internationalization is expected to be enabled. 7 #endif // V8_INTL_SUPPORT 12 #include "src/api-inl.h" 13 #include "src/api-natives.h" 14 #include "src/arguments-inl.h" 15 #include "src/counters.h" 17 #include "src/global-handles.h" 18 #include "src/heap/factory.h" 19 #include "src/isolate-inl.h" 20 #include "src/objects/intl-objects.h" 21 #include "src/objects/js-array-inl.h" 22 #include "src/objects/js-collator-inl.h" 23 #include "src/objects/js-date-time-format-inl.h" 24 #include "src/objects/js-list-format-inl.h" 25 #include "src/objects/js-list-format.h" 26 #include "src/objects/js-number-format-inl.h" 27 #include "src/objects/js-plural-rules-inl.h" 28 #include "src/objects/managed.h" 29 #include "src/runtime/runtime-utils.h" 30 #include "src/utils.h" 36 RUNTIME_FUNCTION(Runtime_FormatList) {
37 HandleScope scope(isolate);
38 DCHECK_EQ(2, args.length());
39 CONVERT_ARG_HANDLE_CHECKED(JSListFormat, list_format, 0);
40 CONVERT_ARG_HANDLE_CHECKED(JSArray, list, 1);
41 RETURN_RESULT_OR_FAILURE(
42 isolate, JSListFormat::FormatList(isolate, list_format, list));
46 RUNTIME_FUNCTION(Runtime_FormatListToParts) {
47 HandleScope scope(isolate);
48 DCHECK_EQ(2, args.length());
49 CONVERT_ARG_HANDLE_CHECKED(JSListFormat, list_format, 0);
50 CONVERT_ARG_HANDLE_CHECKED(JSArray, list, 1);
51 RETURN_RESULT_OR_FAILURE(
52 isolate, JSListFormat::FormatListToParts(isolate, list_format, list));
56 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
57 HandleScope scope(isolate);
59 DCHECK_EQ(1, args.length());
60 CONVERT_ARG_HANDLE_CHECKED(Object, locale, 0);
62 std::string canonicalized;
63 if (!Intl::CanonicalizeLanguageTag(isolate, locale).To(&canonicalized)) {
64 return ReadOnlyRoots(isolate).exception();
66 return *isolate->factory()->NewStringFromAsciiChecked(canonicalized.c_str());
69 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
70 HandleScope scope(isolate);
72 DCHECK_EQ(0, args.length());
73 return *isolate->factory()->NewStringFromAsciiChecked(
74 Intl::DefaultLocale(isolate).c_str());
77 RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) {
78 HandleScope scope(isolate);
79 DCHECK_EQ(args.length(), 1);
80 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
81 s = String::Flatten(isolate, s);
82 RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToLower(isolate, s));
85 RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) {
86 HandleScope scope(isolate);
87 DCHECK_EQ(args.length(), 1);
88 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
89 s = String::Flatten(isolate, s);
90 RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToUpper(isolate, s));