Skip to content

Commit 868adfc

Browse files
Fix compilation with ICU 59.1
https://bugs.webkit.org/show_bug.cgi?id=171612 Reviewed by Mark Lam. ICU 59.1 has broken source compatibility. Now it defines UChar as char16_t, which does not allow automatic type conversion from unsigned short in C++ code. Source/JavaScriptCore: * API/JSStringRef.cpp: (JSStringCreateWithCharacters): (JSStringCreateWithCharactersNoCopy): (JSStringGetCharactersPtr): * runtime/DateConversion.cpp: (JSC::formatDateTime): Source/WebKit2: * Shared/API/c/WKString.cpp: (WKStringGetCharacters): Tools: * TestRunnerShared/UIScriptContext/UIScriptContext.cpp: (UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@216187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3e47e1a commit 868adfc

File tree

7 files changed

+53
-10
lines changed

7 files changed

+53
-10
lines changed

Source/JavaScriptCore/API/JSStringRef.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace WTF::Unicode;
3737
JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
3838
{
3939
initializeThreading();
40-
return &OpaqueJSString::create(chars, numChars).leakRef();
40+
return &OpaqueJSString::create(reinterpret_cast<const UChar*>(chars), numChars).leakRef();
4141
}
4242

4343
JSStringRef JSStringCreateWithUTF8CString(const char* string)
@@ -62,7 +62,7 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
6262
JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars)
6363
{
6464
initializeThreading();
65-
return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars)).leakRef();
65+
return OpaqueJSString::create(StringImpl::createWithoutCopying(reinterpret_cast<const UChar*>(chars), numChars)).leakRef();
6666
}
6767

6868
JSStringRef JSStringRetain(JSStringRef string)
@@ -87,7 +87,7 @@ const JSChar* JSStringGetCharactersPtr(JSStringRef string)
8787
{
8888
if (!string)
8989
return nullptr;
90-
return string->characters();
90+
return reinterpret_cast<const JSChar*>(string->characters());
9191
}
9292

9393
size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string)

Source/JavaScriptCore/ChangeLog

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2017-05-04 Konstantin Tokarev <[email protected]>
2+
3+
Fix compilation with ICU 59.1
4+
https://bugs.webkit.org/show_bug.cgi?id=171612
5+
6+
Reviewed by Mark Lam.
7+
8+
ICU 59.1 has broken source compatibility. Now it defines UChar as
9+
char16_t, which does not allow automatic type conversion from unsigned
10+
short in C++ code.
11+
12+
* API/JSStringRef.cpp:
13+
(JSStringCreateWithCharacters):
14+
(JSStringCreateWithCharactersNoCopy):
15+
(JSStringGetCharactersPtr):
16+
* runtime/DateConversion.cpp:
17+
(JSC::formatDateTime):
18+
119
2017-05-04 Saam Barati <[email protected]>
220

321
stress/call-apply-exponential-bytecode-size.js.no-llint failing on 32-bit debug for OOM on executable memory

Source/JavaScriptCore/runtime/DateConversion.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,16 @@ String formatDateTime(const GregorianDateTime& t, DateTimeFormat format, bool as
107107
#if OS(WINDOWS)
108108
TIME_ZONE_INFORMATION timeZoneInformation;
109109
GetTimeZoneInformation(&timeZoneInformation);
110-
const WCHAR* timeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
110+
const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
111+
String timeZoneName(reinterpret_cast<const UChar*>(winTimeZoneName));
111112
#else
112113
struct tm gtm = t;
113114
char timeZoneName[70];
114115
strftime(timeZoneName, sizeof(timeZoneName), "%Z", &gtm);
115116
#endif
116117
if (timeZoneName[0]) {
117118
builder.appendLiteral(" (");
118-
#if OS(WINDOWS)
119-
builder.append(String(timeZoneName));
120-
#else
121119
builder.append(timeZoneName);
122-
#endif
123120
builder.append(')');
124121
}
125122
}

Source/WebKit2/ChangeLog

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2017-05-04 Konstantin Tokarev <[email protected]>
2+
3+
Fix compilation with ICU 59.1
4+
https://bugs.webkit.org/show_bug.cgi?id=171612
5+
6+
Reviewed by Mark Lam.
7+
8+
ICU 59.1 has broken source compatibility. Now it defines UChar as
9+
char16_t, which does not allow automatic type conversion from unsigned
10+
short in C++ code.
11+
12+
* Shared/API/c/WKString.cpp:
13+
(WKStringGetCharacters):
14+
115
2017-05-04 Dan Bernstein <[email protected]>
216

317
[Cocoa] -[WKWebsiteDataStore httpCookieStore] is declared in the main @interface but implemented in a category

Source/WebKit2/Shared/API/c/WKString.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t buffe
6161
unsigned unsignedBufferLength = std::min<size_t>(bufferLength, std::numeric_limits<unsigned>::max());
6262
auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength);
6363

64-
substring.getCharactersWithUpconvert(static_cast<UChar*>(buffer));
64+
substring.getCharactersWithUpconvert(reinterpret_cast<UChar*>(buffer));
6565
return substring.length();
6666
}
6767

Tools/ChangeLog

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2017-05-04 Konstantin Tokarev <[email protected]>
2+
3+
Fix compilation with ICU 59.1
4+
https://bugs.webkit.org/show_bug.cgi?id=171612
5+
6+
Reviewed by Mark Lam.
7+
8+
ICU 59.1 has broken source compatibility. Now it defines UChar as
9+
char16_t, which does not allow automatic type conversion from unsigned
10+
short in C++ code.
11+
12+
* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
13+
(UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):
14+
115
2017-05-04 Andy Estes <[email protected]>
216

317
[Cocoa] Add an optional width parameter to -[WKWebProcessPlugInNodeHandle renderedImageWithOptions:]

Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback()
171171
return;
172172

173173
JSStringRef result = m_uiScriptResultsPendingCompletion.take(m_currentScriptCallbackID);
174-
String scriptResult(JSStringGetCharactersPtr(result), JSStringGetLength(result));
174+
String scriptResult(reinterpret_cast<const UChar*>(JSStringGetCharactersPtr(result)), JSStringGetLength(result));
175175

176176
m_delegate.uiScriptDidComplete(scriptResult, m_currentScriptCallbackID);
177177

0 commit comments

Comments
 (0)