Skip to content

Commit 00130dc

Browse files
committed
Make String::utf8(), StringImpl::utf8() and StringView::utf8() return a UTF8CString
https://bugs.webkit.org/show_bug.cgi?id=323846 Reviewed by Darin Adler. 320652@main introduced CStringWithEncoding (UTF8CString / Latin1CString / ASCIICString) and migrated String::ascii(), String::latin1() and the tryGetUTF8() family, leaving utf8() itself returning a plain CString behind a FIXME. 320795@main did the mechanical half of what was left: it added CString::legacyCStringPointer() and moved all 2516 utf8().data() call sites onto it while the two spellings were still equivalent. This is the retype. utf8() now returns UTF8CString on String, StringImpl and StringView, so data() is a const char8_t*, span() is a std::span<const char8_t>, and the encoding survives into every expression built from the result rather than stopping at the accessor. All three are done together because they share the one FIXME and because the call sites do not distinguish them: the same helper is reached from a String, a StringView substring and an Impl in adjacent lines, and retyping only one of them would leave the type meaningless in practice. String gains a constructor taking a CStringWithEncoding<T>, which is the same idea as its existing span constructors one level up: the character type already says how to decode the bytes, so the caller should not have to. * Source/JavaScriptCore/jsc.cpp: (fetchModuleFromLocalFileSystem): (JSC_DEFINE_HOST_FUNCTION): (CommandLine::parseArguments): * Source/JavaScriptCore/runtime/Identifier.h: (JSC::Identifier::utf8 const): * Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::createDateIntervalFormatIfNecessary): (JSC::IntlDateTimeFormat::createTemporalIntervalFormat const): * Source/JavaScriptCore/runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::initializeNumberFormat): * Source/JavaScriptCore/runtime/IntlPluralRules.cpp: (JSC::IntlPluralRules::initializePluralRules): * Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp: (JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat): * Source/JavaScriptCore/runtime/JSDateMath.cpp: (JSC::DateCache::timeZoneDisplayName): * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/RegExp.cpp: (JSC::RegExp::printTraceData): * Source/JavaScriptCore/wasm/WasmStreamingCompiler.cpp: (JSC::Wasm::StreamingCompiler::StreamingCompiler): * Source/JavaScriptCore/wasm/debugger/WasmDebugServerUtilities.cpp: (JSC::Wasm::stringToHex): * Source/JavaScriptCore/wasm/debugger/WasmExecutionHandler.cpp: (JSC::Wasm::WTF_REQUIRES_LOCK): * Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp: (JSC::compileAndInstantiate): * Source/WTF/wtf/FileSystem.cpp: (WTF::FileSystemImpl::toStdFileSystemPath): * Source/WTF/wtf/FormattedLogging.h: (std::formatter<T>::format const): * Source/WTF/wtf/cf/URLCF.cpp: (WTF::URL::createCFURL): * Source/WTF/wtf/cocoa/FileSystemCocoa.mm: (WTF::FileSystemImpl::openTemporaryFile): * Source/WTF/wtf/darwin/LibraryPathDiagnostics.mm: (WTF::LibraryPathDiagnosticsLogger::logJSONPayload): (WTF::LibraryPathDiagnosticsLogger::logDynamicLibraryInfo): (WTF::LibraryPathDiagnosticsLogger::logCryptexCanaryInfo): * Source/WTF/wtf/glib/FilePathWatcher.cpp: (WTF::FilePathWatcher::FilePathWatcher): * Source/WTF/wtf/posix/FileSystemPOSIX.cpp: (WTF::FileSystemImpl::openTemporaryFile): * Source/WTF/wtf/text/StringCommon.h: (WTF::unsafeSpan): * Source/WTF/wtf/text/StringImpl.cpp: (WTF::StringImpl::utf8 const): * Source/WTF/wtf/text/StringImpl.h: * Source/WTF/wtf/text/StringView.cpp: (WTF::StringView::utf8 const): * Source/WTF/wtf/text/StringView.h: * Source/WTF/wtf/text/WTFString.cpp: (WTF::String::utf8 const): * Source/WTF/wtf/text/WTFString.h: (WTF::String::String): * Source/WebCore/Modules/WebGPU/Implementation/WebGPUAdapterImpl.cpp: (WebCore::WebGPU::AdapterImpl::requestDevice): * Source/WebCore/Modules/WebGPU/Implementation/WebGPUCommandEncoderImpl.cpp: (WebCore::WebGPU::CommandEncoderImpl::beginRenderPass): * Source/WebCore/Modules/WebGPU/Implementation/WebGPUDeviceImpl.cpp: (WebCore::WebGPU::invalidEntryPointName): (WebCore::WebGPU::hasNullCharacter): (WebCore::WebGPU::DeviceImpl::createBuffer): (WebCore::WebGPU::DeviceImpl::createTexture): (WebCore::WebGPU::DeviceImpl::importExternalTexture): (WebCore::WebGPU::DeviceImpl::createBindGroupLayout): (WebCore::WebGPU::DeviceImpl::createPipelineLayout): (WebCore::WebGPU::DeviceImpl::createBindGroup): (WebCore::WebGPU::DeviceImpl::createShaderModule): (WebCore::WebGPU::convertToBacking): (WebCore::WebGPU::DeviceImpl::createCommandEncoder): (WebCore::WebGPU::DeviceImpl::createRenderBundleEncoder): (WebCore::WebGPU::DeviceImpl::createQuerySet): * Source/WebCore/Modules/WebGPU/Implementation/WebGPURenderBundleEncoderImpl.cpp: (WebCore::WebGPU::RenderBundleEncoderImpl::finish): * Source/WebCore/Modules/WebGPU/Implementation/WebGPUTextureImpl.cpp: (WebCore::WebGPU::TextureImpl::createView): * Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp: (WebCore::FetchBodyConsumer::packageFormData): * Source/WebCore/Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::close): * Source/WebCore/Modules/websockets/WebSocketExtensionDispatcher.cpp: (WebCore::WebSocketExtensionDispatcher::processHeaderValue): * Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp: (WebCore::AccessibilityObjectAtspi::text const): (WebCore::AccessibilityObjectAtspi::textInserted): (WebCore::AccessibilityObjectAtspi::textDeleted): (WebCore::AccessibilityObjectAtspi::textAtOffset const): (WebCore::AccessibilityObjectAtspi::characterAtOffset const): (WebCore::AccessibilityObjectAtspi::characterIndex const): (WebCore::AccessibilityObjectAtspi::textExtents const): (WebCore::AccessibilityObjectAtspi::selectionBounds const): (WebCore::AccessibilityObjectAtspi::selectRange): (WebCore::AccessibilityObjectAtspi::selectionChanged): (WebCore::AccessibilityObjectAtspi::textAttributesWithUTF8Offset const): (WebCore::AccessibilityObjectAtspi::scrollToMakeVisible const): (WebCore::AccessibilityObjectAtspi::scrollToPoint const): * Source/WebCore/bindings/js/GarbageCollectionController.cpp: (WebCore::GarbageCollectionController::dumpHeapForVM): * Source/WebCore/cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::SelectorCodeGenerator::SelectorCodeGenerator): * Source/WebCore/html/MediaFragmentURIParser.cpp: (WebCore::MediaFragmentURIParser::parseFragments): * Source/WebCore/html/canvas/WebGL2RenderingContext.cpp: (WebCore::WebGL2RenderingContext::getActiveUniformBlockName): * Source/WebCore/html/canvas/WebGLProgram.cpp: * Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp: (WebCore::ensureNotNull): (WebCore::WebGLRenderingContextBase::addDebugMessage): * Source/WebCore/html/canvas/WebGLRenderingContextBase.h: * Source/WebCore/loader/FrameLoader.cpp: (WebCore::FrameLoader::defaultSubstituteDataForURL): * Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp: (WebCore::MHTMLArchive::generateMHTMLData): * Source/WebCore/page/Performance.cpp: (WebCore::Performance::measure): * Source/WebCore/page/csp/ContentSecurityPolicy.cpp: (WebCore::generateHashesForContent): * Source/WebCore/platform/audio/HRTFElevation.cpp: (WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): * Source/WebCore/platform/graphics/BitmapImage.h: * Source/WebCore/platform/graphics/BitmapImageSource.cpp: (WebCore::BitmapImageSource::destroyDecodedFrames): (WebCore::BitmapImageSource::stopDecoderWorkQueue): (WebCore::BitmapImageSource::decode): (WebCore::BitmapImageSource::imageFrameDecodeAtIndexHasFinished): (WebCore::BitmapImageSource::requestNativeImageAtIndex): (WebCore::BitmapImageSource::requestNativeImageAtIndexIfNeeded): (WebCore::BitmapImageSource::nativeImageAtIndexCacheIfNeeded): * Source/WebCore/platform/graphics/GraphicsContextGL.h: * Source/WebCore/platform/graphics/GraphicsContextGLActiveInfo.h: * Source/WebCore/platform/graphics/ImageFrameAnimator.cpp: (WebCore::ImageFrameAnimator::startAnimation): (WebCore::ImageFrameAnimator::advanceAnimation): * Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp: (WebCore::extensionEnum): (WebCore::GraphicsContextGLANGLE::initialize): (WebCore::GraphicsContextGLANGLE::bindAttribLocation): (WebCore::GraphicsContextGLANGLE::activeAttribs): (WebCore::GraphicsContextGLANGLE::activeUniforms): (WebCore::GraphicsContextGLANGLE::getString): (WebCore::GraphicsContextGLANGLE::shaderSource): (WebCore::GraphicsContextGLANGLE::getProgramInfoLog): (WebCore::GraphicsContextGLANGLE::getShaderInfoLog): (WebCore::GraphicsContextGLANGLE::getUniformBlockIndex): (WebCore::GraphicsContextGLANGLE::getActiveUniformBlockName): (WebCore::GraphicsContextGLANGLE::transformFeedbackVaryings): (WebCore::GraphicsContextGLANGLE::getTransformFeedbackVarying): (WebCore::GraphicsContextGLANGLE::getFragDataLocation): (WebCore::GraphicsContextGLANGLE::getTranslatedShaderSourceANGLE): * Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h: * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::elementIdChanged const): * Source/WebCore/platform/graphics/gstreamer/VideoEncoderGStreamer.cpp: (WebCore::GStreamerInternalVideoEncoder::encode): * Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp: (WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram): * Source/WebCore/platform/libwpe/PlatformPasteboardLibWPE.cpp: (WebCore::PlatformPasteboard::write): * Source/WebCore/platform/network/curl/PublicSuffixStoreCurl.cpp: (WebCore::PublicSuffixStore::platformTopPrivatelyControlledDomain const): * Source/WebCore/platform/soup/PublicSuffixStoreSoup.cpp: (WebCore::PublicSuffixStore::platformTopPrivatelyControlledDomain const): * Source/WebCore/platform/sql/SQLiteDatabase.cpp: (WebCore::SQLiteDatabase::prepareStatementSlow): * Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp: (WebCore::TextCheckerEnchant::ignoreWord): (WebCore::TextCheckerEnchant::learnWord): (WebCore::TextCheckerEnchant::checkSpellingOfWord): (WebCore::TextCheckerEnchant::getGuessesForWord): (WebCore::TextCheckerEnchant::updateSpellCheckingLanguages): * Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp: (WebCore::lastHyphenLocation): * Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp: (WebCore::markupToCFHTML): (WebCore::setUTF8Data): * Source/WebCore/rendering/RenderText.cpp: (WebCore::capitalizeWordWithLocale): * Source/WebCore/xml/XSLStyleSheetLibxslt.cpp: (WebCore::XSLStyleSheet::locateStylesheetSubResource): * Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::appendFragmentSource): * Source/WebDriver/WebDriverService.cpp: (WebDriver::WebDriverService::run): * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp: (WebKit::RemoteGraphicsContextGL::addDebugMessage): * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h: * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in: * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.cpp: (WebKit::RemoteGraphicsContextGL::bindAttribLocation): (WebKit::RemoteGraphicsContextGL::getString): (WebKit::RemoteGraphicsContextGL::getProgramInfoLog): (WebKit::RemoteGraphicsContextGL::getShaderInfoLog): (WebKit::RemoteGraphicsContextGL::shaderSource): (WebKit::RemoteGraphicsContextGL::getFragDataLocation): (WebKit::RemoteGraphicsContextGL::transformFeedbackVaryings): (WebKit::RemoteGraphicsContextGL::getUniformBlockIndex): (WebKit::RemoteGraphicsContextGL::getActiveUniformBlockName): (WebKit::RemoteGraphicsContextGL::getTranslatedShaderSourceANGLE): * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h: * Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.mm: (WebKit::setIBLAssetOwnership): * Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::completeAuthentication): (WebKit::NetworkDataTaskSoup::download): (WebKit::NetworkDataTaskSoup::didFinishDownload): * Source/WebKit/NetworkProcess/soup/NetworkStorageSessionSoup.cpp: (WebKit::NetworkStorageSession::saveCredentialToPersistentStorage): (WebKit::NetworkStorageSession::setCookiesFromDOM const): (WebKit::NetworkStorageSession::deleteCookie const): (WebKit::NetworkStorageSession::deleteCookiesForHostnames): (WebKit::NetworkStorageSession::domCookiesForHost): * Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm: (decodeObject): * Source/WebKit/Shared/RTCNetwork.cpp: (WebKit::RTCNetwork::value const): (WebKit::WebRTCNetwork::SocketAddress::rtcAddress const): * Source/WebKit/Shared/WTFArgumentCoders.serialization.in: * Source/WebKit/Shared/WebGL.serialization.in: * Source/WebKit/Shared/WebMemorySampler.cpp: (WebKit::WebMemorySampler::appendCurrentMemoryUsageToFile): * Source/WebKit/Shared/WebPushMessage.cpp: (WebKit::WebPushMessage::notificationPayloadToCoreData const): * Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp: (WebKit::InputMethodFilter::notifySurrounding): * Source/WebKit/UIProcess/API/glib/WebKitContextMenuClient.cpp: * Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp: (WebKit::WebKitProtocolHandler::handleGPU): * Source/WebKit/UIProcess/API/glib/WebKitSecurityOrigin.cpp: (webkit_security_origin_to_string): * Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp: (webkit_settings_set_user_agent): (webkit_settings_set_user_agent_with_application_details): * Source/WebKit/UIProcess/API/glib/WebKitUserContentFilterStore.cpp: (webkit_user_content_filter_store_fetch_identifiers): * Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp: (WebKit::DragSource::DragSource): * Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp: (WebKit::DragSource::begin): * Source/WebKit/UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp: (WebKit::RemoteInspectorProtocolHandler::updateTargetList): * Source/WebKit/UIProcess/API/gtk/WebKitWebInspector.cpp: * Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp: (webkitWebViewBaseSetPlugID): * Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp: (WebKit::DownloadProxy::updateQuarantinePropertiesIfPossible): * Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorHTTPServer.cpp: (WebKit::RemoteInspectorHTTPServer::handleRequest const): (WebKit::RemoteInspectorHTTPServer::sendMessageToFrontend const): * Source/WebKit/UIProcess/Inspector/wpe/WebInspectorUIProxyWPE.cpp: (WebKit::computeContentHash): (WebKit::WebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp: (WebKit::bindV4l): * Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: (WebKit::WebAuthenticatorCoordinatorProxy::requestsForAssertion): * Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): * Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp: (WebKit::Clipboard::write): * Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp: (WebKit::Clipboard::write): * Source/WebKit/UIProcess/gtk/ValidationBubbleGtk.cpp: (WebKit::ValidationBubbleGtk::ValidationBubbleGtk): * Source/WebKit/UIProcess/wpe/WebPasteboardProxyWPE.cpp: (WebKit::setClipboardContentFromSpan): * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: (WebKit::RemoteGraphicsContextGLProxy::addDebugMessage): * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in: * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp: (WebKit::RemoteGraphicsContextGLProxy::bindAttribLocation): (WebKit::RemoteGraphicsContextGLProxy::getString): (WebKit::RemoteGraphicsContextGLProxy::getProgramInfoLog): (WebKit::RemoteGraphicsContextGLProxy::getShaderInfoLog): (WebKit::RemoteGraphicsContextGLProxy::shaderSource): (WebKit::RemoteGraphicsContextGLProxy::getFragDataLocation): (WebKit::RemoteGraphicsContextGLProxy::transformFeedbackVaryings): (WebKit::RemoteGraphicsContextGLProxy::getUniformBlockIndex): (WebKit::RemoteGraphicsContextGLProxy::getActiveUniformBlockName): (WebKit::RemoteGraphicsContextGLProxy::getTranslatedShaderSourceANGLE): * Source/WebKit/WebProcess/InjectedBundle/API/glib/WebProcessExtensionManager.cpp: (WebKit::parseUserData): * Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: (WebKit::InjectedBundle::extendClassesForParameterCoder): * Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp: (WebKit::WebPrintOperationGtk::endPrint): * Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp: (TestWebKitAPI::TEST_F(FileSystemTest, readEntireFile)): * Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp: (TestWebKitAPI::TEST(WTF, StringUTF8ConversionInvalidUTF16LenientMode)): (TestWebKitAPI::TEST(WTF, StringUTF8ConversionStrictReplacingMode)): * Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: (TestWebKitAPI::TEST(URLExtras, URLExtras_Spoof)): * Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm: * Tools/TestWebKitAPI/Tests/WebCore/glib/GraphicsContextGLTextureMapper.cpp: * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/EventAttribution.mm: (TestWebKitAPI::triggerAttributionWithSubresourceRedirect): (TestWebKitAPI::signUnlinkableTokenAndSendSecretToken): * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/NetworkProcess.mm: (TEST(WebKit, HTTPReferer)): * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SOAuthorizationTests.mm: (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedCloseByParent)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedCloseByWebKit)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedWithOtherHttpStatusCode)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedWithCookie)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedTwice)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedSuppressActiveSession)): (TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionSucceedNewWindowNavigation)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, InterceptionSuccess)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, InterceptionSuccessBackForwardList)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, InterceptionSucceedWithOtherHttpStatusCode)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, InterceptionSuccessTwice)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, SOAuthorizationLoadPolicyAllowAsync)): (TestWebKitAPI::TEST(SOAuthorizationSubFrame, InterceptionSuccessMessageOrder)): * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestAutomationSession.cpp: * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestSSL.cpp: * Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: (WTR::InjectedBundlePage::willSendRequestForFrame): * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::createTestURL): * Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp: (WTR::UIScriptControllerGtk::copyText): Canonical link: https://commits.webkit.org/320905@main
1 parent 4a94df6 commit 00130dc

129 files changed

Lines changed: 511 additions & 469 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎LayoutTests/ipc/serialized-type-info.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124

125125
const fundamentalTypes = [
126126
"char",
127+
"char8_t",
127128
"char16_t",
128129
"char32_t",
129130
"short",

‎Source/JavaScriptCore/jsc.cpp‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ static bool fetchModuleFromLocalFileSystem(const URL& fileURL, Vector& buffer)
14611461
if ((status.st_mode & S_IFMT) != S_IFREG)
14621462
return false;
14631463

1464-
FILE* f = fopen(pathName.data(), "r");
1464+
FILE* f = fopen(pathName.legacyCStringPointer(), "r");
14651465
#endif
14661466
if (!f) {
14671467
SAFE_FPRINTF(stderr, "Could not open file: %s\n", fileName.utf8());
@@ -2125,8 +2125,7 @@ JSC_DEFINE_HOST_FUNCTION(functionWriteFile, (JSGlobalObject* globalObject, CallF
21252125
return throwVMError(globalObject, scope, "Could not open file."_s);
21262126

21272127
auto size = WTF::visit(WTF::makeVisitor([&](const String& string) {
2128-
CString utf8 = string.utf8();
2129-
return handle.write(byteCast<uint8_t>(utf8.span()));
2128+
return handle.write(byteCast<uint8_t>(string.utf8().span()));
21302129
}, [&] (const std::span<const uint8_t>& data) {
21312130
return handle.write(data);
21322131
}), data);
@@ -2984,8 +2983,7 @@ JSC_DEFINE_HOST_FUNCTION(functionDumpBytecodeProfile, (JSGlobalObject* globalObj
29842983
String path = callFrame->argument(0).toWTFString(globalObject);
29852984
RETURN_IF_EXCEPTION(scope, { });
29862985

2987-
auto pathUtf8 = path.utf8();
2988-
bool ok = vm.m_perBytecodeProfiler->save(pathUtf8.data());
2986+
bool ok = vm.m_perBytecodeProfiler->save(path.utf8().legacyCStringPointer());
29892987
return JSValue::encode(jsBoolean(ok));
29902988
}
29912989

@@ -4371,8 +4369,12 @@ void CommandLine::parseArguments(int argc, char** argv, int start)
43714369
if (!strncmp(arg, singleStringSubArgList.characters(), singleStringSubArgList.length())) {
43724370
// We just assume input is utf-8 (probably ascii)
43734371
String subArgList = String::fromLatin1(arg + singleStringSubArgList.length());
4374-
Vector<CString> splitArgs = subArgList.split(" "_s).map([](const String& arg) { return arg.impl()->utf8(); });
4375-
Vector<char*> buffer = splitArgs.map([](const CString& arg) { return const_cast<char*>(arg.data()); });
4372+
auto splitArgs = subArgList.split(" "_s).map([](const String& arg) {
4373+
return arg.impl()->utf8();
4374+
});
4375+
Vector<char*> buffer = splitArgs.map([](const UTF8CString& arg) {
4376+
return const_cast<char*>(arg.legacyCStringPointer());
4377+
});
43764378

43774379
parseArguments(buffer.mutableSpan().size(), buffer.mutableSpan().data(), 0);
43784380
continue;

‎Source/JavaScriptCore/runtime/Identifier.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Identifier {
9999
int length() const { return m_string.length(); }
100100

101101
CString ascii() const { return m_string.string().ascii(); }
102-
CString utf8() const { return m_string.string().utf8(); }
102+
UTF8CString utf8() const { return m_string.string().utf8(); }
103103

104104
// There's 2 functions to construct Identifier from string, (1) fromString and (2) fromUid.
105105
// They have different meanings in keeping or discarding symbol-ness of strings.

‎Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,12 +1751,12 @@ UDateIntervalFormat* IntlDateTimeFormat::createDateIntervalFormatIfNecessary(JSG
17511751
if (m_impl->m_hourCycle != HourCycle::None)
17521752
localeBuilder.append("-hc-"_s, hourCycleString(m_impl->m_hourCycle));
17531753
}
1754-
CString dataLocaleWithExtensions = localeBuilder.toString().utf8();
1754+
auto dataLocaleWithExtensions = localeBuilder.toString().utf8();
17551755

17561756
UErrorCode status = U_ZERO_ERROR;
17571757
String timeZoneForICU = m_impl->m_timeZone.toICUString();
17581758
StringView timeZoneView(timeZoneForICU);
1759-
m_dateIntervalFormat = std::unique_ptr<UDateIntervalFormat, UDateIntervalFormatDeleter>(udtitvfmt_open(dataLocaleWithExtensions.data(), skeleton.span().data(), skeleton.size(), timeZoneView.upconvertedCharacters(), timeZoneView.length(), &status));
1759+
m_dateIntervalFormat = std::unique_ptr<UDateIntervalFormat, UDateIntervalFormatDeleter>(udtitvfmt_open(dataLocaleWithExtensions.legacyCStringPointer(), skeleton.span().data(), skeleton.size(), timeZoneView.upconvertedCharacters(), timeZoneView.length(), &status));
17601760
if (U_FAILURE(status)) [[unlikely]] {
17611761
throwTypeError(globalObject, scope, "failed to initialize DateIntervalFormat"_s);
17621762
return nullptr;
@@ -2636,10 +2636,10 @@ IntlDateTimeFormat::createTemporalIntervalFormat(UDateFormat* tempFormat, Tempor
26362636
localeBuilder.append(m_impl->m_dataLocale, "-u-ca-"_s, ensureCalendar(), "-nu-"_s, ensureNumberingSystem());
26372637
if (m_impl->m_hourCycle != HourCycle::None)
26382638
localeBuilder.append("-hc-"_s, hourCycleString(m_impl->m_hourCycle));
2639-
CString localeWithExt = localeBuilder.toString().utf8();
2639+
auto localeWithExt = localeBuilder.toString().utf8();
26402640

26412641
return std::unique_ptr<UDateIntervalFormat, UDateIntervalFormatDeleter>(
2642-
udtitvfmt_open(localeWithExt.data(), tempSkeleton.span().data(), tempSkeleton.size(),
2642+
udtitvfmt_open(localeWithExt.legacyCStringPointer(), tempSkeleton.span().data(), tempSkeleton.size(),
26432643
tzView.upconvertedCharacters(), tzView.length(), &status));
26442644
}
26452645

‎Source/JavaScriptCore/runtime/IntlNumberFormat.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ void IntlNumberFormat::initializeNumberFormat(JSGlobalObject* globalObject, JSVa
409409
m_signDisplay = intlOption<SignDisplay>(globalObject, options, Identifier::fromString(vm, "signDisplay"_s), { { "auto"_s, SignDisplay::Auto }, { "never"_s, SignDisplay::Never }, { "always"_s, SignDisplay::Always }, { "exceptZero"_s, SignDisplay::ExceptZero }, { "negative"_s, SignDisplay::Negative } }, "signDisplay must be either \"auto\", \"never\", \"always\", \"exceptZero\", or \"negative\""_s, SignDisplay::Auto);
410410
RETURN_IF_EXCEPTION(scope, void());
411411

412-
CString dataLocaleWithExtensions = m_numberingSystem.isNull() ? m_dataLocale.utf8() : makeString(m_dataLocale, "-u-nu-"_s, m_numberingSystem).utf8();
412+
auto dataLocaleWithExtensions = m_numberingSystem.isNull() ? m_dataLocale.utf8() : makeString(m_dataLocale, "-u-nu-"_s, m_numberingSystem).utf8();
413413
dataLogLnIf(IntlNumberFormatInternal::verbose, "dataLocaleWithExtensions:(", dataLocaleWithExtensions , ")");
414414

415415
// Options are obtained. Configure formatter here.
@@ -540,7 +540,7 @@ void IntlNumberFormat::initializeNumberFormat(JSGlobalObject* globalObject, JSVa
540540
auto upconverted = skeletonView.upconvertedCharacters();
541541

542542
UErrorCode status = U_ZERO_ERROR;
543-
m_numberFormatter = std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter>(unumf_openForSkeletonAndLocale(upconverted.get(), skeletonView.length(), dataLocaleWithExtensions.data(), &status));
543+
m_numberFormatter = std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter>(unumf_openForSkeletonAndLocale(upconverted.get(), skeletonView.length(), dataLocaleWithExtensions.legacyCStringPointer(), &status));
544544
if (U_FAILURE(status)) {
545545
throwTypeError(globalObject, scope, "Failed to initialize NumberFormat"_s);
546546
return;

‎Source/JavaScriptCore/runtime/IntlPluralRules.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,23 @@ void IntlPluralRules::initializePluralRules(JSGlobalObject* globalObject, JSValu
145145
StringView skeletonView { skeletonBuilder };
146146
auto upconverted = skeletonView.upconvertedCharacters();
147147

148-
m_numberFormatter = std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter>(unumf_openForSkeletonAndLocale(upconverted.get(), skeletonView.length(), locale.data(), &status));
148+
m_numberFormatter = std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter>(unumf_openForSkeletonAndLocale(upconverted.get(), skeletonView.length(), locale.legacyCStringPointer(), &status));
149149
if (U_FAILURE(status)) {
150150
throwTypeError(globalObject, scope, "failed to initialize PluralRules"_s);
151151
return;
152152
}
153153

154154
vm.heap.reportExtraMemoryAllocated(this, estimatedUNumberFormatterSize);
155155

156-
m_numberRangeFormatter = std::unique_ptr<UNumberRangeFormatter, UNumberRangeFormatterDeleter>(unumrf_openForSkeletonWithCollapseAndIdentityFallback(upconverted.get(), skeletonView.length(), UNUM_RANGE_COLLAPSE_NONE, UNUM_IDENTITY_FALLBACK_RANGE, locale.data(), nullptr, &status));
156+
m_numberRangeFormatter = std::unique_ptr<UNumberRangeFormatter, UNumberRangeFormatterDeleter>(unumrf_openForSkeletonWithCollapseAndIdentityFallback(upconverted.get(), skeletonView.length(), UNUM_RANGE_COLLAPSE_NONE, UNUM_IDENTITY_FALLBACK_RANGE, locale.legacyCStringPointer(), nullptr, &status));
157157
if (U_FAILURE(status)) {
158158
throwTypeError(globalObject, scope, "failed to initialize PluralRules"_s);
159159
return;
160160
}
161161

162162
vm.heap.reportExtraMemoryAllocated(this, estimatedUNumberRangeFormatterSize);
163163

164-
m_pluralRules = std::unique_ptr<UPluralRules, UPluralRulesDeleter>(uplrules_openForType(locale.data(), m_type == Type::Ordinal ? UPLURAL_TYPE_ORDINAL : UPLURAL_TYPE_CARDINAL, &status));
164+
m_pluralRules = std::unique_ptr<UPluralRules, UPluralRulesDeleter>(uplrules_openForType(locale.legacyCStringPointer(), m_type == Type::Ordinal ? UPLURAL_TYPE_ORDINAL : UPLURAL_TYPE_CARDINAL, &status));
165165
if (U_FAILURE(status)) {
166166
throwTypeError(globalObject, scope, "failed to initialize PluralRules"_s);
167167
return;

‎Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void IntlRelativeTimeFormat::initializeRelativeTimeFormat(JSGlobalObject* global
114114

115115
m_numberingSystem = resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Nu)];
116116
m_dataLocale = resolved.dataLocale;
117-
CString dataLocaleWithExtensions = m_numberingSystem.isNull() ? m_dataLocale.utf8() : makeString(m_dataLocale, "-u-nu-"_s, m_numberingSystem).utf8();
117+
auto dataLocaleWithExtensions = m_numberingSystem.isNull() ? m_dataLocale.utf8() : makeString(m_dataLocale, "-u-nu-"_s, m_numberingSystem).utf8();
118118

119119
m_style = intlOption<Style>(globalObject, options, vm.propertyNames->style, { { "long"_s, Style::Long }, { "short"_s, Style::Short }, { "narrow"_s, Style::Narrow } }, "style must be either \"long\", \"short\", or \"narrow\""_s, Style::Long);
120120
RETURN_IF_EXCEPTION(scope, void());
@@ -135,7 +135,7 @@ void IntlRelativeTimeFormat::initializeRelativeTimeFormat(JSGlobalObject* global
135135
RETURN_IF_EXCEPTION(scope, void());
136136

137137
UErrorCode status = U_ZERO_ERROR;
138-
auto numberFormat = std::unique_ptr<UNumberFormat, ICUDeleter<unum_close>>(unum_open(UNUM_DECIMAL, nullptr, 0, dataLocaleWithExtensions.data(), nullptr, &status));
138+
auto numberFormat = std::unique_ptr<UNumberFormat, ICUDeleter<unum_close>>(unum_open(UNUM_DECIMAL, nullptr, 0, dataLocaleWithExtensions.legacyCStringPointer(), nullptr, &status));
139139
if (U_FAILURE(status)) [[unlikely]] {
140140
throwTypeError(globalObject, scope, "failed to initialize RelativeTimeFormat"_s);
141141
return;
@@ -161,7 +161,7 @@ void IntlRelativeTimeFormat::initializeRelativeTimeFormat(JSGlobalObject* global
161161
unum_setAttribute(numberFormat.get(), UNUM_MINIMUM_GROUPING_DIGITS, useLocaleDefault);
162162

163163
// ureldatefmt_open adopts the UNumberFormat, so we release ownership here.
164-
m_relativeDateTimeFormatter = std::unique_ptr<URelativeDateTimeFormatter, URelativeDateTimeFormatterDeleter>(ureldatefmt_open(dataLocaleWithExtensions.data(), numberFormat.release(), icuStyle, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, &status));
164+
m_relativeDateTimeFormatter = std::unique_ptr<URelativeDateTimeFormatter, URelativeDateTimeFormatterDeleter>(ureldatefmt_open(dataLocaleWithExtensions.legacyCStringPointer(), numberFormat.release(), icuStyle, UDISPCTX_CAPITALIZATION_FOR_STANDALONE, &status));
165165
if (U_FAILURE(status)) [[unlikely]] {
166166
throwTypeError(globalObject, scope, "failed to initialize RelativeTimeFormat"_s);
167167
return;

‎Source/JavaScriptCore/runtime/JSDateMath.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,16 @@ String DateCache::timeZoneDisplayName(bool isDST)
452452
{
453453
if (m_timeZoneStandardDisplayNameCache.isNull()) {
454454
auto& timeZoneCache = *this->timeZoneCache();
455-
CString language = defaultLanguage().utf8();
455+
auto language = defaultLanguage().utf8();
456456
{
457457
Vector<char16_t, 32> standardDisplayNameBuffer;
458-
auto status = callBufferProducingFunction(ucal_getTimeZoneDisplayName, timeZoneCache.m_calendar.get(), UCAL_STANDARD, language.data(), standardDisplayNameBuffer);
458+
auto status = callBufferProducingFunction(ucal_getTimeZoneDisplayName, timeZoneCache.m_calendar.get(), UCAL_STANDARD, language.legacyCStringPointer(), standardDisplayNameBuffer);
459459
if (U_SUCCESS(status))
460460
m_timeZoneStandardDisplayNameCache = String::adopt(WTF::move(standardDisplayNameBuffer));
461461
}
462462
{
463463
Vector<char16_t, 32> dstDisplayNameBuffer;
464-
auto status = callBufferProducingFunction(ucal_getTimeZoneDisplayName, timeZoneCache.m_calendar.get(), UCAL_DST, language.data(), dstDisplayNameBuffer);
464+
auto status = callBufferProducingFunction(ucal_getTimeZoneDisplayName, timeZoneCache.m_calendar.get(), UCAL_DST, language.legacyCStringPointer(), dstDisplayNameBuffer);
465465
if (U_SUCCESS(status))
466466
m_timeZoneDSTDisplayNameCache = String::adopt(WTF::move(dstDisplayNameBuffer));
467467
}

‎Source/JavaScriptCore/runtime/JSGlobalObject.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ JSC_DEFINE_HOST_FUNCTION(dumpAndClearSamplingProfilerSamples, (JSGlobalObject* g
530530
return JSValue::encode(jsUndefined());
531531
}
532532

533-
CString utf8String = jsonData.utf8();
533+
auto utf8String = jsonData.utf8();
534534

535535
fileHandle.write(byteCast<uint8_t>(utf8String.span()));
536536
dataLogLn("Dumped sampling profiler samples to ", tempFilePath);

‎Source/JavaScriptCore/runtime/RegExp.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void RegExp::printTraceData()
555555
formattedRegExp[SameLineFormatedRegExpnWidth] = '\0';
556556

557557
auto patternCStr = pattern().utf8(); // Hold a reference so it doesn't get destroyed.
558-
auto patternStr = patternCStr.data();
558+
auto patternStr = patternCStr.legacyCStringPointer();
559559
auto patternLength = pattern().length();
560560

561561
auto appendRawPatternBuffer = [&] (size_t& index) {

0 commit comments

Comments
 (0)