]> granicus.if.org Git - icu/commitdiff
ICU-9689 UObject::getDynamicClassID() const { return NULL; } and remove UOBJECT_DEFIN...
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 8 Nov 2012 23:31:20 +0000 (23:31 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Thu, 8 Nov 2012 23:31:20 +0000 (23:31 +0000)
X-SVN-Rev: 32776

27 files changed:
icu4c/source/common/appendable.cpp
icu4c/source/common/listformatter.cpp
icu4c/source/common/messagepattern.cpp
icu4c/source/common/normalizer2.cpp
icu4c/source/common/stringtriebuilder.cpp
icu4c/source/common/unicode/appendable.h
icu4c/source/common/unicode/idna.h
icu4c/source/common/unicode/listformatter.h
icu4c/source/common/unicode/messagepattern.h
icu4c/source/common/unicode/normalizer2.h
icu4c/source/common/unicode/stringtriebuilder.h
icu4c/source/common/unicode/uobject.h
icu4c/source/common/uobject.cpp
icu4c/source/common/uts46.cpp
icu4c/source/i18n/alphaindex.cpp
icu4c/source/i18n/fpositer.cpp
icu4c/source/i18n/gender.cpp
icu4c/source/i18n/locdspnm.cpp
icu4c/source/i18n/msgfmt.cpp
icu4c/source/i18n/tznames.cpp
icu4c/source/i18n/unicode/alphaindex.h
icu4c/source/i18n/unicode/fpositer.h
icu4c/source/i18n/unicode/gender.h
icu4c/source/i18n/unicode/locdspnm.h
icu4c/source/i18n/unicode/msgfmt.h
icu4c/source/i18n/unicode/tznames.h
icu4c/source/test/intltest/uobjtest.cpp

index 4d672fc051540d596b7226063f9a8621a73792be..e46d0790181004bbbdc86325c28cd0a819b770df 100644 (file)
@@ -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
index 6a6e986377d8531d5cc8cb14e8c74a085d17b730..60211460279ec95c32f47581246fe0128b552172 100644 (file)
@@ -320,6 +320,4 @@ void ListFormatter::addNewString(const UnicodeString& pat, UnicodeString& origin
     originalString = result;
 }
 
-UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(ListFormatter)
-
 U_NAMESPACE_END
index 18d8a3481e8ce55d86fa815747d1362e21909325..de0410b83c136a7cc10604c1f0128b1882195b20 100644 (file)
@@ -1174,8 +1174,6 @@ MessagePattern::setParseError(UParseError *parseError, int32_t index) {
     parseError->postContext[length]=0;
 }
 
-UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(MessagePattern)
-
 // MessageImpl ------------------------------------------------------------- ***
 
 void
index c78d0a7610b947f4c00a2439355c79e1a0431501..a2c27dd1426bcb2ee8beda7b67ab11375039d7e3 100644 (file)
@@ -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();
index 32a931130cee0fed1ac0d4e9473a182897ff954c..109fcdc5f8a2553118a18ee059b0085002a61537 100644 (file)
@@ -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) {
index a90f37bb07a74334122d7aa2cf82ea9b1224b0e4..a6a83b15cf97193b2dc691f90cbcaa91928ddb7f 100644 (file)
@@ -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;
 };
 
 /**
index 70a84166f3359e239c02fc04c06eb2d47d6478c6..90194a378f38255b81980838b8fc384220b583b6 100644 (file)
@@ -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;
index 37042379db611073b8ba33182b30bdc02310f7a7..1e04532473814117ce2eef552c42ab73b3ac100c 100644 (file)
@@ -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;
 };
index a5204c1438047682ea4ebd1a77b839b214510905..d6074710e023eb6b3c40bda9d4e1a2904d58ee03 100644 (file)
@@ -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);
 
index bfca5ab8324ece2f0eddd41f003ee821df02699e..9b9a691ac3702bb0589d7f56f583f526da4b5482 100644 (file)
@@ -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;
 };
 
 /**
index 9cb2ae5ef7e80059ec0c7f9b662bfec3d38b0408..05fa6e7b5160dd35ef9ce077b7b40d1381f29ca3 100644 (file)
@@ -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
index 5f6b1a1e5a74afe1e4162b69d55abd56532fcf3b..54ceace626d735cbac6d835bf6aba34833a9f43a 100644 (file)
  * 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
index 1d8f6dcb555e488b37a88ad8c967d806a90144e5..900e0345952cdc262b450ed6f1cb8ff159c75cb8 100644 (file)
@@ -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
 
index cddc039ea181b2faa5870de1621eb0ecaf3615e8..8e6c8ff1e7d1b1fc035770580b14392b0baf7d8e 100644 (file)
@@ -109,8 +109,6 @@ IDNA::nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest,
     }
 }
 
-UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(IDNA)
-
 // UTS46 class declaration ------------------------------------------------- ***
 
 class UTS46 : public IDNA {
index 93f1a7174bcdd8801ccf2d1317d906138ab4d330..a9c4d7a5e60ca7d67456913f835b7c166b023d25 100644 (file)
@@ -38,8 +38,6 @@
 //#include <iostream>
 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);
index 69712642b220133188b1f3bb3a2bdd9e75fb2fcd..3481252a6e3b2bb05d29665c258d044642064580 100644 (file)
@@ -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;
index 1d343eb742548ec12f03b33366f4ba96301e4165..4eac9e17740ed542d95ce5b71ddfdb17a5e4ca61 100644 (file)
@@ -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;
index 1d1807aff2279d4d7e7285980daee4aea99d2cea..9b63a3ed33ab71a023ece8327445ff5093906297 100644 (file)
@@ -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
index 3c74aa5be0553148e04f1104d0f809c35e78513c..3c2c7c65a1b91213e578b55c9324d2f75284af09 100644 (file)
@@ -163,7 +163,6 @@ U_NAMESPACE_BEGIN
 
 // -------------------------------------
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MessageFormat)
-UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(MessageFormat::DummyFormat)
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(FormatNameEnumeration)
 
 //--------------------------------------------------------------------
index b7fc35c20b08a76d2ac4bdbe7bbe7e998259b9b9..923eb7ae9e32301230c3263f1d1ae25ff6960223 100644 (file)
@@ -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() {
 }
 
index 7b7d18c356fd21c00b32dbc98e0d79876827f265..f493ec66c773040ce9fb182388578271c98ccd3b 100644 (file)
@@ -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
index ecaa77728ac3a68630fa3246c7eef6b4184eadbc..b842161a69b794ccc6bf97898a384c3ee825decb 100644 (file)
@@ -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
index 3b2ad006e67808fa68155f8e9af67b77ef46a7dd..a9171ed9f2a95d291054e9087a94ff2864bfedfd 100644 (file)
@@ -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.
index cdd2bb8f3fed3bdbcccea58c18268eb7b0c63448..65c4c8ea2f878123059f257edfc1ea30f4982102 100644 (file)
@@ -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) {
index 60ba15385747dd447e5aa6a9f0c0fc1563b8383f..9988e0026b6c57ce284a0682a28f5ac81e3eb53e 100644 (file)
@@ -1087,7 +1087,6 @@ private:
         virtual void parseObject(const UnicodeString&,
                                  Formattable&,
                                  ParsePosition&) const;
-        virtual UClassID getDynamicClassID() const;
     };
 
     friend class MessageFormatAdapter; // getFormatTypeList() access
index 2de296d50ee27777556c03799b811c61deee1d51..8211b3b1ab9509bc8dc865d847093e4cd9b4abb5 100644 (file)
@@ -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
index 11f1293c5b10b8c7503fdc617e239554c2563d7b..e607f2f32b0170585024a60db0d7a7ffedf7c8d8 100644 (file)
@@ -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 <stdio.h>
@@ -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