Blame SOURCES/icu60.patch

b32f37
From 833cfdd150b6f7f0fb021ac5de7890dff158f5fd Mon Sep 17 00:00:00 2001
b32f37
From: Michael Catanzaro <mcatanzaro@redhat.com>
b32f37
Date: Thu, 27 Oct 2022 16:32:43 -0500
b32f37
Subject: [PATCH] Build against ICU 60
b32f37
b32f37
---
b32f37
 Source/JavaScriptCore/runtime/IntlCache.cpp        |  3 +++
b32f37
 Source/JavaScriptCore/runtime/IntlCache.h          |  3 +++
b32f37
 Source/JavaScriptCore/runtime/IntlDisplayNames.cpp | 11 +++++++++++
b32f37
 Source/JavaScriptCore/runtime/IntlDisplayNames.h   |  7 +++++++
b32f37
 Source/JavaScriptCore/runtime/IntlObject.cpp       |  6 +++++-
b32f37
 Source/cmake/OptionsGTK.cmake                      |  2 +-
b32f37
 6 files changed, 30 insertions(+), 2 deletions(-)
b32f37
b32f37
diff --git a/Source/JavaScriptCore/runtime/IntlCache.cpp b/Source/JavaScriptCore/runtime/IntlCache.cpp
b32f37
index b17d7340df56..94a5474059b6 100644
b32f37
--- a/Source/JavaScriptCore/runtime/IntlCache.cpp
b32f37
+++ b/Source/JavaScriptCore/runtime/IntlCache.cpp
b32f37
@@ -26,6 +26,7 @@
42e7ba
 #include "config.h"
42e7ba
 #include "IntlCache.h"
42e7ba
 
42e7ba
+#include "IntlDisplayNames.h"
42e7ba
 #include <wtf/Vector.h>
42e7ba
 
42e7ba
 namespace JSC {
42e7ba
@@ -53,6 +54,7 @@ Vector<UChar, 32> IntlCache::getBestDateTimePattern(const CString& locale, const
42e7ba
     return patternBuffer;
42e7ba
 }
42e7ba
 
42e7ba
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
 Vector<UChar, 32> IntlCache::getFieldDisplayName(const CString& locale, UDateTimePatternField field, UDateTimePGDisplayWidth width, UErrorCode& status)
42e7ba
 {
42e7ba
     auto sharedGenerator = getSharedPatternGenerator(locale, status);
42e7ba
@@ -64,5 +66,6 @@ Vector<UChar, 32> IntlCache::getFieldDisplayName(const CString& locale, UDateTim
42e7ba
         return { };
42e7ba
     return buffer;
42e7ba
 }
42e7ba
+#endif
42e7ba
 
42e7ba
 } // namespace JSC
b32f37
diff --git a/Source/JavaScriptCore/runtime/IntlCache.h b/Source/JavaScriptCore/runtime/IntlCache.h
b32f37
index 058b2423786d..e7a8c82f392b 100644
b32f37
--- a/Source/JavaScriptCore/runtime/IntlCache.h
b32f37
+++ b/Source/JavaScriptCore/runtime/IntlCache.h
b32f37
@@ -25,6 +25,7 @@
42e7ba
 
42e7ba
 #pragma once
42e7ba
 
42e7ba
+#include "IntlDisplayNames.h"
42e7ba
 #include <unicode/udatpg.h>
42e7ba
 #include <wtf/Noncopyable.h>
42e7ba
 #include <wtf/text/CString.h>
42e7ba
@@ -39,7 +40,9 @@ public:
42e7ba
     IntlCache() = default;
42e7ba
 
42e7ba
     Vector<UChar, 32> getBestDateTimePattern(const CString& locale, const UChar* skeleton, unsigned skeletonSize, UErrorCode&);
42e7ba
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
     Vector<UChar, 32> getFieldDisplayName(const CString& locale, UDateTimePatternField, UDateTimePGDisplayWidth, UErrorCode&);
42e7ba
+#endif
42e7ba
 
42e7ba
 private:
42e7ba
     UDateTimePatternGenerator* getSharedPatternGenerator(const CString& locale, UErrorCode& status)
b32f37
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
b32f37
index c281f796eaee..1bc3c0c8a8c6 100644
b32f37
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
b32f37
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
42e7ba
@@ -110,6 +110,7 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
42e7ba
     m_languageDisplay = intlOption<LanguageDisplay>(globalObject, options, vm.propertyNames->languageDisplay, { { "dialect"_s, LanguageDisplay::Dialect }, { "standard"_s, LanguageDisplay::Standard } }, "languageDisplay must be either \"dialect\" or \"standard\""_s, LanguageDisplay::Dialect);
42e7ba
     RETURN_IF_EXCEPTION(scope, void());
42e7ba
 
42e7ba
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
     UErrorCode status = U_ZERO_ERROR;
42e7ba
 
42e7ba
     UDisplayContext contexts[] = {
42e7ba
@@ -137,6 +138,10 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
42e7ba
         throwTypeError(globalObject, scope, "failed to initialize DisplayNames"_s);
42e7ba
         return;
42e7ba
     }
42e7ba
+#else
b32f37
+        throwTypeError(globalObject, scope, "failed to initialize Intl.DisplayNames since feature is not supported by the ICU version"_s);
b32f37
+        return;
42e7ba
+#endif
42e7ba
 }
42e7ba
 
42e7ba
 // https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.of
42e7ba
@@ -146,6 +151,7 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
42e7ba
     VM& vm = globalObject->vm();
42e7ba
     auto scope = DECLARE_THROW_SCOPE(vm);
42e7ba
 
42e7ba
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
     ASSERT(m_displayNames);
42e7ba
     auto code = codeValue.toWTFString(globalObject);
42e7ba
     RETURN_IF_EXCEPTION(scope, { });
42e7ba
@@ -350,6 +356,11 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
42e7ba
         return throwTypeError(globalObject, scope, "Failed to query a display name."_s);
42e7ba
     }
b32f37
     return jsString(vm, String(WTFMove(buffer)));
42e7ba
+#else
42e7ba
+    UNUSED_PARAM(codeValue);
b32f37
+    throwTypeError(globalObject, scope, "failed to initialize Intl.DisplayNames since feature is not supported by the ICU version"_s);
42e7ba
+    return { };
42e7ba
+#endif
42e7ba
 }
42e7ba
 
42e7ba
 // https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.resolvedOptions
b32f37
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.h b/Source/JavaScriptCore/runtime/IntlDisplayNames.h
b32f37
index d80dc3d83a15..f2bf36275c79 100644
b32f37
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.h
b32f37
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.h
b32f37
@@ -29,6 +29,13 @@
b32f37
 #include <unicode/uldnames.h>
b32f37
 #include <wtf/unicode/icu/ICUHelpers.h>
42e7ba
 
42e7ba
+#if !defined(HAVE_ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
+// We need 61 or later since part of implementation uses UCURR_NARROW_SYMBOL_NAME.
42e7ba
+#if U_ICU_VERSION_MAJOR_NUM >= 61
42e7ba
+#define HAVE_ICU_U_LOCALE_DISPLAY_NAMES 1
42e7ba
+#endif
42e7ba
+#endif
42e7ba
+
b32f37
 namespace JSC {
42e7ba
 
b32f37
 enum class RelevantExtensionKey : uint8_t;
b32f37
diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp
b32f37
index f7dc4d578d77..a6ccbe1b9f74 100644
b32f37
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
b32f37
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
42e7ba
@@ -153,7 +153,6 @@ namespace JSC {
42e7ba
   getCanonicalLocales   intlObjectFuncGetCanonicalLocales            DontEnum|Function 1
42e7ba
   Collator              createCollatorConstructor                    DontEnum|PropertyCallback
42e7ba
   DateTimeFormat        createDateTimeFormatConstructor              DontEnum|PropertyCallback
42e7ba
-  DisplayNames          createDisplayNamesConstructor                DontEnum|PropertyCallback
42e7ba
   Locale                createLocaleConstructor                      DontEnum|PropertyCallback
42e7ba
   NumberFormat          createNumberFormatConstructor                DontEnum|PropertyCallback
42e7ba
   PluralRules           createPluralRulesConstructor                 DontEnum|PropertyCallback
42e7ba
@@ -239,6 +238,11 @@ void IntlObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
42e7ba
     Base::finishCreation(vm);
b32f37
     ASSERT(inherits(info()));
42e7ba
     JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
42e7ba
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
42e7ba
+    putDirectWithoutTransition(vm, vm.propertyNames->DisplayNames, createDisplayNamesConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
42e7ba
+#else
42e7ba
+    UNUSED_PARAM(&createDisplayNamesConstructor);
42e7ba
+#endif
42e7ba
 #if HAVE(ICU_U_LIST_FORMATTER)
42e7ba
     putDirectWithoutTransition(vm, vm.propertyNames->ListFormat, createListFormatConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
42e7ba
 #else
b32f37
diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake
b32f37
index 5e653a9e0b5a..0977f2c49037 100644
b32f37
--- a/Source/cmake/OptionsGTK.cmake
b32f37
+++ b/Source/cmake/OptionsGTK.cmake
b32f37
@@ -19,7 +19,7 @@ find_package(Freetype 2.4.2 REQUIRED)
42e7ba
 find_package(LibGcrypt 1.6.0 REQUIRED)
42e7ba
 find_package(GLIB 2.56.4 REQUIRED COMPONENTS gio gio-unix gobject gthread gmodule)
42e7ba
 find_package(HarfBuzz 0.9.18 REQUIRED COMPONENTS ICU)
42e7ba
-find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
42e7ba
+find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
42e7ba
 find_package(JPEG REQUIRED)
42e7ba
 find_package(LibXml2 2.8.0 REQUIRED)
42e7ba
 find_package(PNG REQUIRED)
b32f37
-- 
b32f37
2.31.1
b32f37