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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 SetResolvedDateSettings(isolate, icu_locale, date_format, resolved); | 753 SetResolvedDateSettings(isolate, icu_locale, date_format, resolved); |
754 } | 754 } |
755 | 755 |
756 return date_format; | 756 return date_format; |
757 } | 757 } |
758 | 758 |
759 | 759 |
760 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( | 760 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( |
761 Isolate* isolate, | 761 Isolate* isolate, |
762 Handle<JSObject> obj) { | 762 Handle<JSObject> obj) { |
763 Handle<String> key = | 763 return reinterpret_cast<icu::SimpleDateFormat*>(obj->GetInternalField(0)); |
764 isolate->factory()->NewStringFromStaticChars("dateFormat"); | |
765 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | |
766 CHECK(maybe.IsJust()); | |
767 if (maybe.FromJust()) { | |
768 return reinterpret_cast<icu::SimpleDateFormat*>( | |
769 obj->GetInternalField(0)); | |
770 } | |
771 | |
772 return NULL; | |
773 } | 764 } |
774 | 765 |
775 void DateFormat::DeleteDateFormat(const v8::WeakCallbackInfo<void>& data) { | 766 void DateFormat::DeleteDateFormat(const v8::WeakCallbackInfo<void>& data) { |
776 delete reinterpret_cast<icu::SimpleDateFormat*>(data.GetInternalField(0)); | 767 delete reinterpret_cast<icu::SimpleDateFormat*>(data.GetInternalField(0)); |
777 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 768 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
778 } | 769 } |
779 | 770 |
780 | 771 |
781 icu::DecimalFormat* NumberFormat::InitializeNumberFormat( | 772 icu::DecimalFormat* NumberFormat::InitializeNumberFormat( |
782 Isolate* isolate, | 773 Isolate* isolate, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 SetResolvedNumberSettings(isolate, icu_locale, number_format, resolved); | 808 SetResolvedNumberSettings(isolate, icu_locale, number_format, resolved); |
818 } | 809 } |
819 | 810 |
820 return number_format; | 811 return number_format; |
821 } | 812 } |
822 | 813 |
823 | 814 |
824 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( | 815 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( |
825 Isolate* isolate, | 816 Isolate* isolate, |
826 Handle<JSObject> obj) { | 817 Handle<JSObject> obj) { |
827 Handle<String> key = | 818 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); |
828 isolate->factory()->NewStringFromStaticChars("numberFormat"); | |
829 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | |
830 CHECK(maybe.IsJust()); | |
831 if (maybe.FromJust()) { | |
832 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); | |
833 } | |
834 | |
835 return NULL; | |
836 } | 819 } |
837 | 820 |
838 void NumberFormat::DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data) { | 821 void NumberFormat::DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data) { |
839 delete reinterpret_cast<icu::DecimalFormat*>(data.GetInternalField(0)); | 822 delete reinterpret_cast<icu::DecimalFormat*>(data.GetInternalField(0)); |
840 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 823 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
841 } | 824 } |
842 | 825 |
843 | 826 |
844 icu::Collator* Collator::InitializeCollator( | 827 icu::Collator* Collator::InitializeCollator( |
845 Isolate* isolate, | 828 Isolate* isolate, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 } else { | 860 } else { |
878 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved); | 861 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved); |
879 } | 862 } |
880 | 863 |
881 return collator; | 864 return collator; |
882 } | 865 } |
883 | 866 |
884 | 867 |
885 icu::Collator* Collator::UnpackCollator(Isolate* isolate, | 868 icu::Collator* Collator::UnpackCollator(Isolate* isolate, |
886 Handle<JSObject> obj) { | 869 Handle<JSObject> obj) { |
887 Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator"); | 870 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); |
888 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | |
889 CHECK(maybe.IsJust()); | |
890 if (maybe.FromJust()) { | |
891 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); | |
892 } | |
893 | |
894 return NULL; | |
895 } | 871 } |
896 | 872 |
897 void Collator::DeleteCollator(const v8::WeakCallbackInfo<void>& data) { | 873 void Collator::DeleteCollator(const v8::WeakCallbackInfo<void>& data) { |
898 delete reinterpret_cast<icu::Collator*>(data.GetInternalField(0)); | 874 delete reinterpret_cast<icu::Collator*>(data.GetInternalField(0)); |
899 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 875 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
900 } | 876 } |
901 | 877 |
902 | 878 |
903 icu::BreakIterator* BreakIterator::InitializeBreakIterator( | 879 icu::BreakIterator* BreakIterator::InitializeBreakIterator( |
904 Isolate* isolate, | 880 Isolate* isolate, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 SetResolvedBreakIteratorSettings( | 915 SetResolvedBreakIteratorSettings( |
940 isolate, icu_locale, break_iterator, resolved); | 916 isolate, icu_locale, break_iterator, resolved); |
941 } | 917 } |
942 | 918 |
943 return break_iterator; | 919 return break_iterator; |
944 } | 920 } |
945 | 921 |
946 | 922 |
947 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, | 923 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, |
948 Handle<JSObject> obj) { | 924 Handle<JSObject> obj) { |
949 Handle<String> key = | 925 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); |
950 isolate->factory()->NewStringFromStaticChars("breakIterator"); | |
951 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key); | |
952 CHECK(maybe.IsJust()); | |
953 if (maybe.FromJust()) { | |
954 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); | |
955 } | |
956 | |
957 return NULL; | |
958 } | 926 } |
959 | 927 |
960 void BreakIterator::DeleteBreakIterator( | 928 void BreakIterator::DeleteBreakIterator( |
961 const v8::WeakCallbackInfo<void>& data) { | 929 const v8::WeakCallbackInfo<void>& data) { |
962 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); | 930 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); |
963 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); | 931 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); |
964 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 932 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
965 } | 933 } |
966 | 934 |
967 } // namespace internal | 935 } // namespace internal |
968 } // namespace v8 | 936 } // namespace v8 |
OLD | NEW |