OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 icu::UnicodeString pattern; | 156 icu::UnicodeString pattern; |
157 date_format->toPattern(pattern); | 157 date_format->toPattern(pattern); |
158 JSObject::SetProperty( | 158 JSObject::SetProperty( |
159 resolved, | 159 resolved, |
160 isolate->factory()->NewStringFromAscii(CStrVector("pattern")), | 160 isolate->factory()->NewStringFromAscii(CStrVector("pattern")), |
161 isolate->factory()->NewStringFromTwoByte( | 161 isolate->factory()->NewStringFromTwoByte( |
162 Vector<const uint16_t>( | 162 Vector<const uint16_t>( |
163 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), | 163 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), |
164 pattern.length())), | 164 pattern.length())), |
165 NONE, | 165 NONE, |
166 kSloppyMode); | 166 SLOPPY); |
167 | 167 |
168 // Set time zone and calendar. | 168 // Set time zone and calendar. |
169 const icu::Calendar* calendar = date_format->getCalendar(); | 169 const icu::Calendar* calendar = date_format->getCalendar(); |
170 const char* calendar_name = calendar->getType(); | 170 const char* calendar_name = calendar->getType(); |
171 JSObject::SetProperty( | 171 JSObject::SetProperty( |
172 resolved, | 172 resolved, |
173 isolate->factory()->NewStringFromAscii(CStrVector("calendar")), | 173 isolate->factory()->NewStringFromAscii(CStrVector("calendar")), |
174 isolate->factory()->NewStringFromAscii(CStrVector(calendar_name)), | 174 isolate->factory()->NewStringFromAscii(CStrVector(calendar_name)), |
175 NONE, | 175 NONE, |
176 kSloppyMode); | 176 SLOPPY); |
177 | 177 |
178 const icu::TimeZone& tz = calendar->getTimeZone(); | 178 const icu::TimeZone& tz = calendar->getTimeZone(); |
179 icu::UnicodeString time_zone; | 179 icu::UnicodeString time_zone; |
180 tz.getID(time_zone); | 180 tz.getID(time_zone); |
181 | 181 |
182 icu::UnicodeString canonical_time_zone; | 182 icu::UnicodeString canonical_time_zone; |
183 icu::TimeZone::getCanonicalID(time_zone, canonical_time_zone, status); | 183 icu::TimeZone::getCanonicalID(time_zone, canonical_time_zone, status); |
184 if (U_SUCCESS(status)) { | 184 if (U_SUCCESS(status)) { |
185 if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) { | 185 if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) { |
186 JSObject::SetProperty( | 186 JSObject::SetProperty( |
187 resolved, | 187 resolved, |
188 isolate->factory()->NewStringFromAscii(CStrVector("timeZone")), | 188 isolate->factory()->NewStringFromAscii(CStrVector("timeZone")), |
189 isolate->factory()->NewStringFromAscii(CStrVector("UTC")), | 189 isolate->factory()->NewStringFromAscii(CStrVector("UTC")), |
190 NONE, | 190 NONE, |
191 kSloppyMode); | 191 SLOPPY); |
192 } else { | 192 } else { |
193 JSObject::SetProperty( | 193 JSObject::SetProperty( |
194 resolved, | 194 resolved, |
195 isolate->factory()->NewStringFromAscii(CStrVector("timeZone")), | 195 isolate->factory()->NewStringFromAscii(CStrVector("timeZone")), |
196 isolate->factory()->NewStringFromTwoByte( | 196 isolate->factory()->NewStringFromTwoByte( |
197 Vector<const uint16_t>( | 197 Vector<const uint16_t>( |
198 reinterpret_cast<const uint16_t*>( | 198 reinterpret_cast<const uint16_t*>( |
199 canonical_time_zone.getBuffer()), | 199 canonical_time_zone.getBuffer()), |
200 canonical_time_zone.length())), | 200 canonical_time_zone.length())), |
201 NONE, | 201 NONE, |
202 kSloppyMode); | 202 SLOPPY); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 // Ugly hack. ICU doesn't expose numbering system in any way, so we have | 206 // Ugly hack. ICU doesn't expose numbering system in any way, so we have |
207 // to assume that for given locale NumberingSystem constructor produces the | 207 // to assume that for given locale NumberingSystem constructor produces the |
208 // same digits as NumberFormat/Calendar would. | 208 // same digits as NumberFormat/Calendar would. |
209 status = U_ZERO_ERROR; | 209 status = U_ZERO_ERROR; |
210 icu::NumberingSystem* numbering_system = | 210 icu::NumberingSystem* numbering_system = |
211 icu::NumberingSystem::createInstance(icu_locale, status); | 211 icu::NumberingSystem::createInstance(icu_locale, status); |
212 if (U_SUCCESS(status)) { | 212 if (U_SUCCESS(status)) { |
213 const char* ns = numbering_system->getName(); | 213 const char* ns = numbering_system->getName(); |
214 JSObject::SetProperty( | 214 JSObject::SetProperty( |
215 resolved, | 215 resolved, |
216 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), | 216 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), |
217 isolate->factory()->NewStringFromAscii(CStrVector(ns)), | 217 isolate->factory()->NewStringFromAscii(CStrVector(ns)), |
218 NONE, | 218 NONE, |
219 kSloppyMode); | 219 SLOPPY); |
220 } else { | 220 } else { |
221 JSObject::SetProperty( | 221 JSObject::SetProperty( |
222 resolved, | 222 resolved, |
223 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), | 223 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), |
224 isolate->factory()->undefined_value(), | 224 isolate->factory()->undefined_value(), |
225 NONE, | 225 NONE, |
226 kSloppyMode); | 226 SLOPPY); |
227 } | 227 } |
228 delete numbering_system; | 228 delete numbering_system; |
229 | 229 |
230 // Set the locale | 230 // Set the locale |
231 char result[ULOC_FULLNAME_CAPACITY]; | 231 char result[ULOC_FULLNAME_CAPACITY]; |
232 status = U_ZERO_ERROR; | 232 status = U_ZERO_ERROR; |
233 uloc_toLanguageTag( | 233 uloc_toLanguageTag( |
234 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 234 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
235 if (U_SUCCESS(status)) { | 235 if (U_SUCCESS(status)) { |
236 JSObject::SetProperty( | 236 JSObject::SetProperty( |
237 resolved, | 237 resolved, |
238 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 238 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
239 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 239 isolate->factory()->NewStringFromAscii(CStrVector(result)), |
240 NONE, | 240 NONE, |
241 kSloppyMode); | 241 SLOPPY); |
242 } else { | 242 } else { |
243 // This would never happen, since we got the locale from ICU. | 243 // This would never happen, since we got the locale from ICU. |
244 JSObject::SetProperty( | 244 JSObject::SetProperty( |
245 resolved, | 245 resolved, |
246 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 246 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
247 isolate->factory()->NewStringFromAscii(CStrVector("und")), | 247 isolate->factory()->NewStringFromAscii(CStrVector("und")), |
248 NONE, | 248 NONE, |
249 kSloppyMode); | 249 SLOPPY); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 template<int internal_fields, EternalHandles::SingletonHandle field> | 254 template<int internal_fields, EternalHandles::SingletonHandle field> |
255 Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) { | 255 Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) { |
256 if (isolate->eternal_handles()->Exists(field)) { | 256 if (isolate->eternal_handles()->Exists(field)) { |
257 return Handle<ObjectTemplateInfo>::cast( | 257 return Handle<ObjectTemplateInfo>::cast( |
258 isolate->eternal_handles()->GetSingleton(field)); | 258 isolate->eternal_handles()->GetSingleton(field)); |
259 } | 259 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 icu::UnicodeString pattern; | 382 icu::UnicodeString pattern; |
383 number_format->toPattern(pattern); | 383 number_format->toPattern(pattern); |
384 JSObject::SetProperty( | 384 JSObject::SetProperty( |
385 resolved, | 385 resolved, |
386 isolate->factory()->NewStringFromAscii(CStrVector("pattern")), | 386 isolate->factory()->NewStringFromAscii(CStrVector("pattern")), |
387 isolate->factory()->NewStringFromTwoByte( | 387 isolate->factory()->NewStringFromTwoByte( |
388 Vector<const uint16_t>( | 388 Vector<const uint16_t>( |
389 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), | 389 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), |
390 pattern.length())), | 390 pattern.length())), |
391 NONE, | 391 NONE, |
392 kSloppyMode); | 392 SLOPPY); |
393 | 393 |
394 // Set resolved currency code in options.currency if not empty. | 394 // Set resolved currency code in options.currency if not empty. |
395 icu::UnicodeString currency(number_format->getCurrency()); | 395 icu::UnicodeString currency(number_format->getCurrency()); |
396 if (!currency.isEmpty()) { | 396 if (!currency.isEmpty()) { |
397 JSObject::SetProperty( | 397 JSObject::SetProperty( |
398 resolved, | 398 resolved, |
399 isolate->factory()->NewStringFromAscii(CStrVector("currency")), | 399 isolate->factory()->NewStringFromAscii(CStrVector("currency")), |
400 isolate->factory()->NewStringFromTwoByte( | 400 isolate->factory()->NewStringFromTwoByte( |
401 Vector<const uint16_t>( | 401 Vector<const uint16_t>( |
402 reinterpret_cast<const uint16_t*>(currency.getBuffer()), | 402 reinterpret_cast<const uint16_t*>(currency.getBuffer()), |
403 currency.length())), | 403 currency.length())), |
404 NONE, | 404 NONE, |
405 kSloppyMode); | 405 SLOPPY); |
406 } | 406 } |
407 | 407 |
408 // Ugly hack. ICU doesn't expose numbering system in any way, so we have | 408 // Ugly hack. ICU doesn't expose numbering system in any way, so we have |
409 // to assume that for given locale NumberingSystem constructor produces the | 409 // to assume that for given locale NumberingSystem constructor produces the |
410 // same digits as NumberFormat/Calendar would. | 410 // same digits as NumberFormat/Calendar would. |
411 UErrorCode status = U_ZERO_ERROR; | 411 UErrorCode status = U_ZERO_ERROR; |
412 icu::NumberingSystem* numbering_system = | 412 icu::NumberingSystem* numbering_system = |
413 icu::NumberingSystem::createInstance(icu_locale, status); | 413 icu::NumberingSystem::createInstance(icu_locale, status); |
414 if (U_SUCCESS(status)) { | 414 if (U_SUCCESS(status)) { |
415 const char* ns = numbering_system->getName(); | 415 const char* ns = numbering_system->getName(); |
416 JSObject::SetProperty( | 416 JSObject::SetProperty( |
417 resolved, | 417 resolved, |
418 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), | 418 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), |
419 isolate->factory()->NewStringFromAscii(CStrVector(ns)), | 419 isolate->factory()->NewStringFromAscii(CStrVector(ns)), |
420 NONE, | 420 NONE, |
421 kSloppyMode); | 421 SLOPPY); |
422 } else { | 422 } else { |
423 JSObject::SetProperty( | 423 JSObject::SetProperty( |
424 resolved, | 424 resolved, |
425 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), | 425 isolate->factory()->NewStringFromAscii(CStrVector("numberingSystem")), |
426 isolate->factory()->undefined_value(), | 426 isolate->factory()->undefined_value(), |
427 NONE, | 427 NONE, |
428 kSloppyMode); | 428 SLOPPY); |
429 } | 429 } |
430 delete numbering_system; | 430 delete numbering_system; |
431 | 431 |
432 JSObject::SetProperty( | 432 JSObject::SetProperty( |
433 resolved, | 433 resolved, |
434 isolate->factory()->NewStringFromAscii(CStrVector("useGrouping")), | 434 isolate->factory()->NewStringFromAscii(CStrVector("useGrouping")), |
435 isolate->factory()->ToBoolean(number_format->isGroupingUsed()), | 435 isolate->factory()->ToBoolean(number_format->isGroupingUsed()), |
436 NONE, | 436 NONE, |
437 kSloppyMode); | 437 SLOPPY); |
438 | 438 |
439 JSObject::SetProperty( | 439 JSObject::SetProperty( |
440 resolved, | 440 resolved, |
441 isolate->factory()->NewStringFromAscii( | 441 isolate->factory()->NewStringFromAscii( |
442 CStrVector("minimumIntegerDigits")), | 442 CStrVector("minimumIntegerDigits")), |
443 isolate->factory()->NewNumberFromInt( | 443 isolate->factory()->NewNumberFromInt( |
444 number_format->getMinimumIntegerDigits()), | 444 number_format->getMinimumIntegerDigits()), |
445 NONE, | 445 NONE, |
446 kSloppyMode); | 446 SLOPPY); |
447 | 447 |
448 JSObject::SetProperty( | 448 JSObject::SetProperty( |
449 resolved, | 449 resolved, |
450 isolate->factory()->NewStringFromAscii( | 450 isolate->factory()->NewStringFromAscii( |
451 CStrVector("minimumFractionDigits")), | 451 CStrVector("minimumFractionDigits")), |
452 isolate->factory()->NewNumberFromInt( | 452 isolate->factory()->NewNumberFromInt( |
453 number_format->getMinimumFractionDigits()), | 453 number_format->getMinimumFractionDigits()), |
454 NONE, | 454 NONE, |
455 kSloppyMode); | 455 SLOPPY); |
456 | 456 |
457 JSObject::SetProperty( | 457 JSObject::SetProperty( |
458 resolved, | 458 resolved, |
459 isolate->factory()->NewStringFromAscii( | 459 isolate->factory()->NewStringFromAscii( |
460 CStrVector("maximumFractionDigits")), | 460 CStrVector("maximumFractionDigits")), |
461 isolate->factory()->NewNumberFromInt( | 461 isolate->factory()->NewNumberFromInt( |
462 number_format->getMaximumFractionDigits()), | 462 number_format->getMaximumFractionDigits()), |
463 NONE, | 463 NONE, |
464 kSloppyMode); | 464 SLOPPY); |
465 | 465 |
466 Handle<String> key = isolate->factory()->NewStringFromAscii( | 466 Handle<String> key = isolate->factory()->NewStringFromAscii( |
467 CStrVector("minimumSignificantDigits")); | 467 CStrVector("minimumSignificantDigits")); |
468 if (JSReceiver::HasLocalProperty(resolved, key)) { | 468 if (JSReceiver::HasLocalProperty(resolved, key)) { |
469 JSObject::SetProperty( | 469 JSObject::SetProperty( |
470 resolved, | 470 resolved, |
471 isolate->factory()->NewStringFromAscii( | 471 isolate->factory()->NewStringFromAscii( |
472 CStrVector("minimumSignificantDigits")), | 472 CStrVector("minimumSignificantDigits")), |
473 isolate->factory()->NewNumberFromInt( | 473 isolate->factory()->NewNumberFromInt( |
474 number_format->getMinimumSignificantDigits()), | 474 number_format->getMinimumSignificantDigits()), |
475 NONE, | 475 NONE, |
476 kSloppyMode); | 476 SLOPPY); |
477 } | 477 } |
478 | 478 |
479 key = isolate->factory()->NewStringFromAscii( | 479 key = isolate->factory()->NewStringFromAscii( |
480 CStrVector("maximumSignificantDigits")); | 480 CStrVector("maximumSignificantDigits")); |
481 if (JSReceiver::HasLocalProperty(resolved, key)) { | 481 if (JSReceiver::HasLocalProperty(resolved, key)) { |
482 JSObject::SetProperty( | 482 JSObject::SetProperty( |
483 resolved, | 483 resolved, |
484 isolate->factory()->NewStringFromAscii( | 484 isolate->factory()->NewStringFromAscii( |
485 CStrVector("maximumSignificantDigits")), | 485 CStrVector("maximumSignificantDigits")), |
486 isolate->factory()->NewNumberFromInt( | 486 isolate->factory()->NewNumberFromInt( |
487 number_format->getMaximumSignificantDigits()), | 487 number_format->getMaximumSignificantDigits()), |
488 NONE, | 488 NONE, |
489 kSloppyMode); | 489 SLOPPY); |
490 } | 490 } |
491 | 491 |
492 // Set the locale | 492 // Set the locale |
493 char result[ULOC_FULLNAME_CAPACITY]; | 493 char result[ULOC_FULLNAME_CAPACITY]; |
494 status = U_ZERO_ERROR; | 494 status = U_ZERO_ERROR; |
495 uloc_toLanguageTag( | 495 uloc_toLanguageTag( |
496 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 496 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
497 if (U_SUCCESS(status)) { | 497 if (U_SUCCESS(status)) { |
498 JSObject::SetProperty( | 498 JSObject::SetProperty( |
499 resolved, | 499 resolved, |
500 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 500 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
501 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 501 isolate->factory()->NewStringFromAscii(CStrVector(result)), |
502 NONE, | 502 NONE, |
503 kSloppyMode); | 503 SLOPPY); |
504 } else { | 504 } else { |
505 // This would never happen, since we got the locale from ICU. | 505 // This would never happen, since we got the locale from ICU. |
506 JSObject::SetProperty( | 506 JSObject::SetProperty( |
507 resolved, | 507 resolved, |
508 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 508 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
509 isolate->factory()->NewStringFromAscii(CStrVector("und")), | 509 isolate->factory()->NewStringFromAscii(CStrVector("und")), |
510 NONE, | 510 NONE, |
511 kSloppyMode); | 511 SLOPPY); |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 icu::Collator* CreateICUCollator( | 516 icu::Collator* CreateICUCollator( |
517 Isolate* isolate, | 517 Isolate* isolate, |
518 const icu::Locale& icu_locale, | 518 const icu::Locale& icu_locale, |
519 Handle<JSObject> options) { | 519 Handle<JSObject> options) { |
520 // Make collator from options. | 520 // Make collator from options. |
521 icu::Collator* collator = NULL; | 521 icu::Collator* collator = NULL; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 icu::Collator* collator, | 582 icu::Collator* collator, |
583 Handle<JSObject> resolved) { | 583 Handle<JSObject> resolved) { |
584 UErrorCode status = U_ZERO_ERROR; | 584 UErrorCode status = U_ZERO_ERROR; |
585 | 585 |
586 JSObject::SetProperty( | 586 JSObject::SetProperty( |
587 resolved, | 587 resolved, |
588 isolate->factory()->NewStringFromAscii(CStrVector("numeric")), | 588 isolate->factory()->NewStringFromAscii(CStrVector("numeric")), |
589 isolate->factory()->ToBoolean( | 589 isolate->factory()->ToBoolean( |
590 collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON), | 590 collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON), |
591 NONE, | 591 NONE, |
592 kSloppyMode); | 592 SLOPPY); |
593 | 593 |
594 switch (collator->getAttribute(UCOL_CASE_FIRST, status)) { | 594 switch (collator->getAttribute(UCOL_CASE_FIRST, status)) { |
595 case UCOL_LOWER_FIRST: | 595 case UCOL_LOWER_FIRST: |
596 JSObject::SetProperty( | 596 JSObject::SetProperty( |
597 resolved, | 597 resolved, |
598 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), | 598 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), |
599 isolate->factory()->NewStringFromAscii(CStrVector("lower")), | 599 isolate->factory()->NewStringFromAscii(CStrVector("lower")), |
600 NONE, | 600 NONE, |
601 kSloppyMode); | 601 SLOPPY); |
602 break; | 602 break; |
603 case UCOL_UPPER_FIRST: | 603 case UCOL_UPPER_FIRST: |
604 JSObject::SetProperty( | 604 JSObject::SetProperty( |
605 resolved, | 605 resolved, |
606 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), | 606 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), |
607 isolate->factory()->NewStringFromAscii(CStrVector("upper")), | 607 isolate->factory()->NewStringFromAscii(CStrVector("upper")), |
608 NONE, | 608 NONE, |
609 kSloppyMode); | 609 SLOPPY); |
610 break; | 610 break; |
611 default: | 611 default: |
612 JSObject::SetProperty( | 612 JSObject::SetProperty( |
613 resolved, | 613 resolved, |
614 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), | 614 isolate->factory()->NewStringFromAscii(CStrVector("caseFirst")), |
615 isolate->factory()->NewStringFromAscii(CStrVector("false")), | 615 isolate->factory()->NewStringFromAscii(CStrVector("false")), |
616 NONE, | 616 NONE, |
617 kSloppyMode); | 617 SLOPPY); |
618 } | 618 } |
619 | 619 |
620 switch (collator->getAttribute(UCOL_STRENGTH, status)) { | 620 switch (collator->getAttribute(UCOL_STRENGTH, status)) { |
621 case UCOL_PRIMARY: { | 621 case UCOL_PRIMARY: { |
622 JSObject::SetProperty( | 622 JSObject::SetProperty( |
623 resolved, | 623 resolved, |
624 isolate->factory()->NewStringFromAscii(CStrVector("strength")), | 624 isolate->factory()->NewStringFromAscii(CStrVector("strength")), |
625 isolate->factory()->NewStringFromAscii(CStrVector("primary")), | 625 isolate->factory()->NewStringFromAscii(CStrVector("primary")), |
626 NONE, | 626 NONE, |
627 kSloppyMode); | 627 SLOPPY); |
628 | 628 |
629 // case level: true + s1 -> case, s1 -> base. | 629 // case level: true + s1 -> case, s1 -> base. |
630 if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) { | 630 if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) { |
631 JSObject::SetProperty( | 631 JSObject::SetProperty( |
632 resolved, | 632 resolved, |
633 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 633 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
634 isolate->factory()->NewStringFromAscii(CStrVector("case")), | 634 isolate->factory()->NewStringFromAscii(CStrVector("case")), |
635 NONE, | 635 NONE, |
636 kSloppyMode); | 636 SLOPPY); |
637 } else { | 637 } else { |
638 JSObject::SetProperty( | 638 JSObject::SetProperty( |
639 resolved, | 639 resolved, |
640 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 640 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
641 isolate->factory()->NewStringFromAscii(CStrVector("base")), | 641 isolate->factory()->NewStringFromAscii(CStrVector("base")), |
642 NONE, | 642 NONE, |
643 kSloppyMode); | 643 SLOPPY); |
644 } | 644 } |
645 break; | 645 break; |
646 } | 646 } |
647 case UCOL_SECONDARY: | 647 case UCOL_SECONDARY: |
648 JSObject::SetProperty( | 648 JSObject::SetProperty( |
649 resolved, | 649 resolved, |
650 isolate->factory()->NewStringFromAscii(CStrVector("strength")), | 650 isolate->factory()->NewStringFromAscii(CStrVector("strength")), |
651 isolate->factory()->NewStringFromAscii(CStrVector("secondary")), | 651 isolate->factory()->NewStringFromAscii(CStrVector("secondary")), |
652 NONE, | 652 NONE, |
653 kSloppyMode); | 653 SLOPPY); |
654 JSObject::SetProperty( | 654 JSObject::SetProperty( |
655 resolved, | 655 resolved, |
656 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 656 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
657 isolate->factory()->NewStringFromAscii(CStrVector("accent")), | 657 isolate->factory()->NewStringFromAscii(CStrVector("accent")), |
658 NONE, | 658 NONE, |
659 kSloppyMode); | 659 SLOPPY); |
660 break; | 660 break; |
661 case UCOL_TERTIARY: | 661 case UCOL_TERTIARY: |
662 JSObject::SetProperty( | 662 JSObject::SetProperty( |
663 resolved, | 663 resolved, |
664 isolate->factory()->NewStringFromAscii(CStrVector("strength")), | 664 isolate->factory()->NewStringFromAscii(CStrVector("strength")), |
665 isolate->factory()->NewStringFromAscii(CStrVector("tertiary")), | 665 isolate->factory()->NewStringFromAscii(CStrVector("tertiary")), |
666 NONE, | 666 NONE, |
667 kSloppyMode); | 667 SLOPPY); |
668 JSObject::SetProperty( | 668 JSObject::SetProperty( |
669 resolved, | 669 resolved, |
670 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 670 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
671 isolate->factory()->NewStringFromAscii(CStrVector("variant")), | 671 isolate->factory()->NewStringFromAscii(CStrVector("variant")), |
672 NONE, | 672 NONE, |
673 kSloppyMode); | 673 SLOPPY); |
674 break; | 674 break; |
675 case UCOL_QUATERNARY: | 675 case UCOL_QUATERNARY: |
676 // We shouldn't get quaternary and identical from ICU, but if we do | 676 // We shouldn't get quaternary and identical from ICU, but if we do |
677 // put them into variant. | 677 // put them into variant. |
678 JSObject::SetProperty( | 678 JSObject::SetProperty( |
679 resolved, | 679 resolved, |
680 isolate->factory()->NewStringFromAscii(CStrVector("strength")), | 680 isolate->factory()->NewStringFromAscii(CStrVector("strength")), |
681 isolate->factory()->NewStringFromAscii(CStrVector("quaternary")), | 681 isolate->factory()->NewStringFromAscii(CStrVector("quaternary")), |
682 NONE, | 682 NONE, |
683 kSloppyMode); | 683 SLOPPY); |
684 JSObject::SetProperty( | 684 JSObject::SetProperty( |
685 resolved, | 685 resolved, |
686 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 686 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
687 isolate->factory()->NewStringFromAscii(CStrVector("variant")), | 687 isolate->factory()->NewStringFromAscii(CStrVector("variant")), |
688 NONE, | 688 NONE, |
689 kSloppyMode); | 689 SLOPPY); |
690 break; | 690 break; |
691 default: | 691 default: |
692 JSObject::SetProperty( | 692 JSObject::SetProperty( |
693 resolved, | 693 resolved, |
694 isolate->factory()->NewStringFromAscii(CStrVector("strength")), | 694 isolate->factory()->NewStringFromAscii(CStrVector("strength")), |
695 isolate->factory()->NewStringFromAscii(CStrVector("identical")), | 695 isolate->factory()->NewStringFromAscii(CStrVector("identical")), |
696 NONE, | 696 NONE, |
697 kSloppyMode); | 697 SLOPPY); |
698 JSObject::SetProperty( | 698 JSObject::SetProperty( |
699 resolved, | 699 resolved, |
700 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), | 700 isolate->factory()->NewStringFromAscii(CStrVector("sensitivity")), |
701 isolate->factory()->NewStringFromAscii(CStrVector("variant")), | 701 isolate->factory()->NewStringFromAscii(CStrVector("variant")), |
702 NONE, | 702 NONE, |
703 kSloppyMode); | 703 SLOPPY); |
704 } | 704 } |
705 | 705 |
706 JSObject::SetProperty( | 706 JSObject::SetProperty( |
707 resolved, | 707 resolved, |
708 isolate->factory()->NewStringFromAscii(CStrVector("ignorePunctuation")), | 708 isolate->factory()->NewStringFromAscii(CStrVector("ignorePunctuation")), |
709 isolate->factory()->ToBoolean(collator->getAttribute( | 709 isolate->factory()->ToBoolean(collator->getAttribute( |
710 UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED), | 710 UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED), |
711 NONE, | 711 NONE, |
712 kSloppyMode); | 712 SLOPPY); |
713 | 713 |
714 // Set the locale | 714 // Set the locale |
715 char result[ULOC_FULLNAME_CAPACITY]; | 715 char result[ULOC_FULLNAME_CAPACITY]; |
716 status = U_ZERO_ERROR; | 716 status = U_ZERO_ERROR; |
717 uloc_toLanguageTag( | 717 uloc_toLanguageTag( |
718 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 718 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
719 if (U_SUCCESS(status)) { | 719 if (U_SUCCESS(status)) { |
720 JSObject::SetProperty( | 720 JSObject::SetProperty( |
721 resolved, | 721 resolved, |
722 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 722 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
723 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 723 isolate->factory()->NewStringFromAscii(CStrVector(result)), |
724 NONE, | 724 NONE, |
725 kSloppyMode); | 725 SLOPPY); |
726 } else { | 726 } else { |
727 // This would never happen, since we got the locale from ICU. | 727 // This would never happen, since we got the locale from ICU. |
728 JSObject::SetProperty( | 728 JSObject::SetProperty( |
729 resolved, | 729 resolved, |
730 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 730 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
731 isolate->factory()->NewStringFromAscii(CStrVector("und")), | 731 isolate->factory()->NewStringFromAscii(CStrVector("und")), |
732 NONE, | 732 NONE, |
733 kSloppyMode); | 733 SLOPPY); |
734 } | 734 } |
735 } | 735 } |
736 | 736 |
737 | 737 |
738 icu::BreakIterator* CreateICUBreakIterator( | 738 icu::BreakIterator* CreateICUBreakIterator( |
739 Isolate* isolate, | 739 Isolate* isolate, |
740 const icu::Locale& icu_locale, | 740 const icu::Locale& icu_locale, |
741 Handle<JSObject> options) { | 741 Handle<JSObject> options) { |
742 UErrorCode status = U_ZERO_ERROR; | 742 UErrorCode status = U_ZERO_ERROR; |
743 icu::BreakIterator* break_iterator = NULL; | 743 icu::BreakIterator* break_iterator = NULL; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 char result[ULOC_FULLNAME_CAPACITY]; | 778 char result[ULOC_FULLNAME_CAPACITY]; |
779 status = U_ZERO_ERROR; | 779 status = U_ZERO_ERROR; |
780 uloc_toLanguageTag( | 780 uloc_toLanguageTag( |
781 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 781 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
782 if (U_SUCCESS(status)) { | 782 if (U_SUCCESS(status)) { |
783 JSObject::SetProperty( | 783 JSObject::SetProperty( |
784 resolved, | 784 resolved, |
785 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 785 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
786 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 786 isolate->factory()->NewStringFromAscii(CStrVector(result)), |
787 NONE, | 787 NONE, |
788 kSloppyMode); | 788 SLOPPY); |
789 } else { | 789 } else { |
790 // This would never happen, since we got the locale from ICU. | 790 // This would never happen, since we got the locale from ICU. |
791 JSObject::SetProperty( | 791 JSObject::SetProperty( |
792 resolved, | 792 resolved, |
793 isolate->factory()->NewStringFromAscii(CStrVector("locale")), | 793 isolate->factory()->NewStringFromAscii(CStrVector("locale")), |
794 isolate->factory()->NewStringFromAscii(CStrVector("und")), | 794 isolate->factory()->NewStringFromAscii(CStrVector("und")), |
795 NONE, | 795 NONE, |
796 kSloppyMode); | 796 SLOPPY); |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
800 } // namespace | 800 } // namespace |
801 | 801 |
802 | 802 |
803 // static | 803 // static |
804 Handle<ObjectTemplateInfo> I18N::GetTemplate(Isolate* isolate) { | 804 Handle<ObjectTemplateInfo> I18N::GetTemplate(Isolate* isolate) { |
805 return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate); | 805 return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate); |
806 } | 806 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1054 |
1055 | 1055 |
1056 void BreakIterator::DeleteBreakIterator( | 1056 void BreakIterator::DeleteBreakIterator( |
1057 const v8::WeakCallbackData<v8::Value, void>& data) { | 1057 const v8::WeakCallbackData<v8::Value, void>& data) { |
1058 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); | 1058 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); |
1059 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); | 1059 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); |
1060 DestroyGlobalHandle(data); | 1060 DestroyGlobalHandle(data); |
1061 } | 1061 } |
1062 | 1062 |
1063 } } // namespace v8::internal | 1063 } } // namespace v8::internal |
OLD | NEW |