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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 | 544 |
545 icu::UnicodeString result; | 545 icu::UnicodeString result; |
546 number_format->format(value->Number(), result); | 546 number_format->format(value->Number(), result); |
547 | 547 |
548 RETURN_RESULT_OR_FAILURE( | 548 RETURN_RESULT_OR_FAILURE( |
549 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 549 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( |
550 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 550 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
551 result.length()))); | 551 result.length()))); |
552 } | 552 } |
553 | 553 |
554 RUNTIME_FUNCTION(Runtime_CurrencyDigits) { | |
555 DCHECK_EQ(1, args.length()); | |
556 | |
557 CONVERT_ARG_HANDLE_CHECKED(String, currency, 0); | |
558 | |
559 v8::String::Utf8Value currency_string(v8::Utils::ToLocal(currency)); | |
560 icu::UnicodeString currency_icu = | |
561 icu::UnicodeString::fromUTF8(*currency_string); | |
562 | |
563 { | |
adamk
2017/03/16 22:47:49
Nit: no need for this block, since its ending brac
Dan Ehrenberg
2017/03/17 09:36:01
Fixed
| |
564 DisallowHeapAllocation no_gc; | |
565 UErrorCode status = U_ZERO_ERROR; | |
566 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
567 currency_icu.getTerminatedBuffer(), &status); | |
568 // For missing currency codes, default to the most common, 2 | |
569 if (!U_SUCCESS(status)) fraction_digits = 2; | |
570 return Smi::FromInt(fraction_digits); | |
571 } | |
572 } | |
554 | 573 |
555 RUNTIME_FUNCTION(Runtime_CreateCollator) { | 574 RUNTIME_FUNCTION(Runtime_CreateCollator) { |
556 HandleScope scope(isolate); | 575 HandleScope scope(isolate); |
557 | 576 |
558 DCHECK_EQ(3, args.length()); | 577 DCHECK_EQ(3, args.length()); |
559 | 578 |
560 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 579 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
561 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 580 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
562 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 581 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
563 | 582 |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 Handle<FixedArray> date_cache_version = | 1199 Handle<FixedArray> date_cache_version = |
1181 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 1200 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
1182 EternalHandles::DATE_CACHE_VERSION)); | 1201 EternalHandles::DATE_CACHE_VERSION)); |
1183 return date_cache_version->get(0); | 1202 return date_cache_version->get(0); |
1184 } | 1203 } |
1185 | 1204 |
1186 } // namespace internal | 1205 } // namespace internal |
1187 } // namespace v8 | 1206 } // namespace v8 |
1188 | 1207 |
1189 #endif // V8_I18N_SUPPORT | 1208 #endif // V8_I18N_SUPPORT |
OLD | NEW |