31 #include "unicode/brkiter.h"
32 #include "unicode/calendar.h"
33 #include "unicode/coll.h"
34 #include "unicode/curramt.h"
35 #include "unicode/dcfmtsym.h"
36 #include "unicode/decimfmt.h"
37 #include "unicode/dtfmtsym.h"
38 #include "unicode/dtptngen.h"
39 #include "unicode/locid.h"
40 #include "unicode/numfmt.h"
41 #include "unicode/numsys.h"
42 #include "unicode/rbbi.h"
43 #include "unicode/smpdtfmt.h"
44 #include "unicode/timezone.h"
45 #include "unicode/uchar.h"
46 #include "unicode/ucol.h"
47 #include "unicode/ucurr.h"
48 #include "unicode/unum.h"
49 #include "unicode/uversion.h"
56 bool ExtractStringSetting(Isolate* isolate,
57 Handle<JSObject> options,
59 icu::UnicodeString* setting) {
60 Handle<String> str = isolate->factory()->NewStringFromAscii(
CStrVector(key));
61 MaybeObject* maybe_object = options->GetProperty(*str);
63 if (maybe_object->ToObject(&
object) &&
object->IsString()) {
66 *setting = icu::UnicodeString::fromUTF8(*utf8_string);
73 bool ExtractIntegerSetting(Isolate* isolate,
74 Handle<JSObject> options,
77 Handle<String> str = isolate->factory()->NewStringFromAscii(
CStrVector(key));
78 MaybeObject* maybe_object = options->GetProperty(*str);
80 if (maybe_object->ToObject(&
object) &&
object->IsNumber()) {
81 object->ToInt32(value);
88 bool ExtractBooleanSetting(Isolate* isolate,
89 Handle<JSObject> options,
92 Handle<String> str = isolate->factory()->NewStringFromAscii(
CStrVector(key));
93 MaybeObject* maybe_object = options->GetProperty(*str);
95 if (maybe_object->ToObject(&
object) &&
object->IsBoolean()) {
96 *value =
object->BooleanValue();
103 icu::SimpleDateFormat* CreateICUDateFormat(
105 const icu::Locale& icu_locale,
106 Handle<JSObject> options) {
109 icu::TimeZone* tz =
NULL;
110 icu::UnicodeString timezone;
111 if (ExtractStringSetting(isolate, options,
"timeZone", &timezone)) {
112 tz = icu::TimeZone::createTimeZone(timezone);
114 tz = icu::TimeZone::createDefault();
118 UErrorCode status = U_ZERO_ERROR;
119 icu::Calendar* calendar =
120 icu::Calendar::createInstance(tz, icu_locale, status);
124 icu::SimpleDateFormat* date_format =
NULL;
125 icu::UnicodeString skeleton;
126 if (ExtractStringSetting(isolate, options,
"skeleton", &skeleton)) {
127 icu::DateTimePatternGenerator* generator =
128 icu::DateTimePatternGenerator::createInstance(icu_locale, status);
129 icu::UnicodeString pattern;
130 if (U_SUCCESS(status)) {
131 pattern = generator->getBestPattern(skeleton, status);
135 date_format =
new icu::SimpleDateFormat(pattern, icu_locale, status);
136 if (U_SUCCESS(status)) {
137 date_format->adoptCalendar(calendar);
141 if (U_FAILURE(status)) {
151 void SetResolvedDateSettings(Isolate* isolate,
152 const icu::Locale& icu_locale,
153 icu::SimpleDateFormat* date_format,
154 Handle<JSObject> resolved) {
155 UErrorCode status = U_ZERO_ERROR;
156 icu::UnicodeString pattern;
157 date_format->toPattern(pattern);
160 isolate->factory()->NewStringFromAscii(
CStrVector(
"pattern")),
161 isolate->factory()->NewStringFromTwoByte(
162 Vector<const uint16_t>(
163 reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
169 const icu::Calendar* calendar = date_format->getCalendar();
170 const char* calendar_name = calendar->getType();
173 isolate->factory()->NewStringFromAscii(
CStrVector(
"calendar")),
174 isolate->factory()->NewStringFromAscii(
CStrVector(calendar_name)),
178 const icu::TimeZone& tz = calendar->getTimeZone();
179 icu::UnicodeString time_zone;
182 icu::UnicodeString canonical_time_zone;
183 icu::TimeZone::getCanonicalID(time_zone, canonical_time_zone, status);
184 if (U_SUCCESS(status)) {
185 if (canonical_time_zone == UNICODE_STRING_SIMPLE(
"Etc/GMT")) {
188 isolate->factory()->NewStringFromAscii(
CStrVector(
"timeZone")),
189 isolate->factory()->NewStringFromAscii(
CStrVector(
"UTC")),
195 isolate->factory()->NewStringFromAscii(
CStrVector(
"timeZone")),
196 isolate->factory()->NewStringFromTwoByte(
197 Vector<const uint16_t>(
198 reinterpret_cast<const uint16_t*>(
199 canonical_time_zone.getBuffer()),
200 canonical_time_zone.length())),
209 status = U_ZERO_ERROR;
210 icu::NumberingSystem* numbering_system =
211 icu::NumberingSystem::createInstance(icu_locale, status);
212 if (U_SUCCESS(status)) {
213 const char* ns = numbering_system->getName();
216 isolate->factory()->NewStringFromAscii(
CStrVector(
"numberingSystem")),
217 isolate->factory()->NewStringFromAscii(
CStrVector(ns)),
223 isolate->factory()->NewStringFromAscii(
CStrVector(
"numberingSystem")),
224 isolate->factory()->undefined_value(),
228 delete numbering_system;
231 char result[ULOC_FULLNAME_CAPACITY];
232 status = U_ZERO_ERROR;
234 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
235 if (U_SUCCESS(status)) {
238 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
239 isolate->factory()->NewStringFromAscii(
CStrVector(result)),
246 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
247 isolate->factory()->NewStringFromAscii(
CStrVector(
"und")),
254 template<
int internal_fields, EternalHandles::SingletonHandle field>
255 Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) {
256 if (isolate->eternal_handles()->Exists(field)) {
258 isolate->eternal_handles()->GetSingleton(field));
264 isolate->eternal_handles()->CreateSingleton(
271 icu::DecimalFormat* CreateICUNumberFormat(
273 const icu::Locale& icu_locale,
274 Handle<JSObject> options) {
277 UErrorCode status = U_ZERO_ERROR;
278 icu::DecimalFormat* number_format =
NULL;
279 icu::UnicodeString style;
280 icu::UnicodeString currency;
281 if (ExtractStringSetting(isolate, options,
"style", &style)) {
282 if (style == UNICODE_STRING_SIMPLE(
"currency")) {
283 icu::UnicodeString display;
284 ExtractStringSetting(isolate, options,
"currency", ¤cy);
285 ExtractStringSetting(isolate, options,
"currencyDisplay", &display);
287 #if (U_ICU_VERSION_MAJOR_NUM == 4) && (U_ICU_VERSION_MINOR_NUM <= 6)
288 icu::NumberFormat::EStyles format_style;
289 if (display == UNICODE_STRING_SIMPLE(
"code")) {
290 format_style = icu::NumberFormat::kIsoCurrencyStyle;
291 }
else if (display == UNICODE_STRING_SIMPLE(
"name")) {
292 format_style = icu::NumberFormat::kPluralCurrencyStyle;
294 format_style = icu::NumberFormat::kCurrencyStyle;
296 #else // ICU version is 4.8 or above (we ignore versions below 4.0).
297 UNumberFormatStyle format_style;
298 if (display == UNICODE_STRING_SIMPLE(
"code")) {
299 format_style = UNUM_CURRENCY_ISO;
300 }
else if (display == UNICODE_STRING_SIMPLE(
"name")) {
301 format_style = UNUM_CURRENCY_PLURAL;
303 format_style = UNUM_CURRENCY;
307 number_format =
static_cast<icu::DecimalFormat*
>(
308 icu::NumberFormat::createInstance(icu_locale, format_style, status));
309 }
else if (style == UNICODE_STRING_SIMPLE(
"percent")) {
310 number_format =
static_cast<icu::DecimalFormat*
>(
311 icu::NumberFormat::createPercentInstance(icu_locale, status));
312 if (U_FAILURE(status)) {
313 delete number_format;
317 number_format->setMinimumFractionDigits(1);
320 number_format =
static_cast<icu::DecimalFormat*
>(
321 icu::NumberFormat::createInstance(icu_locale, status));
325 if (U_FAILURE(status)) {
326 delete number_format;
331 if (!currency.isEmpty()) {
332 number_format->setCurrency(currency.getBuffer(), status);
336 if (ExtractIntegerSetting(
337 isolate, options,
"minimumIntegerDigits", &digits)) {
338 number_format->setMinimumIntegerDigits(digits);
341 if (ExtractIntegerSetting(
342 isolate, options,
"minimumFractionDigits", &digits)) {
343 number_format->setMinimumFractionDigits(digits);
346 if (ExtractIntegerSetting(
347 isolate, options,
"maximumFractionDigits", &digits)) {
348 number_format->setMaximumFractionDigits(digits);
351 bool significant_digits_used =
false;
352 if (ExtractIntegerSetting(
353 isolate, options,
"minimumSignificantDigits", &digits)) {
354 number_format->setMinimumSignificantDigits(digits);
355 significant_digits_used =
true;
358 if (ExtractIntegerSetting(
359 isolate, options,
"maximumSignificantDigits", &digits)) {
360 number_format->setMaximumSignificantDigits(digits);
361 significant_digits_used =
true;
364 number_format->setSignificantDigitsUsed(significant_digits_used);
367 if (ExtractBooleanSetting(isolate, options,
"useGrouping", &grouping)) {
368 number_format->setGroupingUsed(grouping);
372 number_format->setRoundingMode(icu::DecimalFormat::kRoundHalfUp);
374 return number_format;
378 void SetResolvedNumberSettings(Isolate* isolate,
379 const icu::Locale& icu_locale,
380 icu::DecimalFormat* number_format,
381 Handle<JSObject> resolved) {
382 icu::UnicodeString pattern;
383 number_format->toPattern(pattern);
386 isolate->factory()->NewStringFromAscii(
CStrVector(
"pattern")),
387 isolate->factory()->NewStringFromTwoByte(
388 Vector<const uint16_t>(
389 reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
395 icu::UnicodeString currency(number_format->getCurrency());
396 if (!currency.isEmpty()) {
399 isolate->factory()->NewStringFromAscii(
CStrVector(
"currency")),
400 isolate->factory()->NewStringFromTwoByte(
401 Vector<const uint16_t>(
402 reinterpret_cast<const uint16_t*>(currency.getBuffer()),
411 UErrorCode status = U_ZERO_ERROR;
412 icu::NumberingSystem* numbering_system =
413 icu::NumberingSystem::createInstance(icu_locale, status);
414 if (U_SUCCESS(status)) {
415 const char* ns = numbering_system->getName();
418 isolate->factory()->NewStringFromAscii(
CStrVector(
"numberingSystem")),
419 isolate->factory()->NewStringFromAscii(
CStrVector(ns)),
425 isolate->factory()->NewStringFromAscii(
CStrVector(
"numberingSystem")),
426 isolate->factory()->undefined_value(),
430 delete numbering_system;
434 isolate->factory()->NewStringFromAscii(
CStrVector(
"useGrouping")),
435 isolate->factory()->ToBoolean(number_format->isGroupingUsed()),
441 isolate->factory()->NewStringFromAscii(
443 isolate->factory()->NewNumberFromInt(
444 number_format->getMinimumIntegerDigits()),
450 isolate->factory()->NewStringFromAscii(
452 isolate->factory()->NewNumberFromInt(
453 number_format->getMinimumFractionDigits()),
459 isolate->factory()->NewStringFromAscii(
461 isolate->factory()->NewNumberFromInt(
462 number_format->getMaximumFractionDigits()),
466 Handle<String> key = isolate->factory()->NewStringFromAscii(
471 isolate->factory()->NewStringFromAscii(
473 isolate->factory()->NewNumberFromInt(
474 number_format->getMinimumSignificantDigits()),
479 key = isolate->factory()->NewStringFromAscii(
484 isolate->factory()->NewStringFromAscii(
486 isolate->factory()->NewNumberFromInt(
487 number_format->getMaximumSignificantDigits()),
493 char result[ULOC_FULLNAME_CAPACITY];
494 status = U_ZERO_ERROR;
496 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
497 if (U_SUCCESS(status)) {
500 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
501 isolate->factory()->NewStringFromAscii(
CStrVector(result)),
508 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
509 isolate->factory()->NewStringFromAscii(
CStrVector(
"und")),
516 icu::Collator* CreateICUCollator(
518 const icu::Locale& icu_locale,
519 Handle<JSObject> options) {
521 icu::Collator* collator =
NULL;
522 UErrorCode status = U_ZERO_ERROR;
523 collator = icu::Collator::createInstance(icu_locale, status);
525 if (U_FAILURE(status)) {
532 if (ExtractBooleanSetting(isolate, options,
"numeric", &numeric)) {
533 collator->setAttribute(
534 UCOL_NUMERIC_COLLATION, numeric ? UCOL_ON : UCOL_OFF, status);
540 collator->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
542 icu::UnicodeString case_first;
543 if (ExtractStringSetting(isolate, options,
"caseFirst", &case_first)) {
544 if (case_first == UNICODE_STRING_SIMPLE(
"upper")) {
545 collator->setAttribute(UCOL_CASE_FIRST, UCOL_UPPER_FIRST, status);
546 }
else if (case_first == UNICODE_STRING_SIMPLE(
"lower")) {
547 collator->setAttribute(UCOL_CASE_FIRST, UCOL_LOWER_FIRST, status);
550 collator->setAttribute(UCOL_CASE_FIRST, UCOL_OFF, status);
554 icu::UnicodeString sensitivity;
555 if (ExtractStringSetting(isolate, options,
"sensitivity", &sensitivity)) {
556 if (sensitivity == UNICODE_STRING_SIMPLE(
"base")) {
557 collator->setStrength(icu::Collator::PRIMARY);
558 }
else if (sensitivity == UNICODE_STRING_SIMPLE(
"accent")) {
559 collator->setStrength(icu::Collator::SECONDARY);
560 }
else if (sensitivity == UNICODE_STRING_SIMPLE(
"case")) {
561 collator->setStrength(icu::Collator::PRIMARY);
562 collator->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
565 collator->setStrength(icu::Collator::TERTIARY);
570 if (ExtractBooleanSetting(isolate, options,
"ignorePunctuation", &ignore)) {
572 collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, status);
580 void SetResolvedCollatorSettings(Isolate* isolate,
581 const icu::Locale& icu_locale,
582 icu::Collator* collator,
583 Handle<JSObject> resolved) {
584 UErrorCode status = U_ZERO_ERROR;
588 isolate->factory()->NewStringFromAscii(
CStrVector(
"numeric")),
589 isolate->factory()->ToBoolean(
590 collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON),
594 switch (collator->getAttribute(UCOL_CASE_FIRST, status)) {
595 case UCOL_LOWER_FIRST:
598 isolate->factory()->NewStringFromAscii(
CStrVector(
"caseFirst")),
599 isolate->factory()->NewStringFromAscii(
CStrVector(
"lower")),
603 case UCOL_UPPER_FIRST:
606 isolate->factory()->NewStringFromAscii(
CStrVector(
"caseFirst")),
607 isolate->factory()->NewStringFromAscii(
CStrVector(
"upper")),
614 isolate->factory()->NewStringFromAscii(
CStrVector(
"caseFirst")),
615 isolate->factory()->NewStringFromAscii(
CStrVector(
"false")),
620 switch (collator->getAttribute(UCOL_STRENGTH, status)) {
624 isolate->factory()->NewStringFromAscii(
CStrVector(
"strength")),
625 isolate->factory()->NewStringFromAscii(
CStrVector(
"primary")),
630 if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) {
633 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
634 isolate->factory()->NewStringFromAscii(
CStrVector(
"case")),
640 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
641 isolate->factory()->NewStringFromAscii(
CStrVector(
"base")),
650 isolate->factory()->NewStringFromAscii(
CStrVector(
"strength")),
651 isolate->factory()->NewStringFromAscii(
CStrVector(
"secondary")),
656 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
657 isolate->factory()->NewStringFromAscii(
CStrVector(
"accent")),
664 isolate->factory()->NewStringFromAscii(
CStrVector(
"strength")),
665 isolate->factory()->NewStringFromAscii(
CStrVector(
"tertiary")),
670 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
671 isolate->factory()->NewStringFromAscii(
CStrVector(
"variant")),
675 case UCOL_QUATERNARY:
680 isolate->factory()->NewStringFromAscii(
CStrVector(
"strength")),
681 isolate->factory()->NewStringFromAscii(
CStrVector(
"quaternary")),
686 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
687 isolate->factory()->NewStringFromAscii(
CStrVector(
"variant")),
694 isolate->factory()->NewStringFromAscii(
CStrVector(
"strength")),
695 isolate->factory()->NewStringFromAscii(
CStrVector(
"identical")),
700 isolate->factory()->NewStringFromAscii(
CStrVector(
"sensitivity")),
701 isolate->factory()->NewStringFromAscii(
CStrVector(
"variant")),
708 isolate->factory()->NewStringFromAscii(
CStrVector(
"ignorePunctuation")),
709 isolate->factory()->ToBoolean(collator->getAttribute(
710 UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED),
715 char result[ULOC_FULLNAME_CAPACITY];
716 status = U_ZERO_ERROR;
718 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
719 if (U_SUCCESS(status)) {
722 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
723 isolate->factory()->NewStringFromAscii(
CStrVector(result)),
730 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
731 isolate->factory()->NewStringFromAscii(
CStrVector(
"und")),
738 icu::BreakIterator* CreateICUBreakIterator(
740 const icu::Locale& icu_locale,
741 Handle<JSObject> options) {
742 UErrorCode status = U_ZERO_ERROR;
743 icu::BreakIterator* break_iterator =
NULL;
744 icu::UnicodeString type;
745 if (!ExtractStringSetting(isolate, options,
"type", &type))
return NULL;
747 if (type == UNICODE_STRING_SIMPLE(
"character")) {
749 icu::BreakIterator::createCharacterInstance(icu_locale, status);
750 }
else if (type == UNICODE_STRING_SIMPLE(
"sentence")) {
752 icu::BreakIterator::createSentenceInstance(icu_locale, status);
753 }
else if (type == UNICODE_STRING_SIMPLE(
"line")) {
755 icu::BreakIterator::createLineInstance(icu_locale, status);
759 icu::BreakIterator::createWordInstance(icu_locale, status);
762 if (U_FAILURE(status)) {
763 delete break_iterator;
767 return break_iterator;
771 void SetResolvedBreakIteratorSettings(Isolate* isolate,
772 const icu::Locale& icu_locale,
773 icu::BreakIterator* break_iterator,
774 Handle<JSObject> resolved) {
775 UErrorCode status = U_ZERO_ERROR;
778 char result[ULOC_FULLNAME_CAPACITY];
779 status = U_ZERO_ERROR;
781 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
782 if (U_SUCCESS(status)) {
785 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
786 isolate->factory()->NewStringFromAscii(
CStrVector(result)),
793 isolate->factory()->NewStringFromAscii(
CStrVector(
"locale")),
794 isolate->factory()->NewStringFromAscii(
CStrVector(
"und")),
805 return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate);
811 return GetEternal<2, i::EternalHandles::I18N_TEMPLATE_TWO>(isolate);
822 UErrorCode status = U_ZERO_ERROR;
823 icu::Locale icu_locale;
824 char icu_result[ULOC_FULLNAME_CAPACITY];
827 if (bcp47_locale.
length() != 0) {
828 uloc_forLanguageTag(*bcp47_locale, icu_result, ULOC_FULLNAME_CAPACITY,
829 &icu_length, &status);
830 if (U_FAILURE(status) || icu_length == 0) {
833 icu_locale = icu::Locale(icu_result);
836 icu::SimpleDateFormat* date_format = CreateICUDateFormat(
837 isolate, icu_locale, options);
840 icu::Locale no_extension_locale(icu_locale.getBaseName());
841 date_format = CreateICUDateFormat(isolate, no_extension_locale, options);
844 SetResolvedDateSettings(
845 isolate, no_extension_locale, date_format, resolved);
847 SetResolvedDateSettings(isolate, icu_locale, date_format, resolved);
860 return reinterpret_cast<icu::SimpleDateFormat*
>(
861 obj->GetInternalField(0));
876 static void DestroyGlobalHandle(
884 DeleteNativeObjectAt<icu::SimpleDateFormat>(data, 0);
885 DestroyGlobalHandle(data);
895 UErrorCode status = U_ZERO_ERROR;
896 icu::Locale icu_locale;
897 char icu_result[ULOC_FULLNAME_CAPACITY];
900 if (bcp47_locale.
length() != 0) {
901 uloc_forLanguageTag(*bcp47_locale, icu_result, ULOC_FULLNAME_CAPACITY,
902 &icu_length, &status);
903 if (U_FAILURE(status) || icu_length == 0) {
906 icu_locale = icu::Locale(icu_result);
909 icu::DecimalFormat* number_format =
910 CreateICUNumberFormat(isolate, icu_locale, options);
911 if (!number_format) {
913 icu::Locale no_extension_locale(icu_locale.getBaseName());
914 number_format = CreateICUNumberFormat(
915 isolate, no_extension_locale, options);
918 SetResolvedNumberSettings(
919 isolate, no_extension_locale, number_format, resolved);
921 SetResolvedNumberSettings(isolate, icu_locale, number_format, resolved);
924 return number_format;
934 return reinterpret_cast<icu::DecimalFormat*
>(obj->GetInternalField(0));
943 DeleteNativeObjectAt<icu::DecimalFormat>(data, 0);
944 DestroyGlobalHandle(data);
954 UErrorCode status = U_ZERO_ERROR;
955 icu::Locale icu_locale;
956 char icu_result[ULOC_FULLNAME_CAPACITY];
959 if (bcp47_locale.
length() != 0) {
960 uloc_forLanguageTag(*bcp47_locale, icu_result, ULOC_FULLNAME_CAPACITY,
961 &icu_length, &status);
962 if (U_FAILURE(status) || icu_length == 0) {
965 icu_locale = icu::Locale(icu_result);
968 icu::Collator* collator = CreateICUCollator(isolate, icu_locale, options);
971 icu::Locale no_extension_locale(icu_locale.getBaseName());
972 collator = CreateICUCollator(isolate, no_extension_locale, options);
975 SetResolvedCollatorSettings(
976 isolate, no_extension_locale, collator, resolved);
978 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved);
990 return reinterpret_cast<icu::Collator*
>(obj->GetInternalField(0));
999 DeleteNativeObjectAt<icu::Collator>(data, 0);
1000 DestroyGlobalHandle(data);
1010 UErrorCode status = U_ZERO_ERROR;
1011 icu::Locale icu_locale;
1012 char icu_result[ULOC_FULLNAME_CAPACITY];
1015 if (bcp47_locale.
length() != 0) {
1016 uloc_forLanguageTag(*bcp47_locale, icu_result, ULOC_FULLNAME_CAPACITY,
1017 &icu_length, &status);
1018 if (U_FAILURE(status) || icu_length == 0) {
1021 icu_locale = icu::Locale(icu_result);
1024 icu::BreakIterator* break_iterator = CreateICUBreakIterator(
1025 isolate, icu_locale, options);
1026 if (!break_iterator) {
1028 icu::Locale no_extension_locale(icu_locale.getBaseName());
1029 break_iterator = CreateICUBreakIterator(
1030 isolate, no_extension_locale, options);
1033 SetResolvedBreakIteratorSettings(
1034 isolate, no_extension_locale, break_iterator, resolved);
1036 SetResolvedBreakIteratorSettings(
1037 isolate, icu_locale, break_iterator, resolved);
1040 return break_iterator;
1049 return reinterpret_cast<icu::BreakIterator*
>(obj->GetInternalField(0));
1058 DeleteNativeObjectAt<icu::BreakIterator>(data, 0);
1059 DeleteNativeObjectAt<icu::UnicodeString>(data, 1);
1060 DestroyGlobalHandle(data);
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static void Destroy(Object **location)
static String * cast(Object *obj)
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
static Handle< ObjectTemplateInfo > GetTemplate(Isolate *isolate)
static Handle< T > cast(Handle< S > that)
Handle< String > NewStringFromAscii(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
kSerializedDataOffset Object
static void DeleteCollator(const v8::WeakCallbackData< v8::Value, void > &data)
V8_INLINE Local< T > GetValue() const
static void DeleteBreakIterator(const v8::WeakCallbackData< v8::Value, void > &data)
static icu::BreakIterator * InitializeBreakIterator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
static Handle< ObjectTemplateInfo > GetTemplate2(Isolate *isolate)
static Local< ObjectTemplate > New()
void DeleteNativeObjectAt(const v8::WeakCallbackData< v8::Value, void > &data, int index)
static icu::Collator * UnpackCollator(Isolate *isolate, Handle< JSObject > obj)
void SetInternalFieldCount(int value)
static V8_INLINE Handle< T > Cast(Handle< S > that)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Vector< const char > CStrVector(const char *data)
V8_INLINE P * GetParameter() const
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
#define T(name, string, precedence)
static icu::BreakIterator * UnpackBreakIterator(Isolate *isolate, Handle< JSObject > obj)
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
static icu::Collator * InitializeCollator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
static bool HasLocalProperty(Handle< JSReceiver >, Handle< Name > name)