⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 275856 in webkit


Ignore:
Timestamp:
Apr 12, 2021, 7:04:15 PM (6 years ago)
Author:
Ross Kirsling
Message:

ICU 69 deprecates ubrk_safeClone in favor of ubrk_clone
​https://bugs.webkit.org/show_bug.cgi?id=224093

Reviewed by Yusuke Suzuki.

In a shining example of "disappointing library practices", ICU 69 deprecates ubrk_safeClone in favor of
a new *draft* API ubrk_clone, meaning that no function with this functionality is exposed by default.

This patch introduces a function cloneUBreakIterator to abstract over this change; however, since we need to:

  1. confine the effects of disabling U_HIDE_DRAFT_API to a non-unified implementation file
  2. still be able to include ubrk.h from IntlSegmenter.h to instantiate ICUDeleter<ubrk_close> (*not* clone!)

...the new helper function is introduced in a *headerless* implementation file, IntlWorkaround.cpp.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • runtime/IntlSegmenter.cpp:

(JSC::IntlSegmenter::segment const):

  • runtime/IntlSegmenter.h:
  • runtime/IntlSegments.cpp:

(JSC::IntlSegments::createSegmentIterator):

  • runtime/IntlWorkaround.cpp: Added.

(JSC::cloneUBreakIterator):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r275850 r275856  
     12021-04-12  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        ICU 69 deprecates ubrk_safeClone in favor of ubrk_clone
     4        https://bugs.webkit.org/show_bug.cgi?id=224093
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        In a shining example of "disappointing library practices", ICU 69 deprecates ubrk_safeClone in favor of
     9        a new *draft* API ubrk_clone, meaning that no function with this functionality is exposed by default.
     10
     11        This patch introduces a function cloneUBreakIterator to abstract over this change; however, since we need to:
     12
     13          1. confine the effects of disabling U_HIDE_DRAFT_API to a non-unified implementation file
     14          2. still be able to include ubrk.h from IntlSegmenter.h to instantiate ICUDeleter<ubrk_close> (*not* `clone`!)
     15
     16        ...the new helper function is introduced in a *headerless* implementation file, IntlWorkaround.cpp.
     17
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * Sources.txt:
     20        * runtime/IntlSegmenter.cpp:
     21        (JSC::IntlSegmenter::segment const):
     22        * runtime/IntlSegmenter.h:
     23        * runtime/IntlSegments.cpp:
     24        (JSC::IntlSegments::createSegmentIterator):
     25        * runtime/IntlWorkaround.cpp: Added.
     26        (JSC::cloneUBreakIterator):
     27
    1282021-04-12  Don Olmstead  <don.olmstead@sony.com>
    229
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r275797 r275856  
    14031403                A1D793011B43864B004516F5 /* IntlNumberFormatPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D792FB1B43864B004516F5 /* IntlNumberFormatPrototype.h */; };
    14041404                A38D250E25800D440042BFDD /* JSArrayBufferPrototypeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = A38D250D25800D430042BFDD /* JSArrayBufferPrototypeInlines.h */; };
     1405                A3EE8543262514B000FC9B8D /* IntlWorkaround.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */; };
    14051406                A3FF9BC72234749100B1A9AB /* YarrFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = A3FF9BC52234746600B1A9AB /* YarrFlags.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14061407                A503FA1A188E0FB000110F14 /* JavaScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = A503FA14188E0FAF00110F14 /* JavaScriptCallFrame.h */; };
    … …  
    44204421                A1FE1EB01C2C537E00A289FF /* DatePrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = DatePrototype.js; sourceTree = "<group>"; };
    44214422                A27958D7FA1142B0AC9E364D /* WasmContextInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContextInlines.h; sourceTree = "<group>"; };
     4423                A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntlWorkaround.cpp; sourceTree = "<group>"; };
    44224424                A38D250D25800D430042BFDD /* JSArrayBufferPrototypeInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferPrototypeInlines.h; sourceTree = "<group>"; };
    44234425                A3AFF92B245A3CF900C9BA3B /* IntlLocale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlLocale.h; sourceTree = "<group>"; };
    … …  
    72897291                                BCD203470E17135E002C7E82 /* DatePrototype.cpp */,
    72907292                                BCD203480E17135E002C7E82 /* DatePrototype.h */,
    7291                                 FE9F3FC626163CA90069E89F /* DeferTermination.h */,
    72927293                                534638761E71E06E00F12AC1 /* DeferredWorkTimer.cpp */,
    72937294                                534638741E70DDEC00F12AC1 /* DeferredWorkTimer.h */,
     7295                                FE9F3FC626163CA90069E89F /* DeferTermination.h */,
    72947296                                169948EDE68D4054B01EF797 /* DefinePropertyAttributes.h */,
    72957297                                734B655423F4A33100A069D1 /* DeletePropertySlot.h */,
    … …  
    74777479                                E3F2193224C7882A003AE453 /* IntlSegmentsPrototype.cpp */,
    74787480                                E3F2193624C7882B003AE453 /* IntlSegmentsPrototype.h */,
     7481                                A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */,
    74797482                                0F275F2C1ECE079600620D47 /* Intrinsic.cpp */,
    74807483                                86BF642A148DB2B5004DE36A /* Intrinsic.h */,
    … …  
    92319234                                8BC0648A1E1ABA7B00B2B8CA /* AsyncGeneratorFunctionPrototype.h in Headers */,
    92329235                                8BC064921E1ADCC400B2B8CA /* AsyncGeneratorPrototype.h in Headers */,
    9233                                 BCE2FAFF26091782000A510F /* WeakGCHashTable.h in Headers */,
    92349236                                8B3BF5E41E3D368B0076A87A /* AsyncGeneratorPrototype.lut.h in Headers */,
    92359237                                8BC064961E1D845C00B2B8CA /* AsyncIteratorPrototype.h in Headers */,
    … …  
    94999501                                FE5068651AE246390009DAB7 /* DeferredSourceDump.h in Headers */,
    95009502                                534638751E70DDEC00F12AC1 /* DeferredWorkTimer.h in Headers */,
     9503                                FE9F3FC826163CA90069E89F /* DeferTermination.h in Headers */,
    95019504                                473DA4A4764C45FE871B0485 /* DefinePropertyAttributes.h in Headers */,
    95029505                                0FBB73BB1DEF8645002C009E /* DeleteAllCodeEffort.h in Headers */,
    … …  
    95129515                                0F4F11EB209D426600709654 /* DFGAbstractValueClobberEpoch.h in Headers */,
    95139516                                0FD3E4021B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h in Headers */,
    9514                                 FE9F3FB92613C7890069E89F /* ResourceExhaustion.h in Headers */,
    95159517                                0F18D3D01B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h in Headers */,
    95169518                                0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */,
    … …  
    96679669                                0FC20CB61852E2C600C9E954 /* DFGStrengthReductionPhase.h in Headers */,
    96689670                                0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */,
    9669                                 FE9F3FC826163CA90069E89F /* DeferTermination.h in Headers */,
    96709671                                0F50AF3C193E8B3900674EE8 /* DFGStructureClobberState.h in Headers */,
    96719672                                0F2FCCFF18A60070001A27F8 /* DFGThreadData.h in Headers */,
    … …  
    96979698                                0F37308F1C0CD68500052BFA /* DisallowMacroScratchRegisterUsage.h in Headers */,
    96989699                                FE54DEFF1E8D76FA00A892C5 /* DisallowScope.h in Headers */,
    9699                                 BCE2FAFB260916EF000A510F /* WeakGCSet.h in Headers */,
    97009700                                FE54DEFB1E8C6D8800A892C5 /* DisallowVMEntry.h in Headers */,
    97019701                                0FF42731158EBD54004CB9FF /* Disassembler.h in Headers */,
    … …  
    1035510355                                FE64872E2141D04800AB0D3E /* OpcodeInlines.h in Headers */,
    1035610356                                14A4680D216FA56A000D2B1A /* OpcodeSize.h in Headers */,
    10357                                 BCE2FAFD260916FF000A510F /* WeakGCSetInlines.h in Headers */,
    1035810357                                0F2BDC2C151FDE9100CD8910 /* Operands.h in Headers */,
    1035910358                                A70447EA17A0BD4600F5898E /* OperandsInlines.h in Headers */,
    … …  
    1046210461                                992F56B71E4E84B20035953B /* RemoteInspectorXPCConnection.h in Headers */,
    1046310462                                0F24E55117EE274900ABB217 /* Repatch.h in Headers */,
     10463                                FE9F3FB92613C7890069E89F /* ResourceExhaustion.h in Headers */,
    1046410464                                869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
    1046510465                                FE3B642F25D6FB4D001ADDB4 /* RootMarkReason.h in Headers */,
    … …  
    1068810688                                142E313C134FF0A600AFADB5 /* Weak.h in Headers */,
    1068910689                                14E84F9F14EE1ACC00D6D5D4 /* WeakBlock.h in Headers */,
     10690                                BCE2FAFF26091782000A510F /* WeakGCHashTable.h in Headers */,
    1069010691                                14BFCE6910CDB1FC00364CCE /* WeakGCMap.h in Headers */,
    1069110692                                AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */,
     10693                                BCE2FAFB260916EF000A510F /* WeakGCSet.h in Headers */,
     10694                                BCE2FAFD260916FF000A510F /* WeakGCSetInlines.h in Headers */,
    1069210695                                14F7256614EE265E00B1652B /* WeakHandleOwner.h in Headers */,
    1069310696                                14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */,
    … …  
    1156411567                                E399AEC32559457F00B78485 /* IntlDateTimeFormat.cpp in Sources */,
    1156511568                                E366441E254409B30001876F /* IntlListFormat.cpp in Sources */,
     11569                                A3EE8543262514B000FC9B8D /* IntlWorkaround.cpp in Sources */,
    1156611570                                E38E8790254B978400F6F9E4 /* JSDateMath.cpp in Sources */,
    1156711571                                536B319E1F735F160037FC33 /* LowLevelInterpreter.cpp in Sources */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r275243 r275856  
    850850runtime/IntlSegments.cpp
    851851runtime/IntlSegmentsPrototype.cpp
     852runtime/IntlWorkaround.cpp @no-unify // Confine U_HIDE_DRAFT_API's effect to this file.
    852853runtime/IteratorOperations.cpp
    853854runtime/IteratorPrototype.cpp
  • trunk/Source/JavaScriptCore/runtime/IntlSegmenter.cpp

    r275410 r275856  
    126126
    127127    UErrorCode status = U_ZERO_ERROR;
    128     auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_safeClone(m_segmenter.get(), nullptr, nullptr, &status));
     128    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(cloneUBreakIterator(m_segmenter.get(), &status));
    129129    if (U_FAILURE(status)) {
    130130        throwTypeError(globalObject, scope, "failed to initialize Segments"_s);
  • trunk/Source/JavaScriptCore/runtime/IntlSegmenter.h

    r266032 r275856  
    7676};
    7777
     78// Abstraction to call ubrk_safeClone or ubrk_clone depending on ICU version.
     79// This is implemented in IntlWorkaround.cpp in order to confine draft API visibility.
     80UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);
     81
    7882} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/IntlSegments.cpp

    r273138 r275856  
    101101
    102102    UErrorCode status = U_ZERO_ERROR;
    103     auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_safeClone(m_segmenter.get(), nullptr, nullptr, &status));
     103    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(cloneUBreakIterator(m_segmenter.get(), &status));
    104104    if (U_FAILURE(status)) {
    105105        throwTypeError(globalObject, scope, "failed to initialize SegmentIterator"_s);
Note: See TracChangeset for help on using the changeset viewer.