Skip to content
Permalink
Browse files
Add binding generator support for async iterable
https://bugs.webkit.org/show_bug.cgi?id=231243
rdar://problem/84158224

Reviewed by Yusuke Suzuki.

Refactor JSDOMAsyncIterator to better aligned with JSDOMIterator.
We in particular remove the need to know the JS wrapper type.
This allows to use more of the existing iterable binding generator support for async iterable.
Move FileSystemDirectoryHandle async iterable from custom code to binding generator code.

* LayoutTests/imported/w3c/web-platform-tests/file-system-access/idlharness.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/file-system-access/idlharness.https.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt:
* Source/WebCore/Modules/filesystemaccess/FileSystemDirectoryHandle.idl:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/ExtendedDOMIsoSubspaces.h:
* Source/WebCore/bindings/js/JSDOMAsyncIterator.h:
(WebCore::JSDOMAsyncIteratorBase::onPromiseSettledBody):
(WebCore::JSDOMAsyncIteratorBase::onPromiseFulFilledBody):
(WebCore::JSDOMAsyncIteratorBase::onPromiseRejectedBody):
(WebCore::IteratorTraits>::destroy):
(WebCore::IteratorTraits>::next):
(WebCore::IteratorTraits>::runNextSteps):
(WebCore::IteratorTraits>::getNextIterationResult):
(WebCore::IteratorTraits>::settle):
(WebCore::IteratorTraits>::createOnSettledFunction):
(WebCore::IteratorTraits>::fulfill):
(WebCore::IteratorTraits>::createOnFulfilledFunction):
(WebCore::IteratorTraits>::reject):
(WebCore::IteratorTraits>::createOnRejectedFunction):
(WebCore::IteratorTraits>::finishCreation):
(WebCore::JSIterator>::destroy): Deleted.
(WebCore::JSIterator>::next): Deleted.
(WebCore::JSIterator>::runNextSteps): Deleted.
(WebCore::JSIterator>::getNextIterationResult): Deleted.
(WebCore::JSIterator>::settle): Deleted.
(WebCore::JSIterator>::fulfill): Deleted.
(WebCore::JSIterator>::reject): Deleted.
(WebCore::JSIterator>::finishCreation): Deleted.
* Source/WebCore/bindings/js/JSFileSystemDirectoryHandleCustom.cpp: Removed.
* Source/WebCore/bindings/js/JSFileSystemDirectoryHandleIterator.cpp: Removed.
* Source/WebCore/bindings/js/JSFileSystemDirectoryHandleIterator.h: Removed.
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(GenerateInterface):
(AddAsyncIterableOperationIfNeeded):
(AddIterableOperationIfNeeded):
(addGenericIterableOperations):
(GetFunctionName):
(GeneratePropertiesHashTable):
(InterfaceNeedsAsyncIterator):
(GenerateImplementation):
(IsValueIterableInterface):
(IsKeyValueIterableInterface):
(GenerateAsyncIterableDefinition):
(GenerateIterableDefinition):
(GenerateGenericIterableDefinition):
(GetRuntimeEnabledStaticProperties):
* Source/WebCore/bindings/scripts/IDLParser.pm:
(parseAsyncIterable):
* Source/WebCore/bindings/scripts/preprocess-idls.pl:
(containsIterableInterfaceFromIDL):
* Source/WebCore/bindings/scripts/test/BindingTestGlobalConstructors.idl:
* Source/WebCore/bindings/scripts/test/JS/JSTestAsyncIterable.cpp: Added.
(WebCore::JSTestAsyncIterableDOMConstructor::prototypeForStructure):
(WebCore::JSTestAsyncIterableDOMConstructor::initializeProperties):
(WebCore::JSTestAsyncIterablePrototype::finishCreation):
(WebCore::JSTestAsyncIterable::JSTestAsyncIterable):
(WebCore::JSTestAsyncIterable::finishCreation):
(WebCore::JSTestAsyncIterable::createPrototype):
(WebCore::JSTestAsyncIterable::prototype):
(WebCore::JSTestAsyncIterable::getConstructor):
(WebCore::JSTestAsyncIterable::destroy):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
(WebCore::jsTestAsyncIterablePrototypeFunction_entriesCaller):
(WebCore::JSC_DEFINE_HOST_FUNCTION):
(WebCore::jsTestAsyncIterablePrototypeFunction_keysCaller):
(WebCore::jsTestAsyncIterablePrototypeFunction_valuesCaller):
(WebCore::TestAsyncIterableIteratorTraits>::onPromiseSettled):
(WebCore::TestAsyncIterableIteratorTraits>::onPromiseFulFilled):
(WebCore::TestAsyncIterableIteratorTraits>::onPromiseRejected):
(WebCore::JSTestAsyncIterable::subspaceForImpl):
(WebCore::JSTestAsyncIterable::analyzeHeap):
(WebCore::JSTestAsyncIterableOwner::isReachableFromOpaqueRoots):
(WebCore::JSTestAsyncIterableOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSTestAsyncIterable::toWrapped):
* Source/WebCore/bindings/scripts/test/JS/JSTestAsyncIterable.h: Added.
(WebCore::JSTestAsyncIterable::create):
(WebCore::JSTestAsyncIterable::createStructure):
(WebCore::JSTestAsyncIterable::subspaceFor):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* Source/WebCore/bindings/scripts/test/JS/JSTestAsyncKeyValueIterable.cpp: Added.
(WebCore::JSTestAsyncKeyValueIterableDOMConstructor::prototypeForStructure):
(WebCore::JSTestAsyncKeyValueIterableDOMConstructor::initializeProperties):
(WebCore::JSTestAsyncKeyValueIterablePrototype::finishCreation):
(WebCore::JSTestAsyncKeyValueIterable::JSTestAsyncKeyValueIterable):
(WebCore::JSTestAsyncKeyValueIterable::finishCreation):
(WebCore::JSTestAsyncKeyValueIterable::createPrototype):
(WebCore::JSTestAsyncKeyValueIterable::prototype):
(WebCore::JSTestAsyncKeyValueIterable::getConstructor):
(WebCore::JSTestAsyncKeyValueIterable::destroy):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
(WebCore::jsTestAsyncKeyValueIterablePrototypeFunction_entriesCaller):
(WebCore::JSC_DEFINE_HOST_FUNCTION):
(WebCore::jsTestAsyncKeyValueIterablePrototypeFunction_keysCaller):
(WebCore::jsTestAsyncKeyValueIterablePrototypeFunction_valuesCaller):
(WebCore::TestAsyncKeyValueIterableIteratorTraits>::onPromiseSettled):
(WebCore::TestAsyncKeyValueIterableIteratorTraits>::onPromiseFulFilled):
(WebCore::TestAsyncKeyValueIterableIteratorTraits>::onPromiseRejected):
(WebCore::JSTestAsyncKeyValueIterable::subspaceForImpl):
(WebCore::JSTestAsyncKeyValueIterable::analyzeHeap):
(WebCore::JSTestAsyncKeyValueIterableOwner::isReachableFromOpaqueRoots):
(WebCore::JSTestAsyncKeyValueIterableOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSTestAsyncKeyValueIterable::toWrapped):
* Source/WebCore/bindings/scripts/test/JS/JSTestAsyncKeyValueIterable.h: Added.
(WebCore::JSTestAsyncKeyValueIterable::create):
(WebCore::JSTestAsyncKeyValueIterable::createStructure):
(WebCore::JSTestAsyncKeyValueIterable::subspaceFor):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::jsTestGlobalObject_TestAsyncIterableConstructorGetter):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
(WebCore::jsTestGlobalObject_TestAsyncKeyValueIterableConstructorGetter):
* Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::jsTestInterfacePrototypeFunction_entriesCaller):
* Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp:
(WebCore::jsTestIterablePrototypeFunction_entriesCaller):
* Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::jsTestNodePrototypeFunction_entriesCaller):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestAsyncIterable.idl: Copied from Source/WebCore/bindings/js/ExtendedDOMIsoSubspaces.h.
* Source/WebCore/bindings/scripts/test/TestAsyncKeyValueIterable.idl: Copied from Source/WebCore/bindings/js/ExtendedDOMIsoSubspaces.h.

Canonical link: https://commits.webkit.org/257021@main
  • Loading branch information
youennf committed Nov 25, 2022
1 parent ee56f48 commit 10ce73287c2f5790bf83081440da55786d54ab6f
Show file tree
Hide file tree
Showing 27 changed files with 1,273 additions and 416 deletions.
@@ -39,7 +39,7 @@ PASS FileSystemDirectoryHandle interface object name
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object's "constructor" property
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object's @@unscopables property
FAIL FileSystemDirectoryHandle interface: async iterable<USVString, FileSystemHandle> undefined is not an object (evaluating 'iteratorDesc.enumerable')
PASS FileSystemDirectoryHandle interface: async iterable<USVString, FileSystemHandle>
PASS FileSystemDirectoryHandle interface: operation getFileHandle(USVString, optional FileSystemGetFileOptions)
PASS FileSystemDirectoryHandle interface: operation getDirectoryHandle(USVString, optional FileSystemGetDirectoryOptions)
PASS FileSystemDirectoryHandle interface: operation removeEntry(USVString, optional FileSystemRemoveOptions)
@@ -39,7 +39,7 @@ PASS FileSystemDirectoryHandle interface object name
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object's "constructor" property
PASS FileSystemDirectoryHandle interface: existence and properties of interface prototype object's @@unscopables property
FAIL FileSystemDirectoryHandle interface: async iterable<USVString, FileSystemHandle> undefined is not an object (evaluating 'iteratorDesc.enumerable')
PASS FileSystemDirectoryHandle interface: async iterable<USVString, FileSystemHandle>
PASS FileSystemDirectoryHandle interface: operation getFileHandle(USVString, optional FileSystemGetFileOptions)
PASS FileSystemDirectoryHandle interface: operation getDirectoryHandle(USVString, optional FileSystemGetDirectoryOptions)
PASS FileSystemDirectoryHandle interface: operation removeEntry(USVString, optional FileSystemRemoveOptions)
@@ -1,6 +1,6 @@

PASS getDirectoryHandle(create=false) rejects for non-existing directories
FAIL getDirectoryHandle(create=true) creates an empty directory promise_test: Unhandled rejection with value: object "TypeError: undefined is not a function (near '...entry of handle...')"
PASS getDirectoryHandle(create=true) creates an empty directory
PASS getDirectoryHandle(create=false) returns existing directories
PASS getDirectoryHandle(create=true) returns existing directories without erasing
FAIL getDirectoryHandle() when a file already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
@@ -1,6 +1,6 @@

PASS getDirectoryHandle(create=false) rejects for non-existing directories
FAIL getDirectoryHandle(create=true) creates an empty directory promise_test: Unhandled rejection with value: object "TypeError: undefined is not a function (near '...entry of handle...')"
PASS getDirectoryHandle(create=true) creates an empty directory
PASS getDirectoryHandle(create=false) returns existing directories
PASS getDirectoryHandle(create=true) returns existing directories without erasing
FAIL getDirectoryHandle() when a file already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
@@ -40,13 +40,10 @@ dictionary FileSystemRemoveOptions {
Exposed=(Window,Worker),
SecureContext
] interface FileSystemDirectoryHandle : FileSystemHandle {
async iterable<USVString, FileSystemHandle>;

Promise<FileSystemFileHandle> getFileHandle(USVString name, optional FileSystemGetFileOptions options);
Promise<FileSystemDirectoryHandle> getDirectoryHandle(USVString name, optional FileSystemGetDirectoryOptions options);
Promise<undefined> removeEntry(USVString name, optional FileSystemRemoveOptions options);
Promise<sequence<USVString>?> resolve(FileSystemHandle possibleDescendant);

// FIXME: This interface should be AsyncIterable, which is not supported by bindings code generator yet.
[Custom] any entries();
[Custom] any keys();
[Custom] any values();
};
@@ -570,8 +570,6 @@ bindings/js/JSExecState.cpp
bindings/js/JSExtendableMessageEventCustom.cpp
bindings/js/JSFetchEventCustom.cpp
bindings/js/JSFileSystemEntryCustom.cpp
bindings/js/JSFileSystemDirectoryHandleCustom.cpp
bindings/js/JSFileSystemDirectoryHandleIterator.cpp
bindings/js/JSFileSystemHandleCustom.cpp
bindings/js/JSHTMLAllCollectionCustom.cpp
bindings/js/JSHTMLCanvasElementCustom.cpp
@@ -3036,7 +3036,6 @@
932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */; };
932F1D3C270D26A0000C2813 /* JSDOMAsyncIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 932F1D39270D269F000C2813 /* JSDOMAsyncIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F1D47270EBF4C000C2813 /* JSFileSystemDirectoryHandleIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 932F1D45270EBF4B000C2813 /* JSFileSystemDirectoryHandleIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309D88099E64910056E581 /* AppendNodeCommand.h */; };
93309DD9099E64920056E581 /* ApplyStyleCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309D8A099E64910056E581 /* ApplyStyleCommand.h */; };
93309DDB099E64920056E581 /* BreakBlockquoteCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309D8C099E64910056E581 /* BreakBlockquoteCommand.h */; };
@@ -13190,9 +13189,6 @@
932D26F4279B8526004DCD8D /* FourCC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FourCC.cpp; sourceTree = "<group>"; };
932E16080AF578340025F408 /* FrameLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameLoader.cpp; sourceTree = "<group>"; };
932F1D39270D269F000C2813 /* JSDOMAsyncIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMAsyncIterator.h; sourceTree = "<group>"; };
932F1D43270EBF38000C2813 /* JSFileSystemDirectoryHandleCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileSystemDirectoryHandleCustom.cpp; sourceTree = "<group>"; };
932F1D45270EBF4B000C2813 /* JSFileSystemDirectoryHandleIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileSystemDirectoryHandleIterator.h; sourceTree = "<group>"; };
932F1D46270EBF4B000C2813 /* JSFileSystemDirectoryHandleIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileSystemDirectoryHandleIterator.cpp; sourceTree = "<group>"; };
93309D87099E64910056E581 /* AppendNodeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppendNodeCommand.cpp; sourceTree = "<group>"; };
93309D88099E64910056E581 /* AppendNodeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppendNodeCommand.h; sourceTree = "<group>"; };
93309D89099E64910056E581 /* ApplyStyleCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyStyleCommand.cpp; sourceTree = "<group>"; };
@@ -25888,7 +25884,6 @@
BC60901E0E91B8EC000C68B5 /* JSEventTargetCustom.cpp */,
46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */,
932F1D43270EBF38000C2813 /* JSFileSystemDirectoryHandleCustom.cpp */,
835B680E1F548BDE0071F7F6 /* JSFileSystemEntryCustom.cpp */,
931A1BDD26F7ED090081A7E5 /* JSFileSystemHandleCustom.cpp */,
84BBE5482597E7F100AA8F28 /* JSHTMLAllCollectionCustom.cpp */,
@@ -30377,8 +30372,6 @@
8F934D841189F1EE00508D5D /* JSExecState.cpp */,
8F934D831189F1EE00508D5D /* JSExecState.h */,
B56576E417DA599F00A56BDC /* JSExecStateInstrumentation.h */,
932F1D46270EBF4B000C2813 /* JSFileSystemDirectoryHandleIterator.cpp */,
932F1D45270EBF4B000C2813 /* JSFileSystemDirectoryHandleIterator.h */,
93849C1624BE12E500448D5A /* JSIDBSerializationGlobalObject.cpp */,
93849C2124BEDD8800448D5A /* JSIDBSerializationGlobalObject.h */,
E3C9AEC92113147400419B92 /* JSMicrotaskCallback.h */,
@@ -36720,7 +36713,6 @@
2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */,
898785F5122E1EAC003AABDA /* JSFileReaderSync.h in Headers */,
833B9E321F508D8500E0E428 /* JSFileSystemDirectoryEntry.h in Headers */,
932F1D47270EBF4C000C2813 /* JSFileSystemDirectoryHandleIterator.h in Headers */,
836589DE1F54A76900DC31F4 /* JSFileSystemDirectoryReader.h in Headers */,
836589E01F54A76E00DC31F4 /* JSFileSystemEntriesCallback.h in Headers */,
833B9E341F508D8500E0E428 /* JSFileSystemEntry.h in Headers */,
@@ -32,7 +32,6 @@ namespace WebCore {
class ExtendedDOMIsoSubspaces : public DOMIsoSubspaces {
public:
ExtendedDOMIsoSubspaces() = default;
std::unique_ptr<JSC::IsoSubspace> m_subspaceForFileSystemDirectoryHandleIterator;
};

} // namespace WebCore

0 comments on commit 10ce732

Please sign in to comment.