[webkit-changes] [WebKit/WebKit] 77ea37: Simplify the CodeGeneratorExtensions.pm generated ...

Timothy Hatcher noreply at github.com
Wed Sep 6 14:50:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 77ea37f47beef56db7979962d266e459efdf4d2f
      https://github.com/WebKit/WebKit/commit/77ea37f47beef56db7979962d266e459efdf4d2f
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2023-09-06 (Wed, 06 Sep 2023)

  Changed paths:
    M Source/WebKit/WebProcess/Extensions/Bindings/Cocoa/JSWebExtensionWrapperCocoa.mm
    M Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIExtension.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm

  Log Message:
  -----------
  Simplify the CodeGeneratorExtensions.pm generated code for the most common optional argument case.
https://webkit.org/b/261163
rdar://problem/114986995

Reviewed by Brian Weinstein.

Refine the argument handling for the Web Extension code generator.

* Streamlined argument handling for the common 2 and 3 argument cases, specifically when the last argument is optional.
* Replaced the previous loop-based method for these cases with more direct conditional checks.
* Complex handling remains in place for scenarios with multiple optional arguments beyond 3 total arguments.
* Cuts down the functions using the complex method from roughly 50 to just 7.
* Helps both improved readability and potential generated code performance.

* Source/WebKit/WebProcess/Extensions/Bindings/Cocoa/JSWebExtensionWrapperCocoa.mm:
(WebKit::toNSString): Only try to convert strings.
(WebKit::toNSDictionary): Don't try to convert functions or promises.
* Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm:
(_generateImplementationFile):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIExtension.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm:
(TestWebKitAPI::TEST):

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




More information about the webkit-changes mailing list