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

Side by Side Diff: third_party/icu/source/i18n/calendar.cpp

Issue 6520018: Get ICU 4.6 to be compiled without RTTI.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: do not include typeinfo at all Created 9 years, 10 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 | « third_party/icu/source/i18n/brktrans.cpp ('k') | third_party/icu/source/i18n/coll.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 1997-2010, International Business Machines Corporation and * 3 * Copyright (C) 1997-2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. * 4 * others. All Rights Reserved. *
5 ******************************************************************************* 5 *******************************************************************************
6 * 6 *
7 * File CALENDAR.CPP 7 * File CALENDAR.CPP
8 * 8 *
9 * Modification History: 9 * Modification History:
10 * 10 *
11 * Date Name Description 11 * Date Name Description
12 * 02/03/97 clhuang Creation. 12 * 02/03/97 clhuang Creation.
13 * 04/22/97 aliu Cleaned up, fixed memory leak, made 13 * 04/22/97 aliu Cleaned up, fixed memory leak, made
14 * setWeekCountData() more robust. 14 * setWeekCountData() more robust.
15 * Moved platform code to TPlatformUtilities. 15 * Moved platform code to TPlatformUtilities.
16 * 05/01/97 aliu Made equals(), before(), after() arguments const. 16 * 05/01/97 aliu Made equals(), before(), after() arguments const.
17 * 05/20/97 aliu Changed logic of when to compute fields and time 17 * 05/20/97 aliu Changed logic of when to compute fields and time
18 * to fix bugs. 18 * to fix bugs.
19 * 08/12/97 aliu Added equivalentTo. Misc other fixes. 19 * 08/12/97 aliu Added equivalentTo. Misc other fixes.
20 * 07/28/98 stephen Sync up with JDK 1.2 20 * 07/28/98 stephen Sync up with JDK 1.2
21 * 09/02/98 stephen Sync with JDK 1.2 8/31 build (getActualMin/Max) 21 * 09/02/98 stephen Sync with JDK 1.2 8/31 build (getActualMin/Max)
22 * 03/17/99 stephen Changed adoptTimeZone() - now fAreFieldsSet is 22 * 03/17/99 stephen Changed adoptTimeZone() - now fAreFieldsSet is
23 * set to FALSE to force update of time. 23 * set to FALSE to force update of time.
24 ******************************************************************************* 24 *******************************************************************************
25 */ 25 */
26 26
27 #include <typeinfo> // for 'typeid' to work
28 27
29 #include "unicode/utypes.h" 28 #include "unicode/utypes.h"
30 29
31 #if !UCONFIG_NO_FORMATTING 30 #if !UCONFIG_NO_FORMATTING
32 31
33 #include "unicode/gregocal.h" 32 #include "unicode/gregocal.h"
34 #include "gregoimp.h" 33 #include "gregoimp.h"
35 #include "buddhcal.h" 34 #include "buddhcal.h"
36 #include "taiwncal.h" 35 #include "taiwncal.h"
37 #include "japancal.h" 36 #include "japancal.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 UnicodeString id((UChar)0x40); /* '@' a variant character */ 365 UnicodeString id((UChar)0x40); /* '@' a variant character */
367 id.append(UNICODE_STRING_SIMPLE("calendar=")); 366 id.append(UNICODE_STRING_SIMPLE("calendar="));
368 id.append(UnicodeString(gCalTypes[i], -1, US_INV)); 367 id.append(UnicodeString(gCalTypes[i], -1, US_INV));
369 result.put(id, (void*)this, status); 368 result.put(id, (void*)this, status);
370 } 369 }
371 } 370 }
372 } 371 }
373 372
374 virtual UObject* create(const ICUServiceKey& key, const ICUService* /*servic e*/, UErrorCode& status) const { 373 virtual UObject* create(const ICUServiceKey& key, const ICUService* /*servic e*/, UErrorCode& status) const {
375 #ifdef U_DEBUG_CALSVC 374 #ifdef U_DEBUG_CALSVC
376 if(dynamic_cast<const LocaleKey*>(&key) == NULL) { 375 if(CR_DYNAMIC_CAST<const LocaleKey*>(&key) == NULL) {
377 fprintf(stderr, "::create - not a LocaleKey!\n"); 376 fprintf(stderr, "::create - not a LocaleKey!\n");
378 } 377 }
379 #endif 378 #endif
380 const LocaleKey& lkey = (LocaleKey&)key; 379 const LocaleKey& lkey = (LocaleKey&)key;
381 Locale curLoc; // current locale 380 Locale curLoc; // current locale
382 Locale canLoc; // Canonical locale 381 Locale canLoc; // Canonical locale
383 382
384 lkey.currentLocale(curLoc); 383 lkey.currentLocale(curLoc);
385 lkey.canonicalLocale(canLoc); 384 lkey.canonicalLocale(canLoc);
386 385
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 class CalendarService : public ICULocaleService { 436 class CalendarService : public ICULocaleService {
438 public: 437 public:
439 CalendarService() 438 CalendarService()
440 : ICULocaleService(UNICODE_STRING_SIMPLE("Calendar")) 439 : ICULocaleService(UNICODE_STRING_SIMPLE("Calendar"))
441 { 440 {
442 UErrorCode status = U_ZERO_ERROR; 441 UErrorCode status = U_ZERO_ERROR;
443 registerFactory(new DefaultCalendarFactory(), status); 442 registerFactory(new DefaultCalendarFactory(), status);
444 } 443 }
445 444
446 virtual UObject* cloneInstance(UObject* instance) const { 445 virtual UObject* cloneInstance(UObject* instance) const {
447 UnicodeString *s = dynamic_cast<UnicodeString *>(instance); 446 UnicodeString *s = CR_DYNAMIC_CAST<UnicodeString *>(instance);
448 if(s != NULL) { 447 if(s != NULL) {
449 return s->clone(); 448 return s->clone();
450 } else { 449 } else {
451 #ifdef U_DEBUG_CALSVC_F 450 #ifdef U_DEBUG_CALSVC_F
452 UErrorCode status2 = U_ZERO_ERROR; 451 UErrorCode status2 = U_ZERO_ERROR;
453 fprintf(stderr, "Cloning a %s calendar with tz=%ld\n", ((Calendar*)i nstance)->getType(), ((Calendar*)instance)->get(UCAL_ZONE_OFFSET, status2)); 452 fprintf(stderr, "Cloning a %s calendar with tz=%ld\n", ((Calendar*)i nstance)->getType(), ((Calendar*)instance)->get(UCAL_ZONE_OFFSET, status2));
454 #endif 453 #endif
455 return ((Calendar*)instance)->clone(); 454 return ((Calendar*)instance)->clone();
456 } 455 }
457 } 456 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 806
808 if(U_FAILURE(success) || !u) { 807 if(U_FAILURE(success) || !u) {
809 delete zone; 808 delete zone;
810 if(U_SUCCESS(success)) { // Propagate some kind of err 809 if(U_SUCCESS(success)) { // Propagate some kind of err
811 success = U_INTERNAL_PROGRAM_ERROR; 810 success = U_INTERNAL_PROGRAM_ERROR;
812 } 811 }
813 return NULL; 812 return NULL;
814 } 813 }
815 814
816 #if !UCONFIG_NO_SERVICE 815 #if !UCONFIG_NO_SERVICE
817 const UnicodeString* str = dynamic_cast<const UnicodeString*>(u); 816 const UnicodeString* str = CR_DYNAMIC_CAST<const UnicodeString*>(u);
818 if(str != NULL) { 817 if(str != NULL) {
819 // It's a unicode string telling us what type of calendar to load ("greg orian", etc) 818 // It's a unicode string telling us what type of calendar to load ("greg orian", etc)
820 // Create a Locale over this string 819 // Create a Locale over this string
821 Locale l(""); 820 Locale l("");
822 LocaleUtility::initLocaleFromName(*str, l); 821 LocaleUtility::initLocaleFromName(*str, l);
823 822
824 #ifdef U_DEBUG_CALSVC 823 #ifdef U_DEBUG_CALSVC
825 fprintf(stderr, "Calendar::createInstance(%s), looking up [%s]\n", aLoca le.getName(), l.getName()); 824 fprintf(stderr, "Calendar::createInstance(%s), looking up [%s]\n", aLoca le.getName(), l.getName());
826 #endif 825 #endif
827 826
828 Locale actualLoc2; 827 Locale actualLoc2;
829 delete u; 828 delete u;
830 u = NULL; 829 u = NULL;
831 830
832 // Don't overwrite actualLoc, since the actual loc from this call 831 // Don't overwrite actualLoc, since the actual loc from this call
833 // may be something like "@calendar=gregorian" -- TODO investigate 832 // may be something like "@calendar=gregorian" -- TODO investigate
834 // further... 833 // further...
835 c = (Calendar*)getCalendarService(success)->get(l, LocaleKey::KIND_ANY, &actualLoc2, success); 834 c = (Calendar*)getCalendarService(success)->get(l, LocaleKey::KIND_ANY, &actualLoc2, success);
836 835
837 if(U_FAILURE(success) || !c) { 836 if(U_FAILURE(success) || !c) {
838 delete zone; 837 delete zone;
839 if(U_SUCCESS(success)) { 838 if(U_SUCCESS(success)) {
840 success = U_INTERNAL_PROGRAM_ERROR; // Propagate some err 839 success = U_INTERNAL_PROGRAM_ERROR; // Propagate some err
841 } 840 }
842 return NULL; 841 return NULL;
843 } 842 }
844 843
845 str = dynamic_cast<const UnicodeString*>(c); 844 if (c->getDynamicClassID() == UnicodeString::getStaticClassID()) {
846 if(str != NULL) { 845 // recursed! Second lookup returned a UnicodeString.
847 // recursed! Second lookup returned a UnicodeString.
848 // Perhaps DefaultCalendar{} was set to another locale. 846 // Perhaps DefaultCalendar{} was set to another locale.
849 #ifdef U_DEBUG_CALSVC 847 #ifdef U_DEBUG_CALSVC
850 char tmp[200]; 848 char tmp[200];
849 const UnicodeString* str = (const UnicodeString*) c;
851 // Extract a char* out of it.. 850 // Extract a char* out of it..
852 int32_t len = str->length(); 851 int32_t len = str->length();
853 int32_t actLen = sizeof(tmp)-1; 852 int32_t actLen = sizeof(tmp)-1;
854 if(len > actLen) { 853 if(len > actLen) {
855 len = actLen; 854 len = actLen;
856 } 855 }
857 str->extract(0,len,tmp); 856 str->extract(0,len,tmp);
858 tmp[len]=0; 857 tmp[len]=0;
859 858
860 fprintf(stderr, "err - recursed, 2nd lookup was unistring %s\n", tmp ); 859 fprintf(stderr, "err - recursed, 2nd lookup was unistring %s\n", tmp );
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 { 901 {
903 UErrorCode status = U_ZERO_ERROR; 902 UErrorCode status = U_ZERO_ERROR;
904 return isEquivalentTo(that) && 903 return isEquivalentTo(that) &&
905 getTimeInMillis(status) == that.getTimeInMillis(status) && 904 getTimeInMillis(status) == that.getTimeInMillis(status) &&
906 U_SUCCESS(status); 905 U_SUCCESS(status);
907 } 906 }
908 907
909 UBool 908 UBool
910 Calendar::isEquivalentTo(const Calendar& other) const 909 Calendar::isEquivalentTo(const Calendar& other) const
911 { 910 {
912 return typeid(*this) == typeid(other) && 911 return CR_TYPEID(*this) == CR_TYPEID(other) &&
913 fLenient == other.fLenient && 912 fLenient == other.fLenient &&
914 fFirstDayOfWeek == other.fFirstDayOfWeek && 913 fFirstDayOfWeek == other.fFirstDayOfWeek &&
915 fMinimalDaysInFirstWeek == other.fMinimalDaysInFirstWeek && 914 fMinimalDaysInFirstWeek == other.fMinimalDaysInFirstWeek &&
916 fWeekendOnset == other.fWeekendOnset && 915 fWeekendOnset == other.fWeekendOnset &&
917 fWeekendOnsetMillis == other.fWeekendOnsetMillis && 916 fWeekendOnsetMillis == other.fWeekendOnsetMillis &&
918 fWeekendCease == other.fWeekendCease && 917 fWeekendCease == other.fWeekendCease &&
919 fWeekendCeaseMillis == other.fWeekendCeaseMillis && 918 fWeekendCeaseMillis == other.fWeekendCeaseMillis &&
920 *fZone == *other.fZone; 919 *fZone == *other.fZone;
921 } 920 }
922 921
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 { 3364 {
3366 internalSet((UCalendarDateFields) field, value); 3365 internalSet((UCalendarDateFields) field, value);
3367 } 3366 }
3368 3367
3369 U_NAMESPACE_END 3368 U_NAMESPACE_END
3370 3369
3371 #endif /* #if !UCONFIG_NO_FORMATTING */ 3370 #endif /* #if !UCONFIG_NO_FORMATTING */
3372 3371
3373 3372
3374 //eof 3373 //eof
OLDNEW
« no previous file with comments | « third_party/icu/source/i18n/brktrans.cpp ('k') | third_party/icu/source/i18n/coll.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698