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

Side by Side Diff: third_party/icu/source/test/intltest/icusvtst.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
OLDNEW
1 /** 1 /**
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 2001-2010, International Business Machines Corporation and 3 * Copyright (C) 2001-2010, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 */ 6 */
7 7
8 #include <typeinfo> // for 'typeid' to work
9 8
10 #include "unicode/utypes.h" 9 #include "unicode/utypes.h"
11 10
12 #if !UCONFIG_NO_SERVICE 11 #if !UCONFIG_NO_SERVICE
13 12
14 #include "icusvtst.h" 13 #include "icusvtst.h"
15 #include "servloc.h" 14 #include "servloc.h"
16 #include <stdio.h> 15 #include <stdio.h>
17 16
18 17
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 static UClassID getStaticClassID() { 77 static UClassID getStaticClassID() {
79 return (UClassID)&fgClassID; 78 return (UClassID)&fgClassID;
80 } 79 }
81 80
82 virtual UClassID getDynamicClassID() const { 81 virtual UClassID getDynamicClassID() const {
83 return getStaticClassID(); 82 return getStaticClassID();
84 } 83 }
85 84
86 virtual UBool operator==(const UObject& other) const 85 virtual UBool operator==(const UObject& other) const
87 { 86 {
88 return typeid(*this) == typeid(other) && 87 return CR_TYPEID(*this) == CR_TYPEID(other) &&
89 _val == ((Integer&)other)._val; 88 _val == ((Integer&)other)._val;
90 } 89 }
91 90
92 public: 91 public:
93 virtual UnicodeString& debug(UnicodeString& result) const { 92 virtual UnicodeString& debug(UnicodeString& result) const {
94 debugClass(result); 93 debugClass(result);
95 result.append(" val: "); 94 result.append(" val: ");
96 result.append(_val); 95 result.append(_val);
97 return result; 96 return result;
98 } 97 }
(...skipping 11 matching lines...) Expand all
110 // use locale keys 109 // use locale keys
111 class TestIntegerService : public ICUService { 110 class TestIntegerService : public ICUService {
112 public: 111 public:
113 ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const { 112 ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const {
114 return LocaleKey::createWithCanonicalFallback(id, NULL, status); // no f allback locale 113 return LocaleKey::createWithCanonicalFallback(id, NULL, status); // no f allback locale
115 } 114 }
116 115
117 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const UnicodeSt ring& id, UBool visible, UErrorCode& status) 116 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const UnicodeSt ring& id, UBool visible, UErrorCode& status)
118 { 117 {
119 Integer* i; 118 Integer* i;
120 if (U_SUCCESS(status) && obj && (i = dynamic_cast<Integer*>(obj)) != NUL L) { 119 if (U_SUCCESS(status) && obj && (i = CR_DYNAMIC_CAST<Integer*>(obj)) != NULL) {
121 return new SimpleFactory(i, id, visible); 120 return new SimpleFactory(i, id, visible);
122 } 121 }
123 return NULL; 122 return NULL;
124 } 123 }
125 124
126 virtual UObject* cloneInstance(UObject* instance) const { 125 virtual UObject* cloneInstance(UObject* instance) const {
127 return instance ? new Integer(*(Integer*)instance) : NULL; 126 return instance ? new Integer(*(Integer*)instance) : NULL;
128 } 127 }
129 }; 128 };
130 129
(...skipping 22 matching lines...) Expand all
153 152
154 UnicodeString append(UnicodeString& result, const UObject* obj) 153 UnicodeString append(UnicodeString& result, const UObject* obj)
155 { 154 {
156 char buffer[128]; 155 char buffer[128];
157 if (obj == NULL) { 156 if (obj == NULL) {
158 result.append("NULL"); 157 result.append("NULL");
159 } else { 158 } else {
160 const UnicodeString* s; 159 const UnicodeString* s;
161 const Locale* loc; 160 const Locale* loc;
162 const Integer* i; 161 const Integer* i;
163 if ((s = dynamic_cast<const UnicodeString*>(obj)) != NULL) { 162 if ((s = CR_DYNAMIC_CAST<const UnicodeString*>(obj)) != NULL) {
164 result.append(*s); 163 result.append(*s);
165 } else if ((loc = dynamic_cast<const Locale*>(obj)) != NULL) { 164 } else if ((loc = CR_DYNAMIC_CAST<const Locale*>(obj)) != NULL) {
166 result.append(loc->getName()); 165 result.append(loc->getName());
167 } else if ((i = dynamic_cast<const Integer*>(obj)) != NULL) { 166 } else if ((i = CR_DYNAMIC_CAST<const Integer*>(obj)) != NULL) {
168 sprintf(buffer, "%d", (int)i->_val); 167 sprintf(buffer, "%d", (int)i->_val);
169 result.append(buffer); 168 result.append(buffer);
170 } else { 169 } else {
171 sprintf(buffer, "%p", (const void*)obj); 170 sprintf(buffer, "%p", (const void*)obj);
172 result.append(buffer); 171 result.append(buffer);
173 } 172 }
174 } 173 }
175 return result; 174 return result;
176 } 175 }
177 176
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 */ 473 */
475 class TestStringSimpleKeyService : public ICUService { 474 class TestStringSimpleKeyService : public ICUService {
476 public: 475 public:
477 476
478 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const Unico deString& id, UBool visible, UErrorCode& status) 477 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const Unico deString& id, UBool visible, UErrorCode& status)
479 { 478 {
480 // We could put this type check into ICUService itself, but we'd still 479 // We could put this type check into ICUService itself, but we'd still
481 // have to implement cloneInstance. Otherwise we could just tel l the service 480 // have to implement cloneInstance. Otherwise we could just tel l the service
482 // what the object type is when we create it, and the default im plementation 481 // what the object type is when we create it, and the default im plementation
483 // could handle everything for us. Phooey. 482 // could handle everything for us. Phooey.
484 if (obj && dynamic_cast<UnicodeString*>(obj) != NULL) { 483 if (obj && CR_DYNAMIC_CAST<UnicodeString*>(obj) != NULL) {
485 return ICUService::createSimpleFactory(obj, id, visible, status); 484 return ICUService::createSimpleFactory(obj, id, visible, status);
486 } 485 }
487 return NULL; 486 return NULL;
488 } 487 }
489 488
490 virtual UObject* cloneInstance(UObject* instance) const { 489 virtual UObject* cloneInstance(UObject* instance) const {
491 return instance ? new UnicodeString(*(UnicodeString*)instance) : NULL; 490 return instance ? new UnicodeString(*(UnicodeString*)instance) : NULL;
492 } 491 }
493 }; 492 };
494 493
495 class TestStringService : public ICUService { 494 class TestStringService : public ICUService {
496 public: 495 public:
497 ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const { 496 ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const {
498 return LocaleKey::createWithCanonicalFallback(id, NULL, status); // no f allback locale 497 return LocaleKey::createWithCanonicalFallback(id, NULL, status); // no f allback locale
499 } 498 }
500 499
501 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const UnicodeStri ng& id, UBool visible, UErrorCode& /* status */) 500 virtual ICUServiceFactory* createSimpleFactory(UObject* obj, const UnicodeStri ng& id, UBool visible, UErrorCode& /* status */)
502 { 501 {
503 UnicodeString* s; 502 UnicodeString* s;
504 if (obj && (s = dynamic_cast<UnicodeString*>(obj)) != NULL) { 503 if (obj && (s = CR_DYNAMIC_CAST<UnicodeString*>(obj)) != NULL) {
505 return new SimpleFactory(s, id, visible); 504 return new SimpleFactory(s, id, visible);
506 } 505 }
507 return NULL; 506 return NULL;
508 } 507 }
509 508
510 virtual UObject* cloneInstance(UObject* instance) const { 509 virtual UObject* cloneInstance(UObject* instance) const {
511 return instance ? new UnicodeString(*(UnicodeString*)instance) : NULL; 510 return instance ? new UnicodeString(*(UnicodeString*)instance) : NULL;
512 } 511 }
513 }; 512 };
514 513
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 nf.addListener(new MyListener()); 1505 nf.addListener(new MyListener());
1507 nf.removeListener(new MyListener()); 1506 nf.removeListener(new MyListener());
1508 #endif 1507 #endif
1509 } 1508 }
1510 1509
1511 1510
1512 /* !UCONFIG_NO_SERVICE */ 1511 /* !UCONFIG_NO_SERVICE */
1513 #endif 1512 #endif
1514 1513
1515 1514
OLDNEW
« no previous file with comments | « third_party/icu/source/test/intltest/dtfmttst.cpp ('k') | third_party/icu/source/test/intltest/intltest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698