| OLD | NEW |
| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 SLOPPY).Assert(); | 388 SLOPPY).Assert(); |
| 389 | 389 |
| 390 JSObject::SetProperty( | 390 JSObject::SetProperty( |
| 391 resolved, factory->NewStringFromStaticChars("maximumFractionDigits"), | 391 resolved, factory->NewStringFromStaticChars("maximumFractionDigits"), |
| 392 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()), | 392 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()), |
| 393 SLOPPY).Assert(); | 393 SLOPPY).Assert(); |
| 394 | 394 |
| 395 Handle<String> key = | 395 Handle<String> key = |
| 396 factory->NewStringFromStaticChars("minimumSignificantDigits"); | 396 factory->NewStringFromStaticChars("minimumSignificantDigits"); |
| 397 Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key); | 397 Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key); |
| 398 CHECK(maybe.has_value); | 398 CHECK(maybe.IsJust()); |
| 399 if (maybe.value) { | 399 if (maybe.FromJust()) { |
| 400 JSObject::SetProperty( | 400 JSObject::SetProperty( |
| 401 resolved, factory->NewStringFromStaticChars("minimumSignificantDigits"), | 401 resolved, factory->NewStringFromStaticChars("minimumSignificantDigits"), |
| 402 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()), | 402 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()), |
| 403 SLOPPY).Assert(); | 403 SLOPPY).Assert(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 key = factory->NewStringFromStaticChars("maximumSignificantDigits"); | 406 key = factory->NewStringFromStaticChars("maximumSignificantDigits"); |
| 407 maybe = JSReceiver::HasOwnProperty(resolved, key); | 407 maybe = JSReceiver::HasOwnProperty(resolved, key); |
| 408 CHECK(maybe.has_value); | 408 CHECK(maybe.IsJust()); |
| 409 if (maybe.value) { | 409 if (maybe.FromJust()) { |
| 410 JSObject::SetProperty( | 410 JSObject::SetProperty( |
| 411 resolved, factory->NewStringFromStaticChars("maximumSignificantDigits"), | 411 resolved, factory->NewStringFromStaticChars("maximumSignificantDigits"), |
| 412 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()), | 412 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()), |
| 413 SLOPPY).Assert(); | 413 SLOPPY).Assert(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 // Set the locale | 416 // Set the locale |
| 417 char result[ULOC_FULLNAME_CAPACITY]; | 417 char result[ULOC_FULLNAME_CAPACITY]; |
| 418 status = U_ZERO_ERROR; | 418 status = U_ZERO_ERROR; |
| 419 uloc_toLanguageTag( | 419 uloc_toLanguageTag( |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 return date_format; | 718 return date_format; |
| 719 } | 719 } |
| 720 | 720 |
| 721 | 721 |
| 722 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( | 722 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( |
| 723 Isolate* isolate, | 723 Isolate* isolate, |
| 724 Handle<JSObject> obj) { | 724 Handle<JSObject> obj) { |
| 725 Handle<String> key = | 725 Handle<String> key = |
| 726 isolate->factory()->NewStringFromStaticChars("dateFormat"); | 726 isolate->factory()->NewStringFromStaticChars("dateFormat"); |
| 727 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | 727 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); |
| 728 CHECK(maybe.has_value); | 728 CHECK(maybe.IsJust()); |
| 729 if (maybe.value) { | 729 if (maybe.FromJust()) { |
| 730 return reinterpret_cast<icu::SimpleDateFormat*>( | 730 return reinterpret_cast<icu::SimpleDateFormat*>( |
| 731 obj->GetInternalField(0)); | 731 obj->GetInternalField(0)); |
| 732 } | 732 } |
| 733 | 733 |
| 734 return NULL; | 734 return NULL; |
| 735 } | 735 } |
| 736 | 736 |
| 737 | 737 |
| 738 template<class T> | 738 template<class T> |
| 739 void DeleteNativeObjectAt(const v8::WeakCallbackData<v8::Value, void>& data, | 739 void DeleteNativeObjectAt(const v8::WeakCallbackData<v8::Value, void>& data, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 return number_format; | 798 return number_format; |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| 802 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( | 802 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( |
| 803 Isolate* isolate, | 803 Isolate* isolate, |
| 804 Handle<JSObject> obj) { | 804 Handle<JSObject> obj) { |
| 805 Handle<String> key = | 805 Handle<String> key = |
| 806 isolate->factory()->NewStringFromStaticChars("numberFormat"); | 806 isolate->factory()->NewStringFromStaticChars("numberFormat"); |
| 807 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | 807 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); |
| 808 CHECK(maybe.has_value); | 808 CHECK(maybe.IsJust()); |
| 809 if (maybe.value) { | 809 if (maybe.FromJust()) { |
| 810 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); | 810 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); |
| 811 } | 811 } |
| 812 | 812 |
| 813 return NULL; | 813 return NULL; |
| 814 } | 814 } |
| 815 | 815 |
| 816 | 816 |
| 817 void NumberFormat::DeleteNumberFormat( | 817 void NumberFormat::DeleteNumberFormat( |
| 818 const v8::WeakCallbackData<v8::Value, void>& data) { | 818 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 819 DeleteNativeObjectAt<icu::DecimalFormat>(data, 0); | 819 DeleteNativeObjectAt<icu::DecimalFormat>(data, 0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } | 859 } |
| 860 | 860 |
| 861 return collator; | 861 return collator; |
| 862 } | 862 } |
| 863 | 863 |
| 864 | 864 |
| 865 icu::Collator* Collator::UnpackCollator(Isolate* isolate, | 865 icu::Collator* Collator::UnpackCollator(Isolate* isolate, |
| 866 Handle<JSObject> obj) { | 866 Handle<JSObject> obj) { |
| 867 Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator"); | 867 Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator"); |
| 868 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | 868 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); |
| 869 CHECK(maybe.has_value); | 869 CHECK(maybe.IsJust()); |
| 870 if (maybe.value) { | 870 if (maybe.FromJust()) { |
| 871 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); | 871 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); |
| 872 } | 872 } |
| 873 | 873 |
| 874 return NULL; | 874 return NULL; |
| 875 } | 875 } |
| 876 | 876 |
| 877 | 877 |
| 878 void Collator::DeleteCollator( | 878 void Collator::DeleteCollator( |
| 879 const v8::WeakCallbackData<v8::Value, void>& data) { | 879 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 880 DeleteNativeObjectAt<icu::Collator>(data, 0); | 880 DeleteNativeObjectAt<icu::Collator>(data, 0); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 | 924 |
| 925 return break_iterator; | 925 return break_iterator; |
| 926 } | 926 } |
| 927 | 927 |
| 928 | 928 |
| 929 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, | 929 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, |
| 930 Handle<JSObject> obj) { | 930 Handle<JSObject> obj) { |
| 931 Handle<String> key = | 931 Handle<String> key = |
| 932 isolate->factory()->NewStringFromStaticChars("breakIterator"); | 932 isolate->factory()->NewStringFromStaticChars("breakIterator"); |
| 933 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | 933 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); |
| 934 CHECK(maybe.has_value); | 934 CHECK(maybe.IsJust()); |
| 935 if (maybe.value) { | 935 if (maybe.FromJust()) { |
| 936 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); | 936 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); |
| 937 } | 937 } |
| 938 | 938 |
| 939 return NULL; | 939 return NULL; |
| 940 } | 940 } |
| 941 | 941 |
| 942 | 942 |
| 943 void BreakIterator::DeleteBreakIterator( | 943 void BreakIterator::DeleteBreakIterator( |
| 944 const v8::WeakCallbackData<v8::Value, void>& data) { | 944 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 945 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); | 945 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); |
| 946 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); | 946 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); |
| 947 DestroyGlobalHandle(data); | 947 DestroyGlobalHandle(data); |
| 948 } | 948 } |
| 949 | 949 |
| 950 } } // namespace v8::internal | 950 } } // namespace v8::internal |
| OLD | NEW |