From: Steven R. Loomis Date: Sat, 16 Aug 2014 01:30:43 +0000 (+0000) Subject: ICU-10347 add U_FINAL and U_OVERRIDE for C++11 "final" and "override". X-Git-Tag: milestone-59-0-1~1732 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3dc3bc4560b1e50a8424be6fe19e4464b5d660e;p=icu ICU-10347 add U_FINAL and U_OVERRIDE for C++11 "final" and "override". Added them to several "not for subclassing" classes. Some exceptions: * Commented out U_FINAL where there's an internal override needed. * For tests, added "#define U_FINAL" at the top to disable this. #defined to null for Doxygen. X-SVN-Rev: 36177 --- diff --git a/icu4c/source/Doxyfile.in b/icu4c/source/Doxyfile.in index 4683b6b7e90..90edbb18f2e 100644 --- a/icu4c/source/Doxyfile.in +++ b/icu4c/source/Doxyfile.in @@ -1,7 +1,7 @@ # Doxyfile 1.3.7 # ******************************************************************** # * COPYRIGHT: -# * Copyright (c) 2004-2012, International Business Machines Corporation +# * Copyright (c) 2004-2014, International Business Machines Corporation # * and others. All Rights Reserved. # ******************************************************************** @@ -192,7 +192,7 @@ EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = U_EXPORT2= U_STABLE= U_DRAFT= U_INTERNAL= U_SYSTEM= U_DEPRECATED= U_OBSOLETE= U_CALLCONV= U_CDECL_BEGIN= U_CDECL_END= U_NO_THROW=\ "U_NAMESPACE_BEGIN=namespace icu{" "U_NAMESPACE_END=}" U_HAVE_STD_STRING=1 U_SHOW_CPLUSPLUS_API=1 U_DEFINE_LOCAL_OPEN_POINTER()= U_IN_DOXYGEN=1 +PREDEFINED = U_EXPORT2= U_STABLE= U_DRAFT= U_INTERNAL= U_SYSTEM= U_DEPRECATED= U_OBSOLETE= U_CALLCONV= U_CDECL_BEGIN= U_CDECL_END= U_NO_THROW=\ "U_NAMESPACE_BEGIN=namespace icu{" "U_NAMESPACE_END=}" U_HAVE_STD_STRING=1 U_SHOW_CPLUSPLUS_API=1 U_DEFINE_LOCAL_OPEN_POINTER()= U_IN_DOXYGEN=1 U_OVERRIDE= U_FINAL= EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/icu4c/source/common/unicode/caniter.h b/icu4c/source/common/unicode/caniter.h index 23246c5a0f2..3bd79f768e0 100644 --- a/icu4c/source/common/unicode/caniter.h +++ b/icu4c/source/common/unicode/caniter.h @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2011, International Business Machines Corporation and + * Copyright (C) 1996-2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* */ @@ -69,7 +69,7 @@ Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMB * @author C++ port by V. Weinstein * @stable ICU 2.4 */ -class U_COMMON_API CanonicalIterator : public UObject { +class U_COMMON_API CanonicalIterator U_FINAL : public UObject { public: /** * Construct a CanonicalIterator object diff --git a/icu4c/source/common/unicode/rbbi.h b/icu4c/source/common/unicode/rbbi.h index aa6cf47ba42..844420dd3a8 100644 --- a/icu4c/source/common/unicode/rbbi.h +++ b/icu4c/source/common/unicode/rbbi.h @@ -1,6 +1,6 @@ /* *************************************************************************** -* Copyright (C) 1999-2013 International Business Machines Corporation * +* Copyright (C) 1999-2014 International Business Machines Corporation * * and others. All rights reserved. * *************************************************************************** @@ -62,7 +62,7 @@ struct RBBIStateTable; * not part of the ICU API, and may not remain stable.

* */ -class U_COMMON_API RuleBasedBreakIterator : public BreakIterator { +class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { protected: /** diff --git a/icu4c/source/common/unicode/umachine.h b/icu4c/source/common/unicode/umachine.h index d1102f49365..dd37108bb34 100644 --- a/icu4c/source/common/unicode/umachine.h +++ b/icu4c/source/common/unicode/umachine.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1999-2012, International Business Machines +* Copyright (C) 1999-2014, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -13,7 +13,7 @@ * created on: 1999sep13 * created by: Markus W. Scherer * -* This file defines basic types and constants for utf.h to be +* This file defines basic types and constants for ICU to be * platform-independent. umachine.h and utf.h are included into * utypes.h to provide all the general definitions for ICU. * All of these definitions used to be in utypes.h before @@ -116,6 +116,44 @@ /** This is used to declare a function as an internal ICU C API */ #define U_INTERNAL U_CAPI +/** + * \def U_OVERRIDE + * Defined to the C++11 "override" keyword if available. + * Denotes a class or member which is an override of the base class. + * May result in an error if it applied to something not an override. + * (NOTE: '#define U_OVERRIDE' at the top of a compilation unit will + * disable this keyword's use.) + * @internal + */ + +/** + * \def U_FINAL + * Defined to the C++11 "final" keyword if available. + * Denotes a class or member which may not be overridden in subclasses. + * May result in an error if subclasses attempt to override. + * (NOTE: '#define U_FINAL' at the top of a compilation unit will + * disable this keyword's use.) + * @internal + */ + +#if defined(__cplusplus) && __cplusplus>=201103L +/* C++11 */ +#ifndef U_OVERRIDE +#define U_OVERRIDE override +#endif +#ifndef U_FINAL +#define U_FINAL final +#endif +#else +/* not C++11 - define to nothing */ +#ifndef U_OVERRIDE +#define U_OVERRIDE +#endif +#ifndef U_FINAL +#define U_FINAL +#endif +#endif + /*==========================================================================*/ /* limits for int32_t etc., like in POSIX inttypes.h */ /*==========================================================================*/ diff --git a/icu4c/source/common/unicode/uniset.h b/icu4c/source/common/unicode/uniset.h index fa7cc7ca1c2..237ebf766c3 100644 --- a/icu4c/source/common/unicode/uniset.h +++ b/icu4c/source/common/unicode/uniset.h @@ -1,6 +1,6 @@ /* *************************************************************************** -* Copyright (C) 1999-2013, International Business Machines Corporation +* Copyright (C) 1999-2014, International Business Machines Corporation * and others. All Rights Reserved. *************************************************************************** * Date Name Description @@ -273,7 +273,7 @@ class RuleCharacterIterator; * @author Alan Liu * @stable ICU 2.0 */ -class U_COMMON_API UnicodeSet : public UnicodeFilter { +class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { int32_t len; // length of list used; 0 <= len <= capacity int32_t capacity; // capacity of list diff --git a/icu4c/source/common/unicode/usetiter.h b/icu4c/source/common/unicode/usetiter.h index 43374b2dae5..21c9babd0cf 100644 --- a/icu4c/source/common/unicode/usetiter.h +++ b/icu4c/source/common/unicode/usetiter.h @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2002-2008, International Business Machines +* Copyright (c) 2002-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ @@ -58,7 +58,7 @@ class UnicodeString; * @author M. Davis * @stable ICU 2.4 */ -class U_COMMON_API UnicodeSetIterator : public UObject { +class U_COMMON_API UnicodeSetIterator U_FINAL : public UObject { protected: diff --git a/icu4c/source/i18n/unicode/coleitr.h b/icu4c/source/i18n/unicode/coleitr.h index d4beb320567..8c5d0e94f58 100644 --- a/icu4c/source/i18n/unicode/coleitr.h +++ b/icu4c/source/i18n/unicode/coleitr.h @@ -113,7 +113,7 @@ class UVector32; * @see RuleBasedCollator * @version 1.8 Jan 16 2001 */ -class U_I18N_API CollationElementIterator : public UObject { +class U_I18N_API CollationElementIterator U_FINAL : public UObject { public: // CollationElementIterator public data member ------------------------------ diff --git a/icu4c/source/i18n/unicode/dtfmtsym.h b/icu4c/source/i18n/unicode/dtfmtsym.h index 17fa705b6b2..852b71daef2 100644 --- a/icu4c/source/i18n/unicode/dtfmtsym.h +++ b/icu4c/source/i18n/unicode/dtfmtsym.h @@ -76,7 +76,7 @@ class Hashtable; * locale at least contains any resources that are to be particularized for the * calendar type. */ -class U_I18N_API DateFormatSymbols : public UObject { +class U_I18N_API DateFormatSymbols U_FINAL : public UObject { public: /** * Construct a DateFormatSymbols object by loading format data from diff --git a/icu4c/source/i18n/unicode/dtitvinf.h b/icu4c/source/i18n/unicode/dtitvinf.h index d39207bb5b2..9f6674e70d1 100644 --- a/icu4c/source/i18n/unicode/dtitvinf.h +++ b/icu4c/source/i18n/unicode/dtitvinf.h @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2008-2011,2013, International Business Machines Corporation and + * Copyright (C) 2008-2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -148,7 +148,7 @@ U_NAMESPACE_BEGIN * @stable ICU 4.0 **/ -class U_I18N_API DateIntervalInfo : public UObject { +class U_I18N_API DateIntervalInfo U_FINAL : public UObject { public: #ifndef U_HIDE_INTERNAL_API /** diff --git a/icu4c/source/i18n/unicode/regex.h b/icu4c/source/i18n/unicode/regex.h index b2ef4ce33d9..7b85d7040f2 100644 --- a/icu4c/source/i18n/unicode/regex.h +++ b/icu4c/source/i18n/unicode/regex.h @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2013, International Business Machines +* Copyright (C) 2002-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: regex.h @@ -80,7 +80,7 @@ class UVector64; * * @stable ICU 2.4 */ -class U_I18N_API RegexPattern: public UObject { +class U_I18N_API RegexPattern U_FINAL : public UObject { public: /** @@ -622,7 +622,7 @@ private: * * @stable ICU 2.4 */ -class U_I18N_API RegexMatcher: public UObject { +class U_I18N_API RegexMatcher U_FINAL : public UObject { public: /** diff --git a/icu4c/source/i18n/unicode/stsearch.h b/icu4c/source/i18n/unicode/stsearch.h index c9c910b14bd..d38cb23f215 100644 --- a/icu4c/source/i18n/unicode/stsearch.h +++ b/icu4c/source/i18n/unicode/stsearch.h @@ -129,7 +129,7 @@ U_NAMESPACE_BEGIN * @since ICU 2.0 */ -class U_I18N_API StringSearch : public SearchIterator +class U_I18N_API StringSearch U_FINAL : public SearchIterator { public: diff --git a/icu4c/source/i18n/unicode/tblcoll.h b/icu4c/source/i18n/unicode/tblcoll.h index f392ac0e994..4025b80b47c 100644 --- a/icu4c/source/i18n/unicode/tblcoll.h +++ b/icu4c/source/i18n/unicode/tblcoll.h @@ -107,7 +107,7 @@ class UVector64; * Note, RuleBasedCollator is not to be subclassed. * @see Collator */ -class U_I18N_API RuleBasedCollator : public Collator { +class U_I18N_API RuleBasedCollator U_FINAL : public Collator { public: /** * RuleBasedCollator constructor. This takes the table rules and builds a diff --git a/icu4c/source/test/intltest/regcoll.cpp b/icu4c/source/test/intltest/regcoll.cpp index 0cc127e704a..f3b583bd839 100644 --- a/icu4c/source/test/intltest/regcoll.cpp +++ b/icu4c/source/test/intltest/regcoll.cpp @@ -4,6 +4,10 @@ * others. All Rights Reserved. ********************************************************************/ +// My4146160Collator overrides RBC. Disable U_FINAL for this test. +#define U_FINAL +#define U_OVERRIDE + #include "unicode/utypes.h" #if !UCONFIG_NO_COLLATION diff --git a/icu4c/source/test/intltest/transrt.cpp b/icu4c/source/test/intltest/transrt.cpp index 30ebbe9e052..3f1d57b0310 100644 --- a/icu4c/source/test/intltest/transrt.cpp +++ b/icu4c/source/test/intltest/transrt.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2000-2013, International Business Machines +* Copyright (C) 2000-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -8,6 +8,10 @@ ********************************************************************** */ +// AbbreviatedUnicodeSetIterator overrides UnicodeSetIterator. +#define U_FINAL +#define U_OVERRIDE + #include "unicode/utypes.h" #if !UCONFIG_NO_TRANSLITERATION