ICU-22954 Partially revert PR #3295 U_ICU_NAMESPACE_OR_INTERNAL, header-only localpointer

This partially reverts commit 3527b3d320.

Making LocalPointer header-only, with a different namespace when compiling internally,
turned out to be problematic.
This commit is contained in:
Markus Scherer 2024-12-23 10:00:43 -08:00
parent 38b6d7fe5a
commit c0a3fe15d4
5 changed files with 16 additions and 16 deletions

View file

@ -21,7 +21,7 @@
/**
* \file
* \brief C++ header-only API: "Smart pointers" for use with and in ICU4C C++ code.
* \brief C++ API: "Smart pointers" for use with and in ICU4C C++ code.
*
* These classes are inspired by
* - std::auto_ptr
@ -40,11 +40,11 @@
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#if U_SHOW_CPLUSPLUS_API
#include <memory>
namespace U_ICU_NAMESPACE_OR_INTERNAL {
U_NAMESPACE_BEGIN
/**
* "Smart pointer" base class; do not use directly: use LocalPointer etc.
@ -603,7 +603,7 @@ public:
} // namespace internal
#endif
} // U_ICU_NAMESPACE_OR_INTERNAL
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#endif /* U_SHOW_CPLUSPLUS_API */
#endif /* __LOCALPOINTER_H__ */

View file

@ -801,8 +801,8 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
uint32_t options,
UErrorCode &errorCode) {
// all argument checking is done in unorm_compare
return unorm_compare(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s1.getBuffer()), s1.length(),
U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(s2.getBuffer()), s2.length(),
return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(),
toUCharPtr(s2.getBuffer()), s2.length(),
options,
&errorCode);
}

View file

@ -4676,7 +4676,7 @@ UnicodeString::startsWith(const UnicodeString& srcText,
inline UBool
UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars));
srcLength = u_strlen(toUCharPtr(srcChars));
}
return doEqualsSubstring(0, srcLength, srcChars, 0, srcLength);
}
@ -4684,7 +4684,7 @@ UnicodeString::startsWith(ConstChar16Ptr srcChars, int32_t srcLength) const {
inline UBool
UnicodeString::startsWith(const char16_t *srcChars, int32_t srcStart, int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars));
srcLength = u_strlen(toUCharPtr(srcChars));
}
return doEqualsSubstring(0, srcLength, srcChars, srcStart, srcLength);
}
@ -4707,7 +4707,7 @@ inline UBool
UnicodeString::endsWith(ConstChar16Ptr srcChars,
int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars));
srcLength = u_strlen(toUCharPtr(srcChars));
}
return doEqualsSubstring(length() - srcLength, srcLength, srcChars, 0, srcLength);
}
@ -4717,7 +4717,7 @@ UnicodeString::endsWith(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(srcChars + srcStart));
srcLength = u_strlen(toUCharPtr(srcChars + srcStart));
}
return doEqualsSubstring(length() - srcLength, srcLength,
srcChars, srcStart, srcLength);

View file

@ -346,9 +346,9 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
U_CAPI void U_EXPORT2
uset_close(USet* set);
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#if U_SHOW_CPLUSPLUS_API
namespace U_ICU_NAMESPACE_OR_INTERNAL {
U_NAMESPACE_BEGIN
/**
* \class LocalUSetPointer
@ -361,7 +361,7 @@ namespace U_ICU_NAMESPACE_OR_INTERNAL {
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);
} // U_ICU_NAMESPACE_OR_INTERNAL
U_NAMESPACE_END
#endif

View file

@ -1572,8 +1572,8 @@ class Predicate {
return compare(
ucol_strcoll(
collator,
U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(lhs.getBuffer()), lhs.length(),
U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(rhs.getBuffer()), rhs.length()),
toUCharPtr(lhs.getBuffer()), lhs.length(),
toUCharPtr(rhs.getBuffer()), rhs.length()),
result);
}