[webkit-changes] [WebKit/WebKit] 90ecb2: Refactor some fundamentals in ArgumentCodersCocoa.h

Brady Eidson noreply at github.com
Thu Nov 9 10:52:29 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 90ecb2cd9622645eadbe43708accc91290196bdf
      https://github.com/WebKit/WebKit/commit/90ecb2cd9622645eadbe43708accc91290196bdf
  Author: Brady Eidson <beidson at apple.com>
  Date:   2023-11-09 (Thu, 09 Nov 2023)

  Changed paths:
    M Source/WebKit/Platform/IPC/Decoder.h
    M Source/WebKit/Scripts/generate-serializers.py
    M Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
    M Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
    M Source/WebKit/Shared/mac/ObjCObjectGraph.mm
    M Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm

  Log Message:
  -----------
  Refactor some fundamentals in ArgumentCodersCocoa.h
https://bugs.webkit.org/show_bug.cgi?id=264385
rdar://118099847

Reviewed by Alex Christensen.

- Make all encode() methods work in terms of a single master encode() method
- Get rid of many extra decode() methods
- Make all decode() methods work in terms of a single master decode() method
- Rename the final decode() method that takes "allowed classes" to "decodeWithAllowedClasses" for compile
  safety and clarity
- Move the main "decodeWithAllowedClasses" entry point to Decoder itself to avoid re-entrancy in some situations.
- Make the way that "decodeWithAllowedClasses" gets the default array-of-allowed-classes a template so
  our softlinked classes can work with the default parameter
- Update callers that used to explicitly pass an allowed class to rely on the default, when possible.

Why do all this?

It makes Obj-C decode use nicer to write and to look at.

But also upcoming work for NSArray and NSDictionary will completely upend how we encode/decode for our Obj-C types
and this patch is a standalone prerequisite to enabling that work.

* Source/WebKit/Platform/IPC/Decoder.h:
(IPC::getClass):
(IPC::Decoder::decodeWithAllowedClasses):
* Source/WebKit/Scripts/generate-serializers.py:
(decode_type):
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp:
(IPC::ArgumentCoder<Namespace::OtherClass>::decode):
(IPC::ArgumentCoder<SoftLinkedMember>::decode):
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h:
(IPC::decodeWithAllowedClasses):
(IPC::ArgumentCoder<RetainPtr<T>>::decode):
(IPC::encode):
(IPC::decode): Deleted.
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::decodeFontInternal):
* Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::getClass<PKPayment>):
(IPC::getClass<PKContact>):
(IPC::getClass<PKPaymentMerchantSession>):
(IPC::getClass<PKPaymentMethod>):
(IPC::ArgumentCoder<WebCore::Payment>::decode):
(IPC::ArgumentCoder<WebCore::PaymentContact>::decode):
(IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode):
(IPC::ArgumentCoder<WebCore::PaymentMethod>::decode):
(IPC::ArgumentCoder<WebCore::PaymentSessionError>::decode):
(IPC::getClass<DDScannerResult>):
(IPC::ArgumentCoder<WebCore::DataDetectorElementInfo>::decode):
(IPC::getClass<AVOutputContext>):
(IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData):
(IPC::ArgumentCoder<WebCore::TextRecognitionDataDetector>::decodePlatformData):
(IPC::getClass<VKCImageAnalysis>):
(IPC::ArgumentCoder<RetainPtr<VKCImageAnalysis>>::decode):
* Source/WebKit/Shared/mac/ObjCObjectGraph.mm:
(WebKit::ObjCObjectGraph::decode):
* Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<WebCore::Credential>::decodePlatformData):

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




More information about the webkit-changes mailing list