From 89c00402a8f68c7257be32abb0ffee6816df0803 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 30 Aug 2012 03:19:37 +0000 Subject: [PATCH] ICU-9474 Undo the changeset to reduce the exported C++ static variables. X-SVN-Rev: 32299 --- icu4c/source/i18n/alphaindex.cpp | 31 +++++++++++++------------- icu4c/source/i18n/colldata.cpp | 2 +- icu4c/source/i18n/ucol.cpp | 6 +++-- icu4c/source/i18n/unicode/alphaindex.h | 22 ++++++++++++++++++ icu4c/source/i18n/unicode/colldata.h | 2 ++ 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/icu4c/source/i18n/alphaindex.cpp b/icu4c/source/i18n/alphaindex.cpp index 2178ee25666..cf51a03fe4e 100644 --- a/icu4c/source/i18n/alphaindex.cpp +++ b/icu4c/source/i18n/alphaindex.cpp @@ -63,19 +63,8 @@ alphaIndex_deleteRecord(void *obj) { } -typedef const UChar PinyinLookup[24][3]; - -static const Normalizer2 *nfkdNormalizer; -static UBool indexCharactersAreInitialized = FALSE; -static UnicodeSet *ALPHABETIC; -static UnicodeSet *HANGUL; -static UnicodeSet *ETHIOPIC; -static UnicodeSet *CORE_LATIN; -static UnicodeSet *IGNORE_SCRIPTS; -static UnicodeSet *TO_TRY; -static UnicodeSet *UNIHAN; -static const UnicodeString *EMPTY_STRING; +static const Normalizer2 *nfkdNormalizer; // // Append the contents of a UnicodeSet to a UVector of UnicodeStrings. @@ -616,6 +605,7 @@ void AlphabeticIndex::init(UErrorCode &status) { } +static UBool indexCharactersAreInitialized = FALSE; // Index Characters Clean up function. Delete statically allocated constant stuff. U_CDECL_BEGIN @@ -647,6 +637,15 @@ void AlphabeticIndex::staticCleanup() { } +UnicodeSet *AlphabeticIndex::ALPHABETIC; +UnicodeSet *AlphabeticIndex::HANGUL; +UnicodeSet *AlphabeticIndex::ETHIOPIC; +UnicodeSet *AlphabeticIndex::CORE_LATIN; +UnicodeSet *AlphabeticIndex::IGNORE_SCRIPTS; +UnicodeSet *AlphabeticIndex::TO_TRY; +UnicodeSet *AlphabeticIndex::UNIHAN; +const UnicodeString *AlphabeticIndex::EMPTY_STRING; + // // staticInit() One-time initialization of constants. // Thread safe. Called from constructors. @@ -952,7 +951,7 @@ static const UChar PINYIN_LOWER_BOUNDS_SHORT[] = { // "\u0101bcd\u0113fghjk // Pinyin lookup tables copied, pasted (and reformatted) from the ICU4J code. -static const PinyinLookup HACK_PINYIN_LOOKUP_SHORT = { +AlphabeticIndex::PinyinLookup AlphabeticIndex::HACK_PINYIN_LOOKUP_SHORT = { {(UChar)0, (UChar)0, (UChar)0}, // A {(UChar)0x516B, (UChar)0, (UChar)0}, // B {(UChar)0x5693, (UChar)0, (UChar)0}, // C @@ -983,7 +982,7 @@ static const UChar PINYIN_LOWER_BOUNDS_LONG[] = { // "\u0101bcd\u0113fghjkl\u1 0x0101, 0x62, 0x63, 0x64, 0x0113, 0x66, 0x67, 0x68, 0x6A, 0x6B, /*l*/0x6C, 0x1E3F, 0x0144, 0x014D, /*p*/0x70, 0x71, 0x72, 0x73, 0x74, /*w*/0x77, 0x78, 0x79, 0x7A}; -static const PinyinLookup HACK_PINYIN_LOOKUP_LONG = { +AlphabeticIndex::PinyinLookup AlphabeticIndex::HACK_PINYIN_LOOKUP_LONG = { {(UChar)0, (UChar)0, (UChar)0}, // A {(UChar)0x516B, (UChar)0, (UChar)0}, // b {(UChar)0xD863, (UChar)0xDEAD, (UChar)0}, // c @@ -1023,8 +1022,8 @@ static const PinyinLookup HACK_PINYIN_LOOKUP_LONG = { // // This whole arrangement is temporary. // -static const PinyinLookup *HACK_PINYIN_LOOKUP = NULL; -static const UChar *PINYIN_LOWER_BOUNDS = NULL; +AlphabeticIndex::PinyinLookup *AlphabeticIndex::HACK_PINYIN_LOOKUP = NULL; +const UChar *AlphabeticIndex::PINYIN_LOWER_BOUNDS = NULL; void AlphabeticIndex::initPinyinBounds(const Collator *col, UErrorCode &status) { { diff --git a/icu4c/source/i18n/colldata.cpp b/icu4c/source/i18n/colldata.cpp index c03b733d00f..a488ea07726 100644 --- a/icu4c/source/i18n/colldata.cpp +++ b/icu4c/source/i18n/colldata.cpp @@ -1038,7 +1038,7 @@ void CollData::close(CollData *collData) cache->unref(collData); } -static CollDataCache *collDataCache = NULL; +CollDataCache *CollData::collDataCache = NULL; CollDataCache *CollData::getCollDataCache() { diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index c3d05c0cbfc..882a3873792 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -4272,8 +4272,6 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, U_NAMESPACE_BEGIN -static uint8_t lastResortByte_ = 0; - class SortKeyByteSink : public ByteSink { public: static const uint32_t FILL_ORIGINAL_BUFFER = 1; @@ -4345,6 +4343,8 @@ private: capacity_ = 0; } + static uint8_t lastResortByte_; // last-resort return value from LastByte() + char *ownedBuffer_; char *buffer_; int32_t capacity_; @@ -4353,6 +4353,8 @@ private: UBool grow_; }; +uint8_t SortKeyByteSink::lastResortByte_ = 0; + SortKeyByteSink::~SortKeyByteSink() { uprv_free(ownedBuffer_); } diff --git a/icu4c/source/i18n/unicode/alphaindex.h b/icu4c/source/i18n/unicode/alphaindex.h index 473a241da41..7b7d18c356f 100644 --- a/icu4c/source/i18n/unicode/alphaindex.h +++ b/icu4c/source/i18n/unicode/alphaindex.h @@ -695,8 +695,30 @@ private: ELangType langType_; // The language type, simplified Chinese, Traditional Chinese, // or not Chinese (Normal). Part of the Pinyin support + typedef const UChar PinyinLookup[24][3]; + static PinyinLookup HACK_PINYIN_LOOKUP_SHORT; + static PinyinLookup HACK_PINYIN_LOOKUP_LONG; + + // These will be lazily set to the short or long tables based on which + // Chinese collation has been configured into the ICU library. + static PinyinLookup *HACK_PINYIN_LOOKUP; + static const UChar *PINYIN_LOWER_BOUNDS; + + + int32_t recordCounter_; // Counts Records created. For minting record serial numbers. +// Constants. Lazily initialized the first time an AlphabeticIndex object is created. + + static UnicodeSet *ALPHABETIC; + static UnicodeSet *CORE_LATIN; + static UnicodeSet *ETHIOPIC; + static UnicodeSet *HANGUL; + static UnicodeSet *IGNORE_SCRIPTS; + static UnicodeSet *TO_TRY; + static UnicodeSet *UNIHAN; + static const UnicodeString *EMPTY_STRING; + }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/unicode/colldata.h b/icu4c/source/i18n/unicode/colldata.h index c8e3433bb6f..d9153d04818 100644 --- a/icu4c/source/i18n/unicode/colldata.h +++ b/icu4c/source/i18n/unicode/colldata.h @@ -441,6 +441,8 @@ private: char keyBuffer[KEY_BUFFER_SIZE]; char *key; + static CollDataCache *collDataCache; + uint32_t minHan; uint32_t maxHan;