diff --git a/icu4c/source/common/appendable.cpp b/icu4c/source/common/appendable.cpp index 4d672fc0515..e46d0790181 100644 --- a/icu4c/source/common/appendable.cpp +++ b/icu4c/source/common/appendable.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2011, International Business Machines +* Copyright (C) 2011-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: appendable.cpp @@ -67,8 +67,6 @@ Appendable::getAppendBuffer(int32_t minCapacity, return scratch; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(Appendable) - // UnicodeStringAppendable is implemented in unistr.cpp. U_NAMESPACE_END diff --git a/icu4c/source/common/listformatter.cpp b/icu4c/source/common/listformatter.cpp index 6a6e986377d..60211460279 100644 --- a/icu4c/source/common/listformatter.cpp +++ b/icu4c/source/common/listformatter.cpp @@ -320,6 +320,4 @@ void ListFormatter::addNewString(const UnicodeString& pat, UnicodeString& origin originalString = result; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(ListFormatter) - U_NAMESPACE_END diff --git a/icu4c/source/common/messagepattern.cpp b/icu4c/source/common/messagepattern.cpp index 18d8a3481e8..de0410b83c1 100644 --- a/icu4c/source/common/messagepattern.cpp +++ b/icu4c/source/common/messagepattern.cpp @@ -1174,8 +1174,6 @@ MessagePattern::setParseError(UParseError *parseError, int32_t index) { parseError->postContext[length]=0; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(MessagePattern) - // MessageImpl ------------------------------------------------------------- *** void diff --git a/icu4c/source/common/normalizer2.cpp b/icu4c/source/common/normalizer2.cpp index c78d0a7610b..a2c27dd1426 100644 --- a/icu4c/source/common/normalizer2.cpp +++ b/icu4c/source/common/normalizer2.cpp @@ -50,8 +50,6 @@ Normalizer2::getCombiningClass(UChar32 /*c*/) const { return 0; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(Normalizer2) - // Normalizer2 implementation for the old UNORM_NONE. class NoopNormalizer2 : public Normalizer2 { virtual ~NoopNormalizer2(); diff --git a/icu4c/source/common/stringtriebuilder.cpp b/icu4c/source/common/stringtriebuilder.cpp index 32a931130ce..109fcdc5f8a 100644 --- a/icu4c/source/common/stringtriebuilder.cpp +++ b/icu4c/source/common/stringtriebuilder.cpp @@ -381,8 +381,6 @@ StringTrieBuilder::equalNodes(const void *left, const void *right) { return *(const Node *)left==*(const Node *)right; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(StringTrieBuilder) - UBool StringTrieBuilder::Node::operator==(const Node &other) const { return this==&other || (typeid(*this)==typeid(other) && hash==other.hash); @@ -396,8 +394,6 @@ StringTrieBuilder::Node::markRightEdgesFirst(int32_t edgeNumber) { return edgeNumber; } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(StringTrieBuilder::Node) - UBool StringTrieBuilder::FinalValueNode::operator==(const Node &other) const { if(this==&other) { diff --git a/icu4c/source/common/unicode/appendable.h b/icu4c/source/common/unicode/appendable.h index a90f37bb07a..a6a83b15cf9 100644 --- a/icu4c/source/common/unicode/appendable.h +++ b/icu4c/source/common/unicode/appendable.h @@ -140,10 +140,6 @@ public: int32_t desiredCapacityHint, UChar *scratch, int32_t scratchCapacity, int32_t *resultCapacity); - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; /** diff --git a/icu4c/source/common/unicode/idna.h b/icu4c/source/common/unicode/idna.h index 70a84166f33..90194a378f3 100644 --- a/icu4c/source/common/unicode/idna.h +++ b/icu4c/source/common/unicode/idna.h @@ -254,10 +254,6 @@ public: virtual void nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const; - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; class UTS46; diff --git a/icu4c/source/common/unicode/listformatter.h b/icu4c/source/common/unicode/listformatter.h index 37042379db6..1e045324738 100644 --- a/icu4c/source/common/unicode/listformatter.h +++ b/icu4c/source/common/unicode/listformatter.h @@ -124,7 +124,6 @@ class U_COMMON_API ListFormatter : public UObject{ ListFormatter& operator = (const ListFormatter&); void addNewString(const UnicodeString& pattern, UnicodeString& originalString, const UnicodeString& newString, UErrorCode& errorCode) const; - virtual UClassID getDynamicClassID() const; const ListFormatData& data; }; diff --git a/icu4c/source/common/unicode/messagepattern.h b/icu4c/source/common/unicode/messagepattern.h index a5204c14380..d6074710e02 100644 --- a/icu4c/source/common/unicode/messagepattern.h +++ b/icu4c/source/common/unicode/messagepattern.h @@ -917,9 +917,6 @@ private: void setParseError(UParseError *parseError, int32_t index); - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; - UBool init(UErrorCode &errorCode); UBool copyStorage(const MessagePattern &other, UErrorCode &errorCode); diff --git a/icu4c/source/common/unicode/normalizer2.h b/icu4c/source/common/unicode/normalizer2.h index bfca5ab8324..9b9a691ac37 100644 --- a/icu4c/source/common/unicode/normalizer2.h +++ b/icu4c/source/common/unicode/normalizer2.h @@ -429,10 +429,6 @@ public: * @stable ICU 4.4 */ virtual UBool isInert(UChar32 c) const = 0; - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; /** diff --git a/icu4c/source/common/unicode/stringtriebuilder.h b/icu4c/source/common/unicode/stringtriebuilder.h index 9cb2ae5ef7e..05fa6e7b516 100644 --- a/icu4c/source/common/unicode/stringtriebuilder.h +++ b/icu4c/source/common/unicode/stringtriebuilder.h @@ -239,9 +239,6 @@ protected: protected: int32_t hash; int32_t offset; - private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; // This class should not be overridden because @@ -396,10 +393,6 @@ protected: virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node) = 0; /** @internal */ virtual int32_t writeDeltaTo(int32_t jumpTarget) = 0; - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; U_NAMESPACE_END diff --git a/icu4c/source/common/unicode/uobject.h b/icu4c/source/common/unicode/uobject.h index 5f6b1a1e5a7..54ceace626d 100644 --- a/icu4c/source/common/unicode/uobject.h +++ b/icu4c/source/common/unicode/uobject.h @@ -59,15 +59,10 @@ * operator==(). Nothing else should be done with them. * * \par - * getDynamicClassID() is declared in the base class of the hierarchy as - * a pure virtual. Each concrete subclass implements it in the same way: + * In class hierarchies that implement "poor man's RTTI", + * each concrete subclass implements getDynamicClassID() in the same way: * * \code - * class Base { - * public: - * virtual UClassID getDynamicClassID() const = 0; - * } - * * class Derived { * public: * virtual UClassID getDynamicClassID() const @@ -210,10 +205,7 @@ public: * and all other public ICU C++ classes * are derived from UObject (starting with ICU 2.2). * - * UObject contains common virtual functions like for ICU's "poor man's RTTI". - * It does not contain default implementations of virtual methods - * like getDynamicClassID to allow derived classes such as Format - * to declare these as pure virtual. + * UObject contains common virtual functions, in particular a virtual destructor. * * The clone() function is not available in UObject because it is not * implemented by all ICU classes. @@ -237,21 +229,23 @@ public: /** * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. + * The base class implementation returns a dummy value. + * + * Use compiler RTTI rather than ICU's "poor man's RTTI". + * Since ICU 4.6, new ICU C++ class hierarchies do not implement "poor man's RTTI". * * @stable ICU 2.2 */ - virtual UClassID getDynamicClassID() const = 0; + virtual UClassID getDynamicClassID() const; protected: // the following functions are protected to prevent instantiation and // direct use of UObject itself // default constructor - // commented out because UObject is abstract (see getDynamicClassID) // inline UObject() {} // copy constructor - // commented out because UObject is abstract (see getDynamicClassID) // inline UObject(const UObject &other) {} #if 0 @@ -286,19 +280,6 @@ protected: * here would be to declare and empty-implement a protected or public one. UObject &UObject::operator=(const UObject &); */ - -// Future implementation for RTTI that support subtyping. [alan] -// -// public: -// /** -// * @internal -// */ -// static UClassID getStaticClassID(); -// -// /** -// * @internal -// */ -// UBool instanceOf(UClassID type) const; }; #ifndef U_HIDE_INTERNAL_API @@ -332,34 +313,6 @@ protected: return (UClassID)&classID; \ } -/** - * This is a simple macro to express that a class and its subclasses do not offer - * ICU's "poor man's RTTI". - * Beginning with ICU 4.6, ICU requires C++ compiler RTTI. - * This does not go into the header. This should only be used in *.cpp files. - * Use this with a private getDynamicClassID() in an immediate subclass of UObject. - * - * @param myClass The name of the class that needs RTTI defined. - * @internal - */ -#define UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(myClass) \ - UClassID myClass::getDynamicClassID() const { return NULL; } - -// /** -// * This macro adds ICU RTTI to an ICU concrete class implementation. -// * This macro should be invoked in *.cpp files. The corresponding -// * header should declare getDynamicClassID and getStaticClassID. -// * -// * @param myClass The name of the class that needs RTTI defined. -// * @param myParent The name of the myClass's parent. -// * @internal -// */ -/*#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass, myParent) \ - UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass, myParent) \ - UClassID myClass::getDynamicClassID() const { \ - return myClass::getStaticClassID(); \ - } -*/ #endif /* U_HIDE_INTERNAL_API */ U_NAMESPACE_END diff --git a/icu4c/source/common/uobject.cpp b/icu4c/source/common/uobject.cpp index 1d8f6dcb555..900e0345952 100644 --- a/icu4c/source/common/uobject.cpp +++ b/icu4c/source/common/uobject.cpp @@ -91,23 +91,7 @@ void U_EXPORT2 UMemory::operator delete(void* p, const char* /*file*/, int /*lin UObject::~UObject() {} -// Future implementation for RTTI that support subtyping. [alan] -// -// UClassID UObject::getStaticClassID() { -// return (UClassID) NULL; -// } -// -// UBool UObject::instanceOf(UClassID type) const { -// UClassID c = getDynamicClassID(); -// for (;;) { -// if (c == type) { -// return TRUE; -// } else if (c == (UClassID) NULL) { -// return FALSE; -// } -// c = * (UClassID*) c; -// } -// } +UClassID UObject::getDynamicClassID() const { return NULL; } U_NAMESPACE_END diff --git a/icu4c/source/common/uts46.cpp b/icu4c/source/common/uts46.cpp index cddc039ea18..8e6c8ff1e7d 100644 --- a/icu4c/source/common/uts46.cpp +++ b/icu4c/source/common/uts46.cpp @@ -109,8 +109,6 @@ IDNA::nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest, } } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(IDNA) - // UTS46 class declaration ------------------------------------------------- *** class UTS46 : public IDNA { diff --git a/icu4c/source/i18n/alphaindex.cpp b/icu4c/source/i18n/alphaindex.cpp index 93f1a7174bc..a9c4d7a5e60 100644 --- a/icu4c/source/i18n/alphaindex.cpp +++ b/icu4c/source/i18n/alphaindex.cpp @@ -38,8 +38,6 @@ //#include U_NAMESPACE_BEGIN -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(AlphabeticIndex) - // Forward Declarations static int32_t U_CALLCONV PreferenceComparator(const void *context, const void *left, const void *right); diff --git a/icu4c/source/i18n/fpositer.cpp b/icu4c/source/i18n/fpositer.cpp index 69712642b22..3481252a6e3 100644 --- a/icu4c/source/i18n/fpositer.cpp +++ b/icu4c/source/i18n/fpositer.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 2009-2010, International Business Machines Corporation and +* Copyright (C) 2009-2012, International Business Machines Corporation and * others. All Rights Reserved. ****************************************************************************** * Date Name Description @@ -18,8 +18,6 @@ U_NAMESPACE_BEGIN -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(FieldPositionIterator) - FieldPositionIterator::~FieldPositionIterator() { delete data; data = NULL; diff --git a/icu4c/source/i18n/gender.cpp b/icu4c/source/i18n/gender.cpp index 1d343eb7425..4eac9e17740 100644 --- a/icu4c/source/i18n/gender.cpp +++ b/icu4c/source/i18n/gender.cpp @@ -63,8 +63,6 @@ GenderInfo::GenderInfo() { GenderInfo::~GenderInfo() { } -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(GenderInfo) - const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& status) { if (U_FAILURE(status)) { return NULL; diff --git a/icu4c/source/i18n/locdspnm.cpp b/icu4c/source/i18n/locdspnm.cpp index 1d1807aff22..9b63a3ed33a 100644 --- a/icu4c/source/i18n/locdspnm.cpp +++ b/icu4c/source/i18n/locdspnm.cpp @@ -149,8 +149,6 @@ ICUDataTable::getNoFallback(const char* tableKey, const char* subTableKey, const LocaleDisplayNames::~LocaleDisplayNames() {} -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(LocaleDisplayNames) - //////////////////////////////////////////////////////////////////////////////////////////////////// #if 0 // currently unused diff --git a/icu4c/source/i18n/msgfmt.cpp b/icu4c/source/i18n/msgfmt.cpp index 3c74aa5be05..3c2c7c65a1b 100644 --- a/icu4c/source/i18n/msgfmt.cpp +++ b/icu4c/source/i18n/msgfmt.cpp @@ -163,7 +163,6 @@ U_NAMESPACE_BEGIN // ------------------------------------- UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MessageFormat) -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(MessageFormat::DummyFormat) UOBJECT_DEFINE_RTTI_IMPLEMENTATION(FormatNameEnumeration) //-------------------------------------------------------------------- diff --git a/icu4c/source/i18n/tznames.cpp b/icu4c/source/i18n/tznames.cpp index b7fc35c20b0..923eb7ae9e3 100644 --- a/icu4c/source/i18n/tznames.cpp +++ b/icu4c/source/i18n/tznames.cpp @@ -303,8 +303,6 @@ TimeZoneNamesDelegate::find(const UnicodeString& text, int32_t start, uint32_t t // --------------------------------------------------- // TimeZoneNames base class // --------------------------------------------------- -UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(TimeZoneNames) - TimeZoneNames::~TimeZoneNames() { } diff --git a/icu4c/source/i18n/unicode/alphaindex.h b/icu4c/source/i18n/unicode/alphaindex.h index 7b7d18c356f..f493ec66c77 100644 --- a/icu4c/source/i18n/unicode/alphaindex.h +++ b/icu4c/source/i18n/unicode/alphaindex.h @@ -511,9 +511,6 @@ class U_I18N_API AlphabeticIndex: public UObject { virtual AlphabeticIndex &resetRecordIterator(); private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; - /** * No Copy constructor. * @internal diff --git a/icu4c/source/i18n/unicode/fpositer.h b/icu4c/source/i18n/unicode/fpositer.h index ecaa77728ac..b842161a69b 100644 --- a/icu4c/source/i18n/unicode/fpositer.h +++ b/icu4c/source/i18n/unicode/fpositer.h @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 2010, International Business Machines +* Copyright (C) 2010-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -108,9 +108,6 @@ private: UVector32 *data; int32_t pos; - - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/unicode/gender.h b/icu4c/source/i18n/unicode/gender.h index 3b2ad006e67..a9171ed9f2a 100644 --- a/icu4c/source/i18n/unicode/gender.h +++ b/icu4c/source/i18n/unicode/gender.h @@ -76,12 +76,6 @@ public: private: int32_t _style; - - /** - * No "poor man's RTTI" - */ - virtual UClassID getDynamicClassID() const; - /** * Copy constructor. One object per locale invariant. Clients * must never copy GenderInfo objects. diff --git a/icu4c/source/i18n/unicode/locdspnm.h b/icu4c/source/i18n/unicode/locdspnm.h index cdd2bb8f3fe..65c4c8ea2f8 100644 --- a/icu4c/source/i18n/unicode/locdspnm.h +++ b/icu4c/source/i18n/unicode/locdspnm.h @@ -193,10 +193,6 @@ public: */ virtual UnicodeString& keyValueDisplayName(const char* key, const char* value, UnicodeString& result) const = 0; - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; inline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) { diff --git a/icu4c/source/i18n/unicode/msgfmt.h b/icu4c/source/i18n/unicode/msgfmt.h index 60ba1538574..9988e0026b6 100644 --- a/icu4c/source/i18n/unicode/msgfmt.h +++ b/icu4c/source/i18n/unicode/msgfmt.h @@ -1087,7 +1087,6 @@ private: virtual void parseObject(const UnicodeString&, Formattable&, ParsePosition&) const; - virtual UClassID getDynamicClassID() const; }; friend class MessageFormatAdapter; // getFormatTypeList() access diff --git a/icu4c/source/i18n/unicode/tznames.h b/icu4c/source/i18n/unicode/tznames.h index 2de296d50ee..8211b3b1ab9 100644 --- a/icu4c/source/i18n/unicode/tznames.h +++ b/icu4c/source/i18n/unicode/tznames.h @@ -363,10 +363,6 @@ public: * @internal */ virtual MatchInfoCollection* find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const = 0; - -private: - // No ICU "poor man's RTTI" for this class nor its subclasses. - virtual UClassID getDynamicClassID() const; }; U_NAMESPACE_END diff --git a/icu4c/source/test/intltest/uobjtest.cpp b/icu4c/source/test/intltest/uobjtest.cpp index 11f1293c5b1..e607f2f32b0 100644 --- a/icu4c/source/test/intltest/uobjtest.cpp +++ b/icu4c/source/test/intltest/uobjtest.cpp @@ -1,8 +1,8 @@ /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2012, International Business Machines Corporation and * others. All Rights Reserved. - * Copyright (C) 2010 , Yahoo! Inc. + * Copyright (C) 2010 , Yahoo! Inc. ********************************************************************/ #include @@ -325,6 +325,8 @@ void UObjectTest::testIDs() ids_count = 0; UErrorCode status = U_ZERO_ERROR; + TESTCLASSID_NONE_CTOR(UObject, ()); + #if !UCONFIG_NO_TRANSLITERATION || !UCONFIG_NO_FORMATTING UParseError parseError; #endif