diff --git a/icu4c/source/common/filteredbrk.cpp b/icu4c/source/common/filteredbrk.cpp index edab8e44986f..baa1d4e42d2e 100644 --- a/icu4c/source/common/filteredbrk.cpp +++ b/icu4c/source/common/filteredbrk.cpp @@ -58,7 +58,7 @@ static int32_t U_CALLCONV compareUnicodeString(UElement t1, UElement t2) { /** * A UVector which implements a set of strings. */ -class U_COMMON_API UStringSet : public UVector { +class UStringSet : public UVector { public: UStringSet(UErrorCode &status) : UVector(uprv_deleteUObject, uhash_compareUnicodeString, @@ -482,7 +482,7 @@ SimpleFilteredSentenceBreakIterator::last(void) { /** * Concrete implementation of builder class. */ -class U_COMMON_API SimpleFilteredBreakIteratorBuilder : public FilteredBreakIteratorBuilder { +class SimpleFilteredBreakIteratorBuilder : public FilteredBreakIteratorBuilder { public: virtual ~SimpleFilteredBreakIteratorBuilder(); SimpleFilteredBreakIteratorBuilder(const Locale &fromLocale, UErrorCode &status); diff --git a/icu4c/source/common/unicode/utf_old.h b/icu4c/source/common/unicode/utf_old.h index 160f5ad0a9f2..6b868c72809b 100644 --- a/icu4c/source/common/unicode/utf_old.h +++ b/icu4c/source/common/unicode/utf_old.h @@ -293,10 +293,10 @@ typedef int32_t UTextOffset; #ifdef U_UTF8_IMPL // No forward declaration if compiling utf_impl.cpp, which defines utf8_countTrailBytes. #elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) -U_CFUNC const uint8_t utf8_countTrailBytes[]; +U_CAPI const uint8_t utf8_countTrailBytes[]; #else -U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_IMPORT*/ -#endif +U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; +#endif /** * Count the trail bytes for a UTF-8 lead byte. diff --git a/icu4c/source/common/unifiedcache.cpp b/icu4c/source/common/unifiedcache.cpp index 3e94bca31dcb..cfb000b2c8e6 100644 --- a/icu4c/source/common/unifiedcache.cpp +++ b/icu4c/source/common/unifiedcache.cpp @@ -45,20 +45,20 @@ U_CDECL_END U_NAMESPACE_BEGIN -U_CAPI int32_t U_EXPORT2 +int32_t U_EXPORT2 ucache_hashKeys(const UHashTok key) { const CacheKeyBase *ckey = (const CacheKeyBase *) key.pointer; return ckey->hashCode(); } -U_CAPI UBool U_EXPORT2 +UBool U_EXPORT2 ucache_compareKeys(const UHashTok key1, const UHashTok key2) { const CacheKeyBase *p1 = (const CacheKeyBase *) key1.pointer; const CacheKeyBase *p2 = (const CacheKeyBase *) key2.pointer; return *p1 == *p2; } -U_CAPI void U_EXPORT2 +void U_EXPORT2 ucache_deleteKey(void *obj) { CacheKeyBase *p = (CacheKeyBase *) obj; delete p; diff --git a/icu4c/source/common/utf_impl.cpp b/icu4c/source/common/utf_impl.cpp index 3d11d9ee9e61..a1f9c6529a7a 100644 --- a/icu4c/source/common/utf_impl.cpp +++ b/icu4c/source/common/utf_impl.cpp @@ -55,7 +55,7 @@ * -finish: * (BSR: Bit Scan Reverse, scans for a 1-bit, starting from the MSB) */ -extern "C" U_EXPORT const uint8_t +U_CAPI const uint8_t utf8_countTrailBytes[256]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/icu4c/source/i18n/collation.cpp b/icu4c/source/i18n/collation.cpp index 14cb86576b82..705ee12e23cc 100644 --- a/icu4c/source/i18n/collation.cpp +++ b/icu4c/source/i18n/collation.cpp @@ -20,15 +20,6 @@ U_NAMESPACE_BEGIN -// Some compilers don't care if constants are defined in the .cpp file. -// MS Visual C++ does not like it, but gcc requires it. clang does not care. -#ifndef _MSC_VER -const uint8_t Collation::LEVEL_SEPARATOR_BYTE; -const uint8_t Collation::MERGE_SEPARATOR_BYTE; -const uint32_t Collation::ONLY_TERTIARY_MASK; -const uint32_t Collation::CASE_AND_TERTIARY_MASK; -#endif - uint32_t Collation::incTwoBytePrimaryByOffset(uint32_t basePrimary, UBool isCompressible, int32_t offset) { // Extract the second byte, minus the minimum byte value, diff --git a/icu4c/source/i18n/collationbuilder.cpp b/icu4c/source/i18n/collationbuilder.cpp index d7ea4c1cba99..fbf09a313d60 100644 --- a/icu4c/source/i18n/collationbuilder.cpp +++ b/icu4c/source/i18n/collationbuilder.cpp @@ -191,13 +191,6 @@ RuleBasedCollator::internalBuildTailoring(const UnicodeString &rules, // CollationBuilder implementation ----------------------------------------- *** -// Some compilers don't care if constants are defined in the .cpp file. -// MS Visual C++ does not like it, but gcc requires it. clang does not care. -#ifndef _MSC_VER -const int32_t CollationBuilder::HAS_BEFORE2; -const int32_t CollationBuilder::HAS_BEFORE3; -#endif - CollationBuilder::CollationBuilder(const CollationTailoring *b, UBool icu4xMode, UErrorCode &errorCode) : nfd(*Normalizer2::getNFDInstance(errorCode)), fcd(*Normalizer2Factory::getFCDInstance(errorCode)), diff --git a/icu4c/source/i18n/collationdatabuilder.cpp b/icu4c/source/i18n/collationdatabuilder.cpp index c9a4a32e838d..e7c3da1ea5eb 100644 --- a/icu4c/source/i18n/collationdatabuilder.cpp +++ b/icu4c/source/i18n/collationdatabuilder.cpp @@ -109,7 +109,7 @@ struct ConditionalCE32 : public UMemory { U_CDECL_BEGIN -U_CAPI void U_CALLCONV +void U_CALLCONV uprv_deleteConditionalCE32(void *obj) { delete static_cast(obj); } diff --git a/icu4c/source/i18n/collationtailoring.h b/icu4c/source/i18n/collationtailoring.h index 3de9682f9500..a6143c1c269d 100644 --- a/icu4c/source/i18n/collationtailoring.h +++ b/icu4c/source/i18n/collationtailoring.h @@ -24,6 +24,8 @@ #include "collationsettings.h" #include "uhash.h" #include "umutex.h" +#include "unifiedcache.h" + struct UDataMemory; struct UResourceBundle; @@ -105,6 +107,10 @@ struct U_I18N_API CollationCacheEntry : public SharedObject { const CollationTailoring *tailoring; }; +template<> U_I18N_API +const CollationCacheEntry * +LocaleCacheKey::createObject(const void *creationContext, + UErrorCode &errorCode) const; U_NAMESPACE_END #endif // !UCONFIG_NO_COLLATION diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index 16ac233c94c7..2638cbf14dec 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -46,7 +46,7 @@ U_NAMESPACE_BEGIN -class U_I18N_API DateFmtBestPattern : public SharedObject { +class DateFmtBestPattern : public SharedObject { public: UnicodeString fPattern; @@ -58,14 +58,14 @@ class U_I18N_API DateFmtBestPattern : public SharedObject { DateFmtBestPattern::~DateFmtBestPattern() { } -template<> U_I18N_API +template<> const DateFmtBestPattern *LocaleCacheKey::createObject( const void * /*creationContext*/, UErrorCode &status) const { status = U_UNSUPPORTED_ERROR; return NULL; } -class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey { +class DateFmtBestPatternKey : public LocaleCacheKey { private: UnicodeString fSkeleton; protected: diff --git a/icu4c/source/i18n/decContext.h b/icu4c/source/i18n/decContext.h index 59ab65e59271..91c6739739dc 100644 --- a/icu4c/source/i18n/decContext.h +++ b/icu4c/source/i18n/decContext.h @@ -262,7 +262,6 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromStringQuiet(decContext *, const char *); U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusQuiet(decContext *, uint32_t); U_CAPI const char * U_EXPORT2 uprv_decContextStatusToString(const decContext *); - U_CAPI int32_t U_EXPORT2 uprv_decContextTestEndian(uint8_t); U_CAPI uint32_t U_EXPORT2 uprv_decContextTestSavedStatus(uint32_t, uint32_t); U_CAPI uint32_t U_EXPORT2 uprv_decContextTestStatus(decContext *, uint32_t); U_CAPI decContext * U_EXPORT2 uprv_decContextZeroStatus(decContext *); diff --git a/icu4c/source/i18n/measfmt.cpp b/icu4c/source/i18n/measfmt.cpp index 1bfdc2b3f869..d2b4e7018dce 100644 --- a/icu4c/source/i18n/measfmt.cpp +++ b/icu4c/source/i18n/measfmt.cpp @@ -239,7 +239,7 @@ static NumericDateFormatters *loadNumericDateFormatters( return result; } -template<> U_I18N_API +template<> const MeasureFormatCacheData *LocaleCacheKey::createObject( const void * /*unused*/, UErrorCode &status) const { const char *localeId = fLoc.getName(); diff --git a/icu4c/source/i18n/reldatefmt.cpp b/icu4c/source/i18n/reldatefmt.cpp index 6dfbffebb0c2..e811eac2c8d7 100644 --- a/icu4c/source/i18n/reldatefmt.cpp +++ b/icu4c/source/i18n/reldatefmt.cpp @@ -701,7 +701,7 @@ static UBool getDateTimePattern( return getStringByIndex(topLevel.getAlias(), dateTimeFormatOffset, result, status); } -template<> U_I18N_API +template<> const RelativeDateTimeCacheData *LocaleCacheKey::createObject(const void * /*unused*/, UErrorCode &status) const { const char *localeId = fLoc.getName(); LocalUResourceBundlePointer topLevel(ures_open(nullptr, localeId, &status)); diff --git a/icu4c/source/i18n/scriptset.h b/icu4c/source/i18n/scriptset.h index 51980ab7b3ef..df5cfdc74868 100644 --- a/icu4c/source/i18n/scriptset.h +++ b/icu4c/source/i18n/scriptset.h @@ -83,4 +83,7 @@ uhash_hashScriptSet(const UElement key); U_CAPI void U_EXPORT2 uhash_deleteScriptSet(void *obj); -#endif // __SCRIPTSET_H__ +U_CAPI UBool U_EXPORT2 +uhash_equalsScriptSet(const UElement key1, const UElement key2); + +#endif // __SCRIPTSET_H_ diff --git a/icu4c/source/i18n/sharedcalendar.h b/icu4c/source/i18n/sharedcalendar.h index 7daebaa40861..60d1d5d48791 100644 --- a/icu4c/source/i18n/sharedcalendar.h +++ b/icu4c/source/i18n/sharedcalendar.h @@ -13,6 +13,7 @@ #include "unicode/utypes.h" #include "sharedobject.h" +#include "unifiedcache.h" U_NAMESPACE_BEGIN @@ -31,6 +32,11 @@ class U_I18N_API SharedCalendar : public SharedObject { SharedCalendar &operator=(const SharedCalendar &) = delete; }; +template<> U_I18N_API +const SharedCalendar *LocaleCacheKey::createObject( + const void * /*unusedCreationContext*/, UErrorCode &status) const; + + U_NAMESPACE_END #endif diff --git a/icu4c/source/i18n/shareddateformatsymbols.h b/icu4c/source/i18n/shareddateformatsymbols.h index 92298a83e329..b51fad98b0bf 100644 --- a/icu4c/source/i18n/shareddateformatsymbols.h +++ b/icu4c/source/i18n/shareddateformatsymbols.h @@ -17,6 +17,7 @@ #include "sharedobject.h" #include "unicode/dtfmtsym.h" +#include "unifiedcache.h" U_NAMESPACE_BEGIN @@ -34,6 +35,11 @@ class U_I18N_API SharedDateFormatSymbols : public SharedObject { SharedDateFormatSymbols &operator=(const SharedDateFormatSymbols &) = delete; }; +template<> U_I18N_API +const SharedDateFormatSymbols * + LocaleCacheKey::createObject( + const void * /*unusedContext*/, UErrorCode &status) const; + U_NAMESPACE_END #endif /* !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/i18n/sharednumberformat.h b/icu4c/source/i18n/sharednumberformat.h index 7ea756a779da..bd914c034078 100644 --- a/icu4c/source/i18n/sharednumberformat.h +++ b/icu4c/source/i18n/sharednumberformat.h @@ -13,6 +13,7 @@ #include "unicode/utypes.h" #include "sharedobject.h" +#include "unifiedcache.h" U_NAMESPACE_BEGIN @@ -31,6 +32,10 @@ class U_I18N_API SharedNumberFormat : public SharedObject { SharedNumberFormat &operator=(const SharedNumberFormat &) = delete; }; +template<> U_I18N_API +const SharedNumberFormat *LocaleCacheKey::createObject( + const void * /*unused*/, UErrorCode &status) const; + U_NAMESPACE_END #endif diff --git a/icu4c/source/i18n/sharedpluralrules.h b/icu4c/source/i18n/sharedpluralrules.h index f543797a802b..11c82c5619a9 100644 --- a/icu4c/source/i18n/sharedpluralrules.h +++ b/icu4c/source/i18n/sharedpluralrules.h @@ -13,6 +13,7 @@ #include "unicode/utypes.h" #include "sharedobject.h" +#include "unifiedcache.h" U_NAMESPACE_BEGIN @@ -30,6 +31,10 @@ class U_I18N_API SharedPluralRules : public SharedObject { SharedPluralRules &operator=(const SharedPluralRules &) =delete; }; +template<> U_I18N_API +const SharedPluralRules *LocaleCacheKey::createObject( + const void * /*unused*/, UErrorCode &status) const; + U_NAMESPACE_END #endif diff --git a/icu4c/source/stubdata/BUILD.bazel b/icu4c/source/stubdata/BUILD.bazel index abb73519ec4b..20344ef49919 100644 --- a/icu4c/source/stubdata/BUILD.bazel +++ b/icu4c/source/stubdata/BUILD.bazel @@ -16,6 +16,7 @@ package( cc_library( name = "stubdata", srcs = ["stubdata.cpp"], + hdrs = ["stubdata.h"], deps = ["//icu4c/source/common:headers"], local_defines = [ "U_COMMON_IMPLEMENTATION", diff --git a/icu4c/source/stubdata/stubdata.cpp b/icu4c/source/stubdata/stubdata.cpp index 0fcab4faa82c..3f336612426c 100644 --- a/icu4c/source/stubdata/stubdata.cpp +++ b/icu4c/source/stubdata/stubdata.cpp @@ -19,26 +19,8 @@ * for running the data building tools. * */ -#include "unicode/utypes.h" -#include "unicode/udata.h" -#include "unicode/uversion.h" - -typedef struct { - uint16_t headerSize; - uint8_t magic1, magic2; - UDataInfo info; - char padding[8]; - uint32_t count, reserved; - /* - const struct { - const char *const name; - const void *const data; - } toc[1]; - */ - int fakeNameAndData[4]; /* TODO: Change this header type from */ - /* pointerTOC to OffsetTOC. */ -} ICU_Data_Header; +#include "stubdata.h" extern "C" U_EXPORT const ICU_Data_Header U_ICUDATA_ENTRY_POINT = { 32, /* headerSize */ diff --git a/icu4c/source/stubdata/stubdata.h b/icu4c/source/stubdata/stubdata.h new file mode 100644 index 000000000000..9879f40164e5 --- /dev/null +++ b/icu4c/source/stubdata/stubdata.h @@ -0,0 +1,52 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/****************************************************************************** +* +* Copyright (C) 2001, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: stubdata.h +* +* This header file is intended to be internal and only included in the +* accompanying implementation file. This file declares a single entry +* point for visibility of tools like TAPI. +* +* Define initialized data that will build into a valid, but empty +* ICU data library. Used to bootstrap the ICU build, which has these +* dependencies: +* ICU Common library depends on ICU data +* ICU data requires data building tools. +* ICU data building tools require the ICU common library. +* +* The stub data library (for which this file is the source) is sufficient +* for running the data building tools. +* +*/ + +#ifndef __STUBDATA_H__ +#define __STUBDATA_H__ + +#include "unicode/utypes.h" +#include "unicode/udata.h" +#include "unicode/uversion.h" + +typedef struct { + uint16_t headerSize; + uint8_t magic1, magic2; + UDataInfo info; + char padding[8]; + uint32_t count, reserved; + /* + const struct { + const char *const name; + const void *const data; + } toc[1]; + */ + int fakeNameAndData[4]; /* TODO: Change this header type from */ + /* pointerTOC to OffsetTOC. */ +} ICU_Data_Header; + +extern "C" U_EXPORT const ICU_Data_Header U_ICUDATA_ENTRY_POINT; + +#endif /* __STUBDATA_H__ */