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

Side by Side Diff: src/i18n.cc

Issue 418383002: Change Has* and Get*Attributes to return Maybe<*>, indicating possible exceptions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/contexts.cc ('k') | src/isolate.h » ('j') | src/objects-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 SLOPPY).Assert(); 412 SLOPPY).Assert();
413 413
414 JSObject::SetProperty( 414 JSObject::SetProperty(
415 resolved, 415 resolved,
416 factory->NewStringFromStaticAscii("maximumFractionDigits"), 416 factory->NewStringFromStaticAscii("maximumFractionDigits"),
417 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()), 417 factory->NewNumberFromInt(number_format->getMaximumFractionDigits()),
418 SLOPPY).Assert(); 418 SLOPPY).Assert();
419 419
420 Handle<String> key = 420 Handle<String> key =
421 factory->NewStringFromStaticAscii("minimumSignificantDigits"); 421 factory->NewStringFromStaticAscii("minimumSignificantDigits");
422 if (JSReceiver::HasOwnProperty(resolved, key)) { 422 Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key);
423 CHECK(maybe.has_value);
424 if (maybe.value) {
423 JSObject::SetProperty( 425 JSObject::SetProperty(
424 resolved, 426 resolved,
425 factory->NewStringFromStaticAscii("minimumSignificantDigits"), 427 factory->NewStringFromStaticAscii("minimumSignificantDigits"),
426 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()), 428 factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()),
427 SLOPPY).Assert(); 429 SLOPPY).Assert();
428 } 430 }
429 431
430 key = factory->NewStringFromStaticAscii("maximumSignificantDigits"); 432 key = factory->NewStringFromStaticAscii("maximumSignificantDigits");
431 if (JSReceiver::HasOwnProperty(resolved, key)) { 433 maybe = JSReceiver::HasOwnProperty(resolved, key);
434 CHECK(maybe.has_value);
435 if (maybe.value) {
432 JSObject::SetProperty( 436 JSObject::SetProperty(
433 resolved, 437 resolved,
434 factory->NewStringFromStaticAscii("maximumSignificantDigits"), 438 factory->NewStringFromStaticAscii("maximumSignificantDigits"),
435 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()), 439 factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()),
436 SLOPPY).Assert(); 440 SLOPPY).Assert();
437 } 441 }
438 442
439 // Set the locale 443 // Set the locale
440 char result[ULOC_FULLNAME_CAPACITY]; 444 char result[ULOC_FULLNAME_CAPACITY];
441 status = U_ZERO_ERROR; 445 status = U_ZERO_ERROR;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 780
777 return date_format; 781 return date_format;
778 } 782 }
779 783
780 784
781 icu::SimpleDateFormat* DateFormat::UnpackDateFormat( 785 icu::SimpleDateFormat* DateFormat::UnpackDateFormat(
782 Isolate* isolate, 786 Isolate* isolate,
783 Handle<JSObject> obj) { 787 Handle<JSObject> obj) {
784 Handle<String> key = 788 Handle<String> key =
785 isolate->factory()->NewStringFromStaticAscii("dateFormat"); 789 isolate->factory()->NewStringFromStaticAscii("dateFormat");
786 if (JSReceiver::HasOwnProperty(obj, key)) { 790 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
791 CHECK(maybe.has_value);
792 if (maybe.value) {
787 return reinterpret_cast<icu::SimpleDateFormat*>( 793 return reinterpret_cast<icu::SimpleDateFormat*>(
788 obj->GetInternalField(0)); 794 obj->GetInternalField(0));
789 } 795 }
790 796
791 return NULL; 797 return NULL;
792 } 798 }
793 799
794 800
795 template<class T> 801 template<class T>
796 void DeleteNativeObjectAt(const v8::WeakCallbackData<v8::Value, void>& data, 802 void DeleteNativeObjectAt(const v8::WeakCallbackData<v8::Value, void>& data,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 856
851 return number_format; 857 return number_format;
852 } 858 }
853 859
854 860
855 icu::DecimalFormat* NumberFormat::UnpackNumberFormat( 861 icu::DecimalFormat* NumberFormat::UnpackNumberFormat(
856 Isolate* isolate, 862 Isolate* isolate,
857 Handle<JSObject> obj) { 863 Handle<JSObject> obj) {
858 Handle<String> key = 864 Handle<String> key =
859 isolate->factory()->NewStringFromStaticAscii("numberFormat"); 865 isolate->factory()->NewStringFromStaticAscii("numberFormat");
860 if (JSReceiver::HasOwnProperty(obj, key)) { 866 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
867 CHECK(maybe.has_value);
868 if (maybe.value) {
861 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0)); 869 return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0));
862 } 870 }
863 871
864 return NULL; 872 return NULL;
865 } 873 }
866 874
867 875
868 void NumberFormat::DeleteNumberFormat( 876 void NumberFormat::DeleteNumberFormat(
869 const v8::WeakCallbackData<v8::Value, void>& data) { 877 const v8::WeakCallbackData<v8::Value, void>& data) {
870 DeleteNativeObjectAt<icu::DecimalFormat>(data, 0); 878 DeleteNativeObjectAt<icu::DecimalFormat>(data, 0);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved); 913 SetResolvedCollatorSettings(isolate, icu_locale, collator, resolved);
906 } 914 }
907 915
908 return collator; 916 return collator;
909 } 917 }
910 918
911 919
912 icu::Collator* Collator::UnpackCollator(Isolate* isolate, 920 icu::Collator* Collator::UnpackCollator(Isolate* isolate,
913 Handle<JSObject> obj) { 921 Handle<JSObject> obj) {
914 Handle<String> key = isolate->factory()->NewStringFromStaticAscii("collator"); 922 Handle<String> key = isolate->factory()->NewStringFromStaticAscii("collator");
915 if (JSReceiver::HasOwnProperty(obj, key)) { 923 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
924 CHECK(maybe.has_value);
925 if (maybe.value) {
916 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0)); 926 return reinterpret_cast<icu::Collator*>(obj->GetInternalField(0));
917 } 927 }
918 928
919 return NULL; 929 return NULL;
920 } 930 }
921 931
922 932
923 void Collator::DeleteCollator( 933 void Collator::DeleteCollator(
924 const v8::WeakCallbackData<v8::Value, void>& data) { 934 const v8::WeakCallbackData<v8::Value, void>& data) {
925 DeleteNativeObjectAt<icu::Collator>(data, 0); 935 DeleteNativeObjectAt<icu::Collator>(data, 0);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 974 }
965 975
966 return break_iterator; 976 return break_iterator;
967 } 977 }
968 978
969 979
970 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate, 980 icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
971 Handle<JSObject> obj) { 981 Handle<JSObject> obj) {
972 Handle<String> key = 982 Handle<String> key =
973 isolate->factory()->NewStringFromStaticAscii("breakIterator"); 983 isolate->factory()->NewStringFromStaticAscii("breakIterator");
974 if (JSReceiver::HasOwnProperty(obj, key)) { 984 Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
985 CHECK(maybe.has_value);
986 if (maybe.value) {
975 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0)); 987 return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0));
976 } 988 }
977 989
978 return NULL; 990 return NULL;
979 } 991 }
980 992
981 993
982 void BreakIterator::DeleteBreakIterator( 994 void BreakIterator::DeleteBreakIterator(
983 const v8::WeakCallbackData<v8::Value, void>& data) { 995 const v8::WeakCallbackData<v8::Value, void>& data) {
984 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); 996 DeleteNativeObjectAt<icu::BreakIterator>(data, 0);
985 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); 997 DeleteNativeObjectAt<icu::UnicodeString>(data, 1);
986 DestroyGlobalHandle(data); 998 DestroyGlobalHandle(data);
987 } 999 }
988 1000
989 } } // namespace v8::internal 1001 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | src/isolate.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698