[webkit-changes] [WebKit/WebKit] afff11: [WK2] Allow moving objects into ArgumentCoder enco...

Žan Doberšek noreply at github.com
Mon Nov 28 09:24:08 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: afff11b97280d9bb26274dfad5ca123f8bffffae
      https://github.com/WebKit/WebKit/commit/afff11b97280d9bb26274dfad5ca123f8bffffae
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2022-11-28 (Mon, 28 Nov 2022)

  Changed paths:
    M Source/WTF/wtf/StdLibExtras.h
    M Source/WebKit/Platform/IPC/ArgumentCoders.h
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp

  Log Message:
  -----------
  [WK2] Allow moving objects into ArgumentCoder encoding functions
https://bugs.webkit.org/show_bug.cgi?id=247525

Reviewed by Alex Christensen and Kimmo Kinnunen.

Adjust current encode() functions for different ArgumentCoder
specializations so that rvalue references to a given object can be
passed in, enabling different resources to be more optimally handled.
This mostly concerns containers and other wrapper types like
std::optional<> and std::variant<>. In changed encode() functions,
universal references are used to accept the passed-in value, and
std::forward_like<> is used to apply the value category from the
universal reference to the contained object that's passed forward into
the encoding process.

std::forward_like<> is a C++23 feature, so not in line yet with the
current C++ standard in use in the project. A fallback implementation is
added in StdLibExtras.h, properly guarded with the relevant feature-test
macro.

As an example, this can simplify encoding of Unix file descriptors or
containers of such items. When such objects can be consumed through
these rvalue references, the underlying resources can completely avoid
any otherwise-necessary duplication.

Testing facilities are added, covering different types that now support
encoding of objects passed through rvalue references. For each type,
testing is done for lvalues, rvalues and moved-in rvalues of that type.
HashTable-based types are skipped for now because of issues in
constructing appropriate values of those types.

* Source/WTF/wtf/StdLibExtras.h:
(std::forward_like):
* Source/WebKit/Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<std::optional<T>>::encode):
(IPC::ArgumentCoder<std::optional<T>>::decode):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp: Added.
(TestWebKitAPI::EncodingCounter::CounterValues::CounterValues):
(TestWebKitAPI::EncodingCounter::CounterValues::operator== const):
(TestWebKitAPI::EncodingCounter::EncodingCounter):
(TestWebKitAPI::EncodingCounter::encode const):
(TestWebKitAPI::EncodingCounter::encode):
(TestWebKitAPI::EncodingCounter::decode):
(TestWebKitAPI::PrintTo):
(TestWebKitAPI::ArgumentCoderEncodingCounterTest::ArgumentCoderEncodingCounterTest):
(TestWebKitAPI::ArgumentCoderEncodingCounterTest::testEncoding):
(TestWebKitAPI::TEST_P):

Canonical link: https://commits.webkit.org/257073@main




More information about the webkit-changes mailing list