Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate everything needed regarding a WebKit Secure Coding type (and move DDScannerResult over to the generated format) #21216

Conversation

beidson
Copy link
Contributor

@beidson beidson commented Dec 2, 2023

9bd720b

Generate everything needed regarding a WebKit Secure Coding type (and move DDScannerResult over to the generated format)
https://bugs.webkit.org/show_bug.cgi?id=265728
rdar://119079477

Reviewed by Alex Christensen.

All WebKit Secure Coding types will follow the identical pattern of:
1 - Get property list dictionary
2 - Encode it
3 - Decode it
4 - Verify the decoded dictionary contents match the type
5 - Recreate the object with the property list

Instead of writing all of that code over time after time, let's generate it.

Given an Objective-C type and a description of its expected dictionary format, the generator now:
1 - Generates a CoreIPC wrapper for that type
2 - Generates the ArgumentCoders for that CoreIPC wrapper (including code that validates the dictionary format)
3 - Generates a description of the dictionary in SerializedTypeInfo
4 - Generates a description of the CoreIPC wrapper in SerializedTypeInfo

All of the above was enough to move DDScannerResult over to this new format, and will greatly
accelerate how quickly we can add new types.

* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Scripts/generate-serializers.py:
(SerializedType.__init__):
(SerializedType.namespace_and_name):
(SerializedType.name_declaration_for_serialized_type_info):
(SerializedType.members_for_serialized_type_info):
(SerializedType.cpp_type_from_struct_or_class):
(SerializedType):
(SerializedType.cpp_struct_or_class_name):
(SerializedType.is_webkit_secure_coding_type):
(SerializedType.wrapper_for_webkit_secure_coding_type):
(generate_forward_declarations):
(generate_impl):
(generate_one_serialized_type_info):
(output_sorted_headers):
(generate_serialized_type_info):
(parse_serialized_types):
(generate_one_dictionary_member_validation):
(generate_webkit_secure_coding_impl):
(generate_webkit_secure_coding_impl.is):
(generate_webkit_secure_coding_header):
(main):
(SerializedType.namespace_unless_wtf_and_name): Deleted.
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp:
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h:
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.cpp: Added.
(WebKit::CoreIPCNSSomeFoundationType::CoreIPCNSSomeFoundationType):
(WebKit::CoreIPCNSSomeFoundationType::isValidDictionary):
(WebKit::CoreIPCNSSomeFoundationType::toID const):
(WebKit::CoreIPCDDScannerResult::CoreIPCDDScannerResult):
(WebKit::CoreIPCDDScannerResult::isValidDictionary):
(WebKit::CoreIPCDDScannerResult::toID const):
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.h: Added.
(WebKit::CoreIPCNSSomeFoundationType::CoreIPCNSSomeFoundationType):
(WebKit::CoreIPCDDScannerResult::CoreIPCDDScannerResult):
* Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp:
(WebKit::allSerializedTypes):
* Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in:
* Source/WebKit/Scripts/webkit/tests/WebKitPlatformGeneratedSerializers.cpp:
(IPC::ArgumentCoder<WebKit::CoreIPCNSSomeFoundationType>::encode):
(IPC::ArgumentCoder<WebKit::CoreIPCNSSomeFoundationType>::decode):
(IPC::ArgumentCoder<WebKit::CoreIPCDDScannerResult>::encode):
(IPC::ArgumentCoder<WebKit::CoreIPCDDScannerResult>::decode):
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.h: Removed.
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.mm: Removed.
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.serialization.in:
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.h:
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.mm:
(WebKit::CoreIPCDictionary::CoreIPCDictionary):
(WebKit::CoreIPCDictionary::keyHasValueOfType const):
(WebKit::CoreIPCDictionary::keyIsMissingOrHasValueOfType const):
(WebKit::CoreIPCDictionary::collectionValuesAreOfType const):
(WebKit::CoreIPCDictionary::createNSDictionaryIfNeeded const):
(WebKit::CoreIPCDictionary::toID const):
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.serialization.in:
* Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.mm:
(WebKit::secureCodingValueFromID):
(WebKit::valueFromID):
* Source/WebKit/Shared/Cocoa/CoreIPCSecureCoding.h:
* Source/WebKit/Shared/Cocoa/CoreIPCSecureCoding.mm:
(WebKit::CoreIPCSecureCoding::conformsToWebKitSecureCoding):
(WebKit::CoreIPCSecureCoding::conformsToSecureCoding):
(WebKit::CoreIPCSecureCoding::CoreIPCSecureCoding):
* Source/WebKit/Shared/Cocoa/CoreIPCTypes.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

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

7c3dcf8

Misc iOS, tvOS & watchOS macOS Linux Windows
❌ πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
❌ πŸ§ͺ webkitpy βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 ❌ πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@beidson beidson self-assigned this Dec 2, 2023
@beidson beidson added the WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore). label Dec 2, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 2, 2023
@beidson beidson removed the merging-blocked Applied to prevent a change from being merged label Dec 3, 2023
@beidson beidson force-pushed the eng/Generate-everything-needed-regarding-a-WebKit-Secure-Coding-type-and-move-DDScannerResult-over-to-the-generated-format branch from 78d2ea1 to 7b9cda9 Compare December 3, 2023 00:24
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 3, 2023
@beidson
Copy link
Contributor Author

beidson commented Dec 3, 2023

These ios-wk2-wpt failures seem unlikely to be from this patch.
I am building for iOS locally to try to reproduce

@beidson beidson removed the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@beidson beidson force-pushed the eng/Generate-everything-needed-regarding-a-WebKit-Secure-Coding-type-and-move-DDScannerResult-over-to-the-generated-format branch from 7b9cda9 to 2bf351a Compare December 4, 2023 18:43
Source/WebKit/Scripts/generate-serializers.py Outdated Show resolved Hide resolved
Source/WebKit/Scripts/generate-serializers.py Outdated Show resolved Hide resolved
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@beidson beidson removed the merging-blocked Applied to prevent a change from being merged label Dec 5, 2023
@beidson beidson force-pushed the eng/Generate-everything-needed-regarding-a-WebKit-Secure-Coding-type-and-move-DDScannerResult-over-to-the-generated-format branch from 2bf351a to 7c3dcf8 Compare December 5, 2023 01:25
@beidson
Copy link
Contributor Author

beidson commented Dec 5, 2023

The GTK API test failures can't be due to this patch.
The webkitpy failures didn't happen on the last upload before this, and appear to be something system related to the bot that ran. There's no actual failures listed or obvious cause, etc. I ran webkitpy tests locally on two machines with 3 build styles and all was well.

I'll keep a close eye after landing.

@beidson beidson added the merge-queue Applied to send a pull request to merge-queue label Dec 5, 2023
… move DDScannerResult over to the generated format)

https://bugs.webkit.org/show_bug.cgi?id=265728
rdar://119079477

Reviewed by Alex Christensen.

All WebKit Secure Coding types will follow the identical pattern of:
1 - Get property list dictionary
2 - Encode it
3 - Decode it
4 - Verify the decoded dictionary contents match the type
5 - Recreate the object with the property list

Instead of writing all of that code over time after time, let's generate it.

Given an Objective-C type and a description of its expected dictionary format, the generator now:
1 - Generates a CoreIPC wrapper for that type
2 - Generates the ArgumentCoders for that CoreIPC wrapper (including code that validates the dictionary format)
3 - Generates a description of the dictionary in SerializedTypeInfo
4 - Generates a description of the CoreIPC wrapper in SerializedTypeInfo

All of the above was enough to move DDScannerResult over to this new format, and will greatly
accelerate how quickly we can add new types.

* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Scripts/generate-serializers.py:
(SerializedType.__init__):
(SerializedType.namespace_and_name):
(SerializedType.name_declaration_for_serialized_type_info):
(SerializedType.members_for_serialized_type_info):
(SerializedType.cpp_type_from_struct_or_class):
(SerializedType):
(SerializedType.cpp_struct_or_class_name):
(SerializedType.is_webkit_secure_coding_type):
(SerializedType.wrapper_for_webkit_secure_coding_type):
(generate_forward_declarations):
(generate_impl):
(generate_one_serialized_type_info):
(output_sorted_headers):
(generate_serialized_type_info):
(parse_serialized_types):
(generate_one_dictionary_member_validation):
(generate_webkit_secure_coding_impl):
(generate_webkit_secure_coding_impl.is):
(generate_webkit_secure_coding_header):
(main):
(SerializedType.namespace_unless_wtf_and_name): Deleted.
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp:
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h:
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.cpp: Added.
(WebKit::CoreIPCNSSomeFoundationType::CoreIPCNSSomeFoundationType):
(WebKit::CoreIPCNSSomeFoundationType::isValidDictionary):
(WebKit::CoreIPCNSSomeFoundationType::toID const):
(WebKit::CoreIPCDDScannerResult::CoreIPCDDScannerResult):
(WebKit::CoreIPCDDScannerResult::isValidDictionary):
(WebKit::CoreIPCDDScannerResult::toID const):
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.h: Added.
(WebKit::CoreIPCNSSomeFoundationType::CoreIPCNSSomeFoundationType):
(WebKit::CoreIPCDDScannerResult::CoreIPCDDScannerResult):
* Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp:
(WebKit::allSerializedTypes):
* Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in:
* Source/WebKit/Scripts/webkit/tests/WebKitPlatformGeneratedSerializers.cpp:
(IPC::ArgumentCoder<WebKit::CoreIPCNSSomeFoundationType>::encode):
(IPC::ArgumentCoder<WebKit::CoreIPCNSSomeFoundationType>::decode):
(IPC::ArgumentCoder<WebKit::CoreIPCDDScannerResult>::encode):
(IPC::ArgumentCoder<WebKit::CoreIPCDDScannerResult>::decode):
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.h: Removed.
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.mm: Removed.
* Source/WebKit/Shared/Cocoa/CoreIPCDDScannerResult.serialization.in:
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.h:
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.mm:
(WebKit::CoreIPCDictionary::CoreIPCDictionary):
(WebKit::CoreIPCDictionary::keyHasValueOfType const):
(WebKit::CoreIPCDictionary::keyIsMissingOrHasValueOfType const):
(WebKit::CoreIPCDictionary::collectionValuesAreOfType const):
(WebKit::CoreIPCDictionary::createNSDictionaryIfNeeded const):
(WebKit::CoreIPCDictionary::toID const):
* Source/WebKit/Shared/Cocoa/CoreIPCDictionary.serialization.in:
* Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.mm:
(WebKit::secureCodingValueFromID):
(WebKit::valueFromID):
* Source/WebKit/Shared/Cocoa/CoreIPCSecureCoding.h:
* Source/WebKit/Shared/Cocoa/CoreIPCSecureCoding.mm:
(WebKit::CoreIPCSecureCoding::conformsToWebKitSecureCoding):
(WebKit::CoreIPCSecureCoding::conformsToSecureCoding):
(WebKit::CoreIPCSecureCoding::CoreIPCSecureCoding):
* Source/WebKit/Shared/Cocoa/CoreIPCTypes.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/271555@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Generate-everything-needed-regarding-a-WebKit-Secure-Coding-type-and-move-DDScannerResult-over-to-the-generated-format branch from 7c3dcf8 to 9bd720b Compare December 5, 2023 16:16
@webkit-commit-queue
Copy link
Collaborator

Committed 271555@main (9bd720b): https://commits.webkit.org/271555@main

Reviewed commits have been landed. Closing PR #21216 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 9bd720b into WebKit:main Dec 5, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Projects
None yet
5 participants