Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 4 |
| 5 | 5 |
| 6 #ifdef V8_I18N_SUPPORT | 6 #ifdef V8_I18N_SUPPORT |
| 7 #include "src/runtime/runtime-utils.h" | 7 #include "src/runtime/runtime-utils.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 | 545 |
| 546 icu::UnicodeString result; | 546 icu::UnicodeString result; |
| 547 number_format->format(value->Number(), result); | 547 number_format->format(value->Number(), result); |
| 548 | 548 |
| 549 RETURN_RESULT_OR_FAILURE( | 549 RETURN_RESULT_OR_FAILURE( |
| 550 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 550 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( |
| 551 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 551 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 552 result.length()))); | 552 result.length()))); |
| 553 } | 553 } |
| 554 | 554 |
| 555 RUNTIME_FUNCTION(Runtime_CurrencyDigits) { | |
| 556 DCHECK_EQ(1, args.length()); | |
| 557 | |
| 558 CONVERT_ARG_HANDLE_CHECKED(String, currency, 0); | |
| 559 | |
| 560 v8::String::Utf8Value currency_string(v8::Utils::ToLocal(currency)); | |
|
jungshik at Google
2017/03/21 20:29:34
JFYI: I tried to avoid this pattern ( see lines 41
Dan Ehrenberg
2017/04/07 11:34:00
What's the right way to avoid it when constructing
| |
| 561 icu::UnicodeString currency_icu = | |
| 562 icu::UnicodeString::fromUTF8(*currency_string); | |
| 563 | |
| 564 DisallowHeapAllocation no_gc; | |
| 565 UErrorCode status = U_ZERO_ERROR; | |
| 566 #if U_ICU_VERSION_MAJOR_NUM >= 59 | |
| 567 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
| 568 icu::toUCharPtr(currency.getTerminatedBuffer()), &status_digits); | |
|
jungshik at Google
2017/03/21 20:29:35
You meant currency_icu here? It seems that it's a
Dan Ehrenberg
2017/04/07 11:34:00
Oops, fixed
| |
| 569 #else | |
| 570 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
| 571 currency.getTerminatedBuffer(), &status_digits); | |
|
jungshik at Google
2017/03/21 20:29:35
same here..
It's a pity that ucurr_getDefaultFra
| |
| 572 #endif | |
| 573 // For missing currency codes, default to the most common, 2 | |
| 574 if (!U_SUCCESS(status)) fraction_digits = 2; | |
| 575 return Smi::FromInt(fraction_digits); | |
| 576 } | |
| 555 | 577 |
| 556 RUNTIME_FUNCTION(Runtime_CreateCollator) { | 578 RUNTIME_FUNCTION(Runtime_CreateCollator) { |
| 557 HandleScope scope(isolate); | 579 HandleScope scope(isolate); |
| 558 | 580 |
| 559 DCHECK_EQ(3, args.length()); | 581 DCHECK_EQ(3, args.length()); |
| 560 | 582 |
| 561 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 583 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 562 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 584 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 563 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 585 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 564 | 586 |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 Handle<FixedArray> date_cache_version = | 1204 Handle<FixedArray> date_cache_version = |
| 1183 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 1205 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
| 1184 EternalHandles::DATE_CACHE_VERSION)); | 1206 EternalHandles::DATE_CACHE_VERSION)); |
| 1185 return date_cache_version->get(0); | 1207 return date_cache_version->get(0); |
| 1186 } | 1208 } |
| 1187 | 1209 |
| 1188 } // namespace internal | 1210 } // namespace internal |
| 1189 } // namespace v8 | 1211 } // namespace v8 |
| 1190 | 1212 |
| 1191 #endif // V8_I18N_SUPPORT | 1213 #endif // V8_I18N_SUPPORT |
| OLD | NEW |