Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 605522841bd2e3f24e23e233a7d97c189d9ae28f
https://github.com/WebKit/WebKit/commit/605522841bd2e3f24e23e233a7d97c189d9ae28f
Author: Adrian Taylor <[email protected]>
Date: 2026-09-15 (Tue, 15 Sep 2026)
Changed paths:
M Source/WebKit/Platform/IPC/HandleMessage.h
M Source/WebKit/Platform/IPC/MessageCheck.swift
M Source/WebKit/Scripts/webkit/messages.py
M Source/WebKit/Scripts/webkit/tests/MessageArgumentDescriptions.cpp
M Source/WebKit/Scripts/webkit/tests/MessageNames.cpp
M Source/WebKit/Scripts/webkit/tests/MessageNames.h
M
Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftEnabledByMessageReceiver.cpp
M
Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftEnabledByMessageReceiver.swift
M Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftMessageReceiver.cpp
M
Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftMessageReceiver.swift
M Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftMessages.h
M Source/WebKit/Scripts/webkit/tests/TestWithSwift.messages.in
M
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyAndEnabledByMessageReceiver.cpp
M
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyAndEnabledByMessageReceiver.swift
M
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyAndEnabledByMessages.h
M
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyMessageReceiver.cpp
M
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyMessageReceiver.swift
M Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyMessages.h
M Source/WebKit/Scripts/webkit/tests/TestWithSwiftMessageReceiver.cpp
M Source/WebKit/Scripts/webkit/tests/TestWithSwiftMessageReceiver.swift
M Source/WebKit/Scripts/webkit/tests/TestWithSwiftMessages.h
M
Source/WebKit/Shared/IPCTesterReceiver.swift
M Source/WebKit/Shared/SessionState.h
M Source/WebKit/UIProcess/WebBackForwardList.swift
Log Message:
-----------
[Swift] Generate the message check catch for Swift receivers
https://bugs.webkit.org/show_bug.cgi?id=323854
rdar://168139740
Reviewed by Richard Robinson.
This is part two of two, in the work to move Swift messageCheck to be Swift
idiomatic.
This part autogenerates the catching mechanisms which were written manually
in the previous PR.
messages.py now emits a wrapper for every message on a Swift receiver.
A handler is then just
func backForwardUpdateItem(connection: IPC.Connection, frameState:
WebKit.RefFrameState)
throws(InvalidMessage)
The handlers also lose @used: they are reached from the generated wrapper
rather than from C++, and @used exists only to stop C++-reachable Swift being
collected.
A final improvement here is autogeneration of aliases for use in
Swift e.g.
using RefFrameState = Ref<FrameState>
A message with a reply has to answer its sender even when the check fails, or
the sender waits forever. In C++ the completion is written out at each call
site, so the default value spelled there can drift from the reply
signature. In Swift we do better and generate a default reply:
void completeWithDefaultReply(<Message>CompletionHandler&);
Four things made this awkward.
Every handler function now has to take an IPC.Connection, whether it uses it
or not. This is because Swift has no mechanism like SFINAE to decide to call
a function differently based on a different parameter set.
Swift does not export extension members to C++, and a generator cannot add
members to a hand-written class, so the wrappers go on <Receiver>WeakRef. That
is already a generated class, the forwarder already owns one, and it already
holds the weak reference to the target.
A wrapper has to spell its parameter types in Swift, but
.messages.in names them in
C++. Logic is added to convert them to Swift.
handleMessageAsync passed the connection straight to callMemberFunction where
handleMessage and handleMessageSynchronous both route it through
makeConnectionArgument, so a Swift handler for a message with an async reply
could not take a connection at all. It now matches the other two.
Everything under Source/WebKit/Scripts/webkit/tests/ is mechanical output of
messages_unittest.py -r.
Canonical link:
https://flagged.apple.com:443/proxy?t2=Di7O8S5Py3&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzIxMTU1QG1haW4=&emid=ee8d3531-3f8f-42ac-93b7-47d242d73d72&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications