Skip to content

Commit

Permalink
ICU-22954 Partially revert PR #3295 U_ICU_NAMESPACE_OR_INTERNAL, head…
Browse files Browse the repository at this point in the history
…er-only localpointer

This partially reverts commit 3527b3d.

Making LocalPointer header-only, with a different namespace when compiling internally,
turned out to be problematic.
  • Loading branch information
markusicu committed Dec 23, 2024
1 parent 38b6d7f commit c0a3fe1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions icu4c/source/common/unicode/localpointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -603,7 +603,7 @@ class LocalOpenPointer : public LocalPointerBase<Type> {
} // 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__ */
4 changes: 2 additions & 2 deletions icu4c/source/common/unicode/normlzr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions icu4c/source/common/unicode/unistr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4676,15 +4676,15 @@ 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);
}

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);
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions icu4c/source/common/unicode/uset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/i18n/unicode/ucol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c0a3fe1

Please sign in to comment.