Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: src/i18n.cc

Issue 559913002: Rename ascii to one-byte where applicable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // limitations under the License. 4 // limitations under the License.
5 5
6 #include "src/i18n.h" 6 #include "src/i18n.h"
7 7
8 #include "unicode/brkiter.h" 8 #include "unicode/brkiter.h"
9 #include "unicode/calendar.h" 9 #include "unicode/calendar.h"
10 #include "unicode/coll.h" 10 #include "unicode/coll.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 void SetResolvedDateSettings(Isolate* isolate, 125 void SetResolvedDateSettings(Isolate* isolate,
126 const icu::Locale& icu_locale, 126 const icu::Locale& icu_locale,
127 icu::SimpleDateFormat* date_format, 127 icu::SimpleDateFormat* date_format,
128 Handle<JSObject> resolved) { 128 Handle<JSObject> resolved) {
129 Factory* factory = isolate->factory(); 129 Factory* factory = isolate->factory();
130 UErrorCode status = U_ZERO_ERROR; 130 UErrorCode status = U_ZERO_ERROR;
131 icu::UnicodeString pattern; 131 icu::UnicodeString pattern;
132 date_format->toPattern(pattern); 132 date_format->toPattern(pattern);
133 JSObject::SetProperty( 133 JSObject::SetProperty(
134 resolved, 134 resolved, factory->NewStringFromStaticChars("pattern"),
135 factory->NewStringFromStaticAscii("pattern"),
136 factory->NewStringFromTwoByte( 135 factory->NewStringFromTwoByte(
137 Vector<const uint16_t>( 136 Vector<const uint16_t>(
138 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), 137 reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
139 pattern.length())).ToHandleChecked(), 138 pattern.length())).ToHandleChecked(),
140 SLOPPY).Assert(); 139 SLOPPY).Assert();
141 140
142 // Set time zone and calendar. 141 // Set time zone and calendar.
143 const icu::Calendar* calendar = date_format->getCalendar(); 142 const icu::Calendar* calendar = date_format->getCalendar();
144 const char* calendar_name = calendar->getType(); 143 const char* calendar_name = calendar->getType();
145 JSObject::SetProperty( 144 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("calendar"),
146 resolved, 145 factory->NewStringFromAsciiChecked(calendar_name),
147 factory->NewStringFromStaticAscii("calendar"), 146 SLOPPY).Assert();
148 factory->NewStringFromAsciiChecked(calendar_name),
149 SLOPPY).Assert();
150 147
151 const icu::TimeZone& tz = calendar->getTimeZone(); 148 const icu::TimeZone& tz = calendar->getTimeZone();
152 icu::UnicodeString time_zone; 149 icu::UnicodeString time_zone;
153 tz.getID(time_zone); 150 tz.getID(time_zone);
154 151
155 icu::UnicodeString canonical_time_zone; 152 icu::UnicodeString canonical_time_zone;
156 icu::TimeZone::getCanonicalID(time_zone, canonical_time_zone, status); 153 icu::TimeZone::getCanonicalID(time_zone, canonical_time_zone, status);
157 if (U_SUCCESS(status)) { 154 if (U_SUCCESS(status)) {
158 if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) { 155 if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) {
159 JSObject::SetProperty( 156 JSObject::SetProperty(
160 resolved, 157 resolved, factory->NewStringFromStaticChars("timeZone"),
161 factory->NewStringFromStaticAscii("timeZone"), 158 factory->NewStringFromStaticChars("UTC"), SLOPPY).Assert();
162 factory->NewStringFromStaticAscii("UTC"),
163 SLOPPY).Assert();
164 } else { 159 } else {
165 JSObject::SetProperty( 160 JSObject::SetProperty(
166 resolved, 161 resolved, factory->NewStringFromStaticChars("timeZone"),
167 factory->NewStringFromStaticAscii("timeZone"),
168 factory->NewStringFromTwoByte( 162 factory->NewStringFromTwoByte(
169 Vector<const uint16_t>( 163 Vector<const uint16_t>(
170 reinterpret_cast<const uint16_t*>( 164 reinterpret_cast<const uint16_t*>(
171 canonical_time_zone.getBuffer()), 165 canonical_time_zone.getBuffer()),
172 canonical_time_zone.length())).ToHandleChecked(), 166 canonical_time_zone.length())).ToHandleChecked(),
173 SLOPPY).Assert(); 167 SLOPPY).Assert();
174 } 168 }
175 } 169 }
176 170
177 // Ugly hack. ICU doesn't expose numbering system in any way, so we have 171 // Ugly hack. ICU doesn't expose numbering system in any way, so we have
178 // to assume that for given locale NumberingSystem constructor produces the 172 // to assume that for given locale NumberingSystem constructor produces the
179 // same digits as NumberFormat/Calendar would. 173 // same digits as NumberFormat/Calendar would.
180 status = U_ZERO_ERROR; 174 status = U_ZERO_ERROR;
181 icu::NumberingSystem* numbering_system = 175 icu::NumberingSystem* numbering_system =
182 icu::NumberingSystem::createInstance(icu_locale, status); 176 icu::NumberingSystem::createInstance(icu_locale, status);
183 if (U_SUCCESS(status)) { 177 if (U_SUCCESS(status)) {
184 const char* ns = numbering_system->getName(); 178 const char* ns = numbering_system->getName();
185 JSObject::SetProperty( 179 JSObject::SetProperty(
186 resolved, 180 resolved, factory->NewStringFromStaticChars("numberingSystem"),
187 factory->NewStringFromStaticAscii("numberingSystem"), 181 factory->NewStringFromAsciiChecked(ns), SLOPPY).Assert();
188 factory->NewStringFromAsciiChecked(ns),
189 SLOPPY).Assert();
190 } else { 182 } else {
191 JSObject::SetProperty( 183 JSObject::SetProperty(resolved,
192 resolved, 184 factory->NewStringFromStaticChars("numberingSystem"),
193 factory->NewStringFromStaticAscii("numberingSystem"), 185 factory->undefined_value(), SLOPPY).Assert();
194 factory->undefined_value(),
195 SLOPPY).Assert();
196 } 186 }
197 delete numbering_system; 187 delete numbering_system;
198 188
199 // Set the locale 189 // Set the locale
200 char result[ULOC_FULLNAME_CAPACITY]; 190 char result[ULOC_FULLNAME_CAPACITY];
201 status = U_ZERO_ERROR; 191 status = U_ZERO_ERROR;
202 uloc_toLanguageTag( 192 uloc_toLanguageTag(
203 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); 193 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
204 if (U_SUCCESS(status)) { 194 if (U_SUCCESS(status)) {
205 JSObject::SetProperty( 195 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
206 resolved, 196 factory->NewStringFromAsciiChecked(result),
207 factory->NewStringFromStaticAscii("locale"), 197 SLOPPY).Assert();
208 factory->NewStringFromAsciiChecked(result),
209 SLOPPY).Assert();
210 } else { 198 } else {
211 // This would never happen, since we got the locale from ICU. 199 // This would never happen, since we got the locale from ICU.
212 JSObject::SetProperty( 200 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
213 resolved, 201 factory->NewStringFromStaticChars("und"),
214 factory->NewStringFromStaticAscii("locale"), 202 SLOPPY).Assert();
215 factory->NewStringFromStaticAscii("und"),
216 SLOPPY).Assert();
217 } 203 }
218 } 204 }
219 205
220 206
221 template<int internal_fields, EternalHandles::SingletonHandle field> 207 template<int internal_fields, EternalHandles::SingletonHandle field>
222 Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) { 208 Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) {
223 if (isolate->eternal_handles()->Exists(field)) { 209 if (isolate->eternal_handles()->Exists(field)) {
224 return Handle<ObjectTemplateInfo>::cast( 210 return Handle<ObjectTemplateInfo>::cast(
225 isolate->eternal_handles()->GetSingleton(field)); 211 isolate->eternal_handles()->GetSingleton(field));
226 } 212 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 329
344 330
345 void SetResolvedNumberSettings(Isolate* isolate, 331 void SetResolvedNumberSettings(Isolate* isolate,
346 const icu::Locale& icu_locale, 332 const icu::Locale& icu_locale,
347 icu::DecimalFormat* number_format, 333 icu::DecimalFormat* number_format,
348 Handle<JSObject> resolved) { 334 Handle<JSObject> resolved) {
349 Factory* factory = isolate->factory(); 335 Factory* factory = isolate->factory();
350 icu::UnicodeString pattern; 336 icu::UnicodeString pattern;
351 number_format->toPattern(pattern); 337 number_format->toPattern(pattern);
352 JSObject::SetProperty( 338 JSObject::SetProperty(
353 resolved, 339 resolved, factory->NewStringFromStaticChars("pattern"),
354 factory->NewStringFromStaticAscii("pattern"),
355 factory->NewStringFromTwoByte( 340 factory->NewStringFromTwoByte(
356 Vector<const uint16_t>( 341 Vector<const uint16_t>(
357 reinterpret_cast<const uint16_t*>(pattern.getBuffer()), 342 reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
358 pattern.length())).ToHandleChecked(), 343 pattern.length())).ToHandleChecked(),
359 SLOPPY).Assert(); 344 SLOPPY).Assert();
360 345
361 // Set resolved currency code in options.currency if not empty. 346 // Set resolved currency code in options.currency if not empty.
362 icu::UnicodeString currency(number_format->getCurrency()); 347 icu::UnicodeString currency(number_format->getCurrency());
363 if (!currency.isEmpty()) { 348 if (!currency.isEmpty()) {
364 JSObject::SetProperty( 349 JSObject::SetProperty(
365 resolved, 350 resolved, factory->NewStringFromStaticChars("currency"),
366 factory->NewStringFromStaticAscii("currency"), 351 factory->NewStringFromTwoByte(Vector<const uint16_t>(
367 factory->NewStringFromTwoByte( 352 reinterpret_cast<const uint16_t*>(
368 Vector<const uint16_t>( 353 currency.getBuffer()),
369 reinterpret_cast<const uint16_t*>(currency.getBuffer()), 354 currency.length())).ToHandleChecked(),
370 currency.length())).ToHandleChecked(),
371 SLOPPY).Assert(); 355 SLOPPY).Assert();
372 } 356 }
373 357
374 // Ugly hack. ICU doesn't expose numbering system in any way, so we have 358 // Ugly hack. ICU doesn't expose numbering system in any way, so we have
375 // to assume that for given locale NumberingSystem constructor produces the 359 // to assume that for given locale NumberingSystem constructor produces the
376 // same digits as NumberFormat/Calendar would. 360 // same digits as NumberFormat/Calendar would.
377 UErrorCode status = U_ZERO_ERROR; 361 UErrorCode status = U_ZERO_ERROR;
378 icu::NumberingSystem* numbering_system = 362 icu::NumberingSystem* numbering_system =
379 icu::NumberingSystem::createInstance(icu_locale, status); 363 icu::NumberingSystem::createInstance(icu_locale, status);
380 if (U_SUCCESS(status)) { 364 if (U_SUCCESS(status)) {
381 const char* ns = numbering_system->getName(); 365 const char* ns = numbering_system->getName();
382 JSObject::SetProperty( 366 JSObject::SetProperty(
383 resolved, 367 resolved, factory->NewStringFromStaticChars("numberingSystem"),
384 factory->NewStringFromStaticAscii("numberingSystem"), 368 factory->NewStringFromAsciiChecked(ns), SLOPPY).Assert();
385 factory->NewStringFromAsciiChecked(ns),
386 SLOPPY).Assert();
387 } else { 369 } else {
388 JSObject::SetProperty( 370 JSObject::SetProperty(resolved,
389 resolved, 371 factory->NewStringFromStaticChars("numberingSystem"),
390 factory->NewStringFromStaticAscii("numberingSystem"), 372 factory->undefined_value(), SLOPPY).Assert();
391 factory->undefined_value(),
392 SLOPPY).Assert();
393 } 373 }
394 delete numbering_system; 374 delete numbering_system;
395 375
396 JSObject::SetProperty( 376 JSObject::SetProperty(
397 resolved, 377 resolved, factory->NewStringFromStaticChars("useGrouping"),
398 factory->NewStringFromStaticAscii("useGrouping"), 378 factory->ToBoolean(number_format->isGroupingUsed()), SLOPPY).Assert();
399 factory->ToBoolean(number_format->isGroupingUsed()),
400 SLOPPY).Assert();
401 379
402 JSObject::SetProperty( 380 JSObject::SetProperty(
403 resolved, 381 resolved, factory->NewStringFromStaticChars("minimumIntegerDigits"),
404 factory->NewStringFromStaticAscii("minimumIntegerDigits"),
405 factory->NewNumberFromInt(number_format->getMinimumIntegerDigits()), 382 factory->NewNumberFromInt(number_format->getMinimumIntegerDigits()),
406 SLOPPY).Assert(); 383 SLOPPY).Assert();
407 384
408 JSObject::SetProperty( 385 JSObject::SetProperty(
409 resolved, 386 resolved, factory->NewStringFromStaticChars("minimumFractionDigits"),
410 factory->NewStringFromStaticAscii("minimumFractionDigits"),
411 factory->NewNumberFromInt(number_format->getMinimumFractionDigits()), 387 factory->NewNumberFromInt(number_format->getMinimumFractionDigits()),
412 SLOPPY).Assert(); 388 SLOPPY).Assert();
413 389
414 JSObject::SetProperty( 390 JSObject::SetProperty(
415 resolved, 391 resolved, factory->NewStringFromStaticChars("maximumFractionDigits"),
416 factory->NewStringFromStaticAscii("maximumFractionDigits"),
417 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()), 392 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()),
418 SLOPPY).Assert(); 393 SLOPPY).Assert();
419 394
420 Handle<String> key = 395 Handle<String> key =
421 factory->NewStringFromStaticAscii("minimumSignificantDigits"); 396 factory->NewStringFromStaticChars("minimumSignificantDigits");
422 Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key); 397 Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key);
423 CHECK(maybe.has_value); 398 CHECK(maybe.has_value);
424 if (maybe.value) { 399 if (maybe.value) {
425 JSObject::SetProperty( 400 JSObject::SetProperty(
426 resolved, 401 resolved, factory->NewStringFromStaticChars("minimumSignificantDigits"),
427 factory->NewStringFromStaticAscii("minimumSignificantDigits"),
428 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()), 402 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()),
429 SLOPPY).Assert(); 403 SLOPPY).Assert();
430 } 404 }
431 405
432 key = factory->NewStringFromStaticAscii("maximumSignificantDigits"); 406 key = factory->NewStringFromStaticChars("maximumSignificantDigits");
433 maybe = JSReceiver::HasOwnProperty(resolved, key); 407 maybe = JSReceiver::HasOwnProperty(resolved, key);
434 CHECK(maybe.has_value); 408 CHECK(maybe.has_value);
435 if (maybe.value) { 409 if (maybe.value) {
436 JSObject::SetProperty( 410 JSObject::SetProperty(
437 resolved, 411 resolved, factory->NewStringFromStaticChars("maximumSignificantDigits"),
438 factory->NewStringFromStaticAscii("maximumSignificantDigits"),
439 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()), 412 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()),
440 SLOPPY).Assert(); 413 SLOPPY).Assert();
441 } 414 }
442 415
443 // Set the locale 416 // Set the locale
444 char result[ULOC_FULLNAME_CAPACITY]; 417 char result[ULOC_FULLNAME_CAPACITY];
445 status = U_ZERO_ERROR; 418 status = U_ZERO_ERROR;
446 uloc_toLanguageTag( 419 uloc_toLanguageTag(
447 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); 420 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
448 if (U_SUCCESS(status)) { 421 if (U_SUCCESS(status)) {
449 JSObject::SetProperty( 422 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
450 resolved, 423 factory->NewStringFromAsciiChecked(result),
451 factory->NewStringFromStaticAscii("locale"), 424 SLOPPY).Assert();
452 factory->NewStringFromAsciiChecked(result),
453 SLOPPY).Assert();
454 } else { 425 } else {
455 // This would never happen, since we got the locale from ICU. 426 // This would never happen, since we got the locale from ICU.
456 JSObject::SetProperty( 427 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
457 resolved, 428 factory->NewStringFromStaticChars("und"),
458 factory->NewStringFromStaticAscii("locale"), 429 SLOPPY).Assert();
459 factory->NewStringFromStaticAscii("und"),
460 SLOPPY).Assert();
461 } 430 }
462 } 431 }
463 432
464 433
465 icu::Collator* CreateICUCollator( 434 icu::Collator* CreateICUCollator(
466 Isolate* isolate, 435 Isolate* isolate,
467 const icu::Locale& icu_locale, 436 const icu::Locale& icu_locale,
468 Handle<JSObject> options) { 437 Handle<JSObject> options) {
469 // Make collator from options. 438 // Make collator from options.
470 icu::Collator* collator = NULL; 439 icu::Collator* collator = NULL;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 496
528 497
529 void SetResolvedCollatorSettings(Isolate* isolate, 498 void SetResolvedCollatorSettings(Isolate* isolate,
530 const icu::Locale& icu_locale, 499 const icu::Locale& icu_locale,
531 icu::Collator* collator, 500 icu::Collator* collator,
532 Handle<JSObject> resolved) { 501 Handle<JSObject> resolved) {
533 Factory* factory = isolate->factory(); 502 Factory* factory = isolate->factory();
534 UErrorCode status = U_ZERO_ERROR; 503 UErrorCode status = U_ZERO_ERROR;
535 504
536 JSObject::SetProperty( 505 JSObject::SetProperty(
537 resolved, 506 resolved, factory->NewStringFromStaticChars("numeric"),
538 factory->NewStringFromStaticAscii("numeric"),
539 factory->ToBoolean( 507 factory->ToBoolean(
540 collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON), 508 collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON),
541 SLOPPY).Assert(); 509 SLOPPY).Assert();
542 510
543 switch (collator->getAttribute(UCOL_CASE_FIRST, status)) { 511 switch (collator->getAttribute(UCOL_CASE_FIRST, status)) {
544 case UCOL_LOWER_FIRST: 512 case UCOL_LOWER_FIRST:
545 JSObject::SetProperty( 513 JSObject::SetProperty(
546 resolved, 514 resolved, factory->NewStringFromStaticChars("caseFirst"),
547 factory->NewStringFromStaticAscii("caseFirst"), 515 factory->NewStringFromStaticChars("lower"), SLOPPY).Assert();
548 factory->NewStringFromStaticAscii("lower"),
549 SLOPPY).Assert();
550 break; 516 break;
551 case UCOL_UPPER_FIRST: 517 case UCOL_UPPER_FIRST:
552 JSObject::SetProperty( 518 JSObject::SetProperty(
553 resolved, 519 resolved, factory->NewStringFromStaticChars("caseFirst"),
554 factory->NewStringFromStaticAscii("caseFirst"), 520 factory->NewStringFromStaticChars("upper"), SLOPPY).Assert();
555 factory->NewStringFromStaticAscii("upper"),
556 SLOPPY).Assert();
557 break; 521 break;
558 default: 522 default:
559 JSObject::SetProperty( 523 JSObject::SetProperty(
560 resolved, 524 resolved, factory->NewStringFromStaticChars("caseFirst"),
561 factory->NewStringFromStaticAscii("caseFirst"), 525 factory->NewStringFromStaticChars("false"), SLOPPY).Assert();
562 factory->NewStringFromStaticAscii("false"),
563 SLOPPY).Assert();
564 } 526 }
565 527
566 switch (collator->getAttribute(UCOL_STRENGTH, status)) { 528 switch (collator->getAttribute(UCOL_STRENGTH, status)) {
567 case UCOL_PRIMARY: { 529 case UCOL_PRIMARY: {
568 JSObject::SetProperty( 530 JSObject::SetProperty(
569 resolved, 531 resolved, factory->NewStringFromStaticChars("strength"),
570 factory->NewStringFromStaticAscii("strength"), 532 factory->NewStringFromStaticChars("primary"), SLOPPY).Assert();
571 factory->NewStringFromStaticAscii("primary"),
572 SLOPPY).Assert();
573 533
574 // case level: true + s1 -> case, s1 -> base. 534 // case level: true + s1 -> case, s1 -> base.
575 if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) { 535 if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) {
576 JSObject::SetProperty( 536 JSObject::SetProperty(
577 resolved, 537 resolved, factory->NewStringFromStaticChars("sensitivity"),
578 factory->NewStringFromStaticAscii("sensitivity"), 538 factory->NewStringFromStaticChars("case"), SLOPPY).Assert();
579 factory->NewStringFromStaticAscii("case"),
580 SLOPPY).Assert();
581 } else { 539 } else {
582 JSObject::SetProperty( 540 JSObject::SetProperty(
583 resolved, 541 resolved, factory->NewStringFromStaticChars("sensitivity"),
584 factory->NewStringFromStaticAscii("sensitivity"), 542 factory->NewStringFromStaticChars("base"), SLOPPY).Assert();
585 factory->NewStringFromStaticAscii("base"),
586 SLOPPY).Assert();
587 } 543 }
588 break; 544 break;
589 } 545 }
590 case UCOL_SECONDARY: 546 case UCOL_SECONDARY:
591 JSObject::SetProperty( 547 JSObject::SetProperty(
592 resolved, 548 resolved, factory->NewStringFromStaticChars("strength"),
593 factory->NewStringFromStaticAscii("strength"), 549 factory->NewStringFromStaticChars("secondary"), SLOPPY).Assert();
594 factory->NewStringFromStaticAscii("secondary"),
595 SLOPPY).Assert();
596 JSObject::SetProperty( 550 JSObject::SetProperty(
597 resolved, 551 resolved, factory->NewStringFromStaticChars("sensitivity"),
598 factory->NewStringFromStaticAscii("sensitivity"), 552 factory->NewStringFromStaticChars("accent"), SLOPPY).Assert();
599 factory->NewStringFromStaticAscii("accent"),
600 SLOPPY).Assert();
601 break; 553 break;
602 case UCOL_TERTIARY: 554 case UCOL_TERTIARY:
603 JSObject::SetProperty( 555 JSObject::SetProperty(
604 resolved, 556 resolved, factory->NewStringFromStaticChars("strength"),
605 factory->NewStringFromStaticAscii("strength"), 557 factory->NewStringFromStaticChars("tertiary"), SLOPPY).Assert();
606 factory->NewStringFromStaticAscii("tertiary"),
607 SLOPPY).Assert();
608 JSObject::SetProperty( 558 JSObject::SetProperty(
609 resolved, 559 resolved, factory->NewStringFromStaticChars("sensitivity"),
610 factory->NewStringFromStaticAscii("sensitivity"), 560 factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
611 factory->NewStringFromStaticAscii("variant"),
612 SLOPPY).Assert();
613 break; 561 break;
614 case UCOL_QUATERNARY: 562 case UCOL_QUATERNARY:
615 // We shouldn't get quaternary and identical from ICU, but if we do 563 // We shouldn't get quaternary and identical from ICU, but if we do
616 // put them into variant. 564 // put them into variant.
617 JSObject::SetProperty( 565 JSObject::SetProperty(
618 resolved, 566 resolved, factory->NewStringFromStaticChars("strength"),
619 factory->NewStringFromStaticAscii("strength"), 567 factory->NewStringFromStaticChars("quaternary"), SLOPPY).Assert();
620 factory->NewStringFromStaticAscii("quaternary"),
621 SLOPPY).Assert();
622 JSObject::SetProperty( 568 JSObject::SetProperty(
623 resolved, 569 resolved, factory->NewStringFromStaticChars("sensitivity"),
624 factory->NewStringFromStaticAscii("sensitivity"), 570 factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
625 factory->NewStringFromStaticAscii("variant"),
626 SLOPPY).Assert();
627 break; 571 break;
628 default: 572 default:
629 JSObject::SetProperty( 573 JSObject::SetProperty(
630 resolved, 574 resolved, factory->NewStringFromStaticChars("strength"),
631 factory->NewStringFromStaticAscii("strength"), 575 factory->NewStringFromStaticChars("identical"), SLOPPY).Assert();
632 factory->NewStringFromStaticAscii("identical"),
633 SLOPPY).Assert();
634 JSObject::SetProperty( 576 JSObject::SetProperty(
635 resolved, 577 resolved, factory->NewStringFromStaticChars("sensitivity"),
636 factory->NewStringFromStaticAscii("sensitivity"), 578 factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
637 factory->NewStringFromStaticAscii("variant"),
638 SLOPPY).Assert();
639 } 579 }
640 580
641 JSObject::SetProperty( 581 JSObject::SetProperty(
642 resolved, 582 resolved, factory->NewStringFromStaticChars("ignorePunctuation"),
643 factory->NewStringFromStaticAscii("ignorePunctuation"), 583 factory->ToBoolean(collator->getAttribute(UCOL_ALTERNATE_HANDLING,
644 factory->ToBoolean(collator->getAttribute( 584 status) == UCOL_SHIFTED),
645 UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED),
646 SLOPPY).Assert(); 585 SLOPPY).Assert();
647 586
648 // Set the locale 587 // Set the locale
649 char result[ULOC_FULLNAME_CAPACITY]; 588 char result[ULOC_FULLNAME_CAPACITY];
650 status = U_ZERO_ERROR; 589 status = U_ZERO_ERROR;
651 uloc_toLanguageTag( 590 uloc_toLanguageTag(
652 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); 591 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
653 if (U_SUCCESS(status)) { 592 if (U_SUCCESS(status)) {
654 JSObject::SetProperty( 593 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
655 resolved, 594 factory->NewStringFromAsciiChecked(result),
656 factory->NewStringFromStaticAscii("locale"), 595 SLOPPY).Assert();
657 factory->NewStringFromAsciiChecked(result),
658 SLOPPY).Assert();
659 } else { 596 } else {
660 // This would never happen, since we got the locale from ICU. 597 // This would never happen, since we got the locale from ICU.
661 JSObject::SetProperty( 598 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
662 resolved, 599 factory->NewStringFromStaticChars("und"),
663 factory->NewStringFromStaticAscii("locale"), 600 SLOPPY).Assert();
664 factory->NewStringFromStaticAscii("und"),
665 SLOPPY).Assert();
666 } 601 }
667 } 602 }
668 603
669 604
670 icu::BreakIterator* CreateICUBreakIterator( 605 icu::BreakIterator* CreateICUBreakIterator(
671 Isolate* isolate, 606 Isolate* isolate,
672 const icu::Locale& icu_locale, 607 const icu::Locale& icu_locale,
673 Handle<JSObject> options) { 608 Handle<JSObject> options) {
674 UErrorCode status = U_ZERO_ERROR; 609 UErrorCode status = U_ZERO_ERROR;
675 icu::BreakIterator* break_iterator = NULL; 610 icu::BreakIterator* break_iterator = NULL;
(...skipping 30 matching lines...) Expand all
706 Handle<JSObject> resolved) { 641 Handle<JSObject> resolved) {
707 Factory* factory = isolate->factory(); 642 Factory* factory = isolate->factory();
708 UErrorCode status = U_ZERO_ERROR; 643 UErrorCode status = U_ZERO_ERROR;
709 644
710 // Set the locale 645 // Set the locale
711 char result[ULOC_FULLNAME_CAPACITY]; 646 char result[ULOC_FULLNAME_CAPACITY];
712 status = U_ZERO_ERROR; 647 status = U_ZERO_ERROR;
713 uloc_toLanguageTag( 648 uloc_toLanguageTag(
714 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); 649 icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
715 if (U_SUCCESS(status)) { 650 if (U_SUCCESS(status)) {
716 JSObject::SetProperty( 651 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
717 resolved, 652 factory->NewStringFromAsciiChecked(result),
718 factory->NewStringFromStaticAscii("locale"), 653 SLOPPY).Assert();
719 factory->NewStringFromAsciiChecked(result),
720 SLOPPY).Assert();
721 } else { 654 } else {
722 // This would never happen, since we got the locale from ICU. 655 // This would never happen, since we got the locale from ICU.
723 JSObject::SetProperty( 656 JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
724 resolved, 657 factory->NewStringFromStaticChars("und"),
725 factory->NewStringFromStaticAscii("locale"), 658 SLOPPY).Assert();
726 factory->NewStringFromStaticAscii("und"),
727 SLOPPY).Assert();
728 } 659 }
729 } 660 }
730 661
731 } // namespace 662 } // namespace
732 663
733 664
734 // static 665 // static
735 Handle<ObjectTemplateInfo> I18N::GetTemplate(Isolate* isolate) { 666 Handle<ObjectTemplateInfo> I18N::GetTemplate(Isolate* isolate) {
736 return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate); 667 return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate);
737 } 668 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 710 }
780 711
781 return date_format; 712 return date_format;
782 } 713 }
783 714
784 715
785 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( 716 icu::SimpleDateFormat* DateFormat::UnpackDateFormat(
786 Isolate* isolate, 717 Isolate* isolate,
787 Handle<JSObject> obj) { 718 Handle<JSObject> obj) {
788 Handle<String> key = 719 Handle<String> key =
789 isolate->factory()->NewStringFromStaticAscii("dateFormat"); 720 isolate->factory()->NewStringFromStaticChars("dateFormat");
790 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); 721 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
791 CHECK(maybe.has_value); 722 CHECK(maybe.has_value);
792 if (maybe.value) { 723 if (maybe.value) {
793 return reinterpret_cast<icu::SimpleDateFormat*>( 724 return reinterpret_cast<icu::SimpleDateFormat*>(
794 obj->GetInternalField(0)); 725 obj->GetInternalField(0));
795 } 726 }
796 727
797 return NULL; 728 return NULL;
798 } 729 }
799 730
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 786 }
856 787
857 return number_format; 788 return number_format;
858 } 789 }
859 790
860 791
861 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( 792 icu::DecimalFormat* NumberFormat::UnpackNumberFormat(
862 Isolate* isolate, 793 Isolate* isolate,
863 Handle<JSObject> obj) { 794 Handle<JSObject> obj) {
864 Handle<String> key = 795 Handle<String> key =
865 isolate->factory()->NewStringFromStaticAscii("numberFormat"); 796 isolate->factory()->NewStringFromStaticChars("numberFormat");
866 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); 797 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
867 CHECK(maybe.has_value); 798 CHECK(maybe.has_value);
868 if (maybe.value) { 799 if (maybe.value) {
869 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); 800 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0));
870 } 801 }
871 802
872 return NULL; 803 return NULL;
873 } 804 }
874 805
875 806
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } else { 843 } else {
913 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved); 844 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved);
914 } 845 }
915 846
916 return collator; 847 return collator;
917 } 848 }
918 849
919 850
920 icu::Collator* Collator::UnpackCollator(Isolate* isolate, 851 icu::Collator* Collator::UnpackCollator(Isolate* isolate,
921 Handle<JSObject> obj) { 852 Handle<JSObject> obj) {
922 Handle<String> key = isolate->factory()->NewStringFromStaticAscii("collator"); 853 Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator");
923 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); 854 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
924 CHECK(maybe.has_value); 855 CHECK(maybe.has_value);
925 if (maybe.value) { 856 if (maybe.value) {
926 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); 857 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0));
927 } 858 }
928 859
929 return NULL; 860 return NULL;
930 } 861 }
931 862
932 863
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 isolate, icu_locale, break_iterator, resolved); 904 isolate, icu_locale, break_iterator, resolved);
974 } 905 }
975 906
976 return break_iterator; 907 return break_iterator;
977 } 908 }
978 909
979 910
980 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, 911 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
981 Handle<JSObject> obj) { 912 Handle<JSObject> obj) {
982 Handle<String> key = 913 Handle<String> key =
983 isolate->factory()->NewStringFromStaticAscii("breakIterator"); 914 isolate->factory()->NewStringFromStaticChars("breakIterator");
984 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); 915 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
985 CHECK(maybe.has_value); 916 CHECK(maybe.has_value);
986 if (maybe.value) { 917 if (maybe.value) {
987 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); 918 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0));
988 } 919 }
989 920
990 return NULL; 921 return NULL;
991 } 922 }
992 923
993 924
994 void BreakIterator::DeleteBreakIterator( 925 void BreakIterator::DeleteBreakIterator(
995 const v8::WeakCallbackData<v8::Value, void>& data) { 926 const v8::WeakCallbackData<v8::Value, void>& data) {
996 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); 927 DeleteNativeObjectAt<icu::BreakIterator>(data, 0);
997 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); 928 DeleteNativeObjectAt<icu::UnicodeString>(data, 1);
998 DestroyGlobalHandle(data); 929 DestroyGlobalHandle(data);
999 } 930 }
1000 931
1001 } } // namespace v8::internal 932 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/code-stubs-ia32.h » ('j') | src/jsregexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698