Bug 224093 - ICU 69 Deprecates ubrk_safeClone in favor of ubrk_clone
Summary: ICU 69 Deprecates ubrk_safeClone in favor of ubrk_clone
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ross Kirsling
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-01 19:43 PDT by Don Olmstead
Modified: 2021-04-13 14:45 PDT (History)
10 users (show)

See Also:


Attachments
WIP Patch (1.89 KB, patch)
2021-04-01 19:47 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
Patch (15.58 KB, patch)
2021-04-12 17:26 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (15.69 KB, patch)
2021-04-12 17:30 PDT, Ross Kirsling
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (15.72 KB, patch)
2021-04-12 17:49 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch for landing (15.61 KB, patch)
2021-04-12 18:34 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Don Olmstead 2021-04-01 19:43:06 PDT
...
Comment 1 Don Olmstead 2021-04-01 19:47:21 PDT
Created attachment 424978 [details]
WIP Patch
Comment 2 Yusuke Suzuki 2021-04-02 01:01:10 PDT
Comment on attachment 424978 [details]
WIP Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=424978&action=review

> Source/JavaScriptCore/runtime/IntlSegmenter.cpp:129
> +    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_clone(m_segmenter.get(), &status));

Since ubrk_clone is draft status, we need to hide U_HIDE_DRAFT_API definition to use it. So I suggest,

1. Let's create a new cpp/h files, IntlWorkaround.h IntlWorkaround.cpp
2. Annotate @no-unify to IntlWorkaround.cpp since we want to avoid including unicode/ubrk.h without removing U_HIDE_DRAFT_API
3. Define a wrapper function around ubrk_clone / ubrk_safeClone in IntlWorkaround.cpp. To use draft ICU APIs, we need some special handling. Please check IntlListFormat.cpp for example :)
Comment 3 Yusuke Suzuki 2021-04-02 02:55:08 PDT
Comment on attachment 424978 [details]
WIP Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=424978&action=review

>> Source/JavaScriptCore/runtime/IntlSegmenter.cpp:129
>> +    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_clone(m_segmenter.get(), &status));
> 
> Since ubrk_clone is draft status, we need to hide U_HIDE_DRAFT_API definition to use it. So I suggest,
> 
> 1. Let's create a new cpp/h files, IntlWorkaround.h IntlWorkaround.cpp
> 2. Annotate @no-unify to IntlWorkaround.cpp since we want to avoid including unicode/ubrk.h without removing U_HIDE_DRAFT_API
> 3. Define a wrapper function around ubrk_clone / ubrk_safeClone in IntlWorkaround.cpp. To use draft ICU APIs, we need some special handling. Please check IntlListFormat.cpp for example :)

Or let's define a helper function in IntlSegmenter.cpp, make it @no-unify, and include the ubrk.h with appropriate or #define.
And ensure that ubrk.h is not included without draft's #define for that file.
Comment 4 Radar WebKit Bug Importer 2021-04-08 19:44:12 PDT
<rdar://problem/76434312>
Comment 5 Ross Kirsling 2021-04-12 17:26:24 PDT
Created attachment 425816 [details]
Patch
Comment 6 Ross Kirsling 2021-04-12 17:30:58 PDT
Created attachment 425817 [details]
Patch
Comment 7 Ross Kirsling 2021-04-12 17:49:31 PDT
Created attachment 425820 [details]
Patch
Comment 8 Yusuke Suzuki 2021-04-12 18:18:25 PDT
Comment on attachment 425820 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425820&action=review

r=me with some comments.

> Source/JavaScriptCore/runtime/IntlWorkaround.cpp:41
> +#if HAVE(ICU_UBRK_CLONE)
> +#define U_HIDE_DRAFT_API 1
> +#endif

I think we do not need to make it back since this cpp file is isolated.

> Source/JavaScriptCore/runtime/IntlWorkaround.cpp:50
> +return ubrk_clone(iterator, status);

4 spaces for indentation.

> Source/JavaScriptCore/runtime/IntlWorkaround.cpp:52
> +return ubrk_safeClone(iterator, nullptr, nullptr, status);

Ditto.
Comment 9 Ross Kirsling 2021-04-12 18:34:38 PDT
Created attachment 425822 [details]
Patch for landing
Comment 10 EWS 2021-04-12 19:04:23 PDT
Committed r275856 (236421@main): <https://commits.webkit.org/236421@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 425822 [details].
Comment 11 Darin Adler 2021-04-13 12:45:11 PDT
Comment on attachment 425822 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=425822&action=review

> Source/JavaScriptCore/runtime/IntlSegmenter.h:80
> +// Abstraction to call ubrk_safeClone or ubrk_clone depending on ICU version.
> +// This is implemented in IntlWorkaround.cpp in order to confine draft API visibility.
> +UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);

Why is this here instead of an IntlWorkaround.h header?

> Source/JavaScriptCore/runtime/IntlWorkaround.cpp:42
> +UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);

Why is this declaration repeated here instead of including the header it’s in?
Comment 12 Ross Kirsling 2021-04-13 14:18:37 PDT
(In reply to Darin Adler from comment #11)
> Comment on attachment 425822 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=425822&action=review
> 
> > Source/JavaScriptCore/runtime/IntlSegmenter.h:80
> > +// Abstraction to call ubrk_safeClone or ubrk_clone depending on ICU version.
> > +// This is implemented in IntlWorkaround.cpp in order to confine draft API visibility.
> > +UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);
> 
> Why is this here instead of an IntlWorkaround.h header?
> 
> > Source/JavaScriptCore/runtime/IntlWorkaround.cpp:42
> > +UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);
> 
> Why is this declaration repeated here instead of including the header it’s
> in?

Er right, I guess we should be able to put the declaration in an IntlWorkaround.h after all.

(This was meant to be less confusing than introducing a IntlWorkaround.h and having IntlWorkaround.cpp *not* include it. However, the reason for that was because IntlSegmenter.h still needs to include ubrk.h in the usual way and I'd been trying to have IntlWorkaround "manage inclusion" of ubrk.h. But as long as we don't muck with the include in IntlSegmenter.h, then IntlWorkaround.h can safely house a declaration and nothing more.)