Add support for WebIDL setlike
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Dec 2019 12:06:54 +0000 (12:06 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Dec 2019 12:06:54 +0000 (12:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159140

Reviewed by Chris Dumez.

Source/WebCore:

Add preliminary support for https://heycam.github.io/webidl/#idl-setlike in the binding generator and IDL parser.
A setlike JS wrapper owns a JSSet as a private slot that mirrors values owned by the wrapped object.
forEach support is still missing.

A DOM class implementing setlike must currently implement the following methods:
- initializeSetLike
- addFromSetLike
- removeFromSetLike

Added an internals class implementing setlike to test it.
Also covered by binding tests.

Test: js/dom/setlike.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMSetLike.cpp: Added.
(WebCore::getBackingSet):
(WebCore::clearBackingSet):
(WebCore::addToBackingSet):
(WebCore::forwardAttributeGetterToBackingSet):
(WebCore::forwardFunctionCallToBackingSet):
* bindings/js/JSDOMSetLike.h: Added.
(WebCore::DOMSetAdapter::DOMSetAdapter):
(WebCore::DOMSetAdapter::add):
(WebCore::DOMSetAdapter::clear):
(WebCore::DOMSetAdapter::globalObject const):
(WebCore::getAndInitializeBackingSet):
(WebCore::forwardSizeToSetLike):
(WebCore::forwardEntriesToSetLike):
(WebCore::forwardKeysToSetLike):
(WebCore::forwardValuesToSetLike):
(WebCore::forwardHasToSetLike):
(WebCore::forwardClearToSetLike):
(WebCore::forwardAddToSetLike):
(WebCore::forwardDeleteToSetLike):
* bindings/js/WebCoreBuiltinNames.h:
* bindings/scripts/CodeGeneratorJS.pm:
(GetFullyQualifiedImplementationCallName):
(AddAdditionalArgumentsForImplementationCall):
(IsAcceleratedDOMAttribute):
(PrototypeOperationCount):
(GeneratePropertiesHashTable):
(InterfaceNeedsIterator):
(GenerateImplementation):
(GenerateAttributeGetterBodyDefinition):
(GenerateOperationBodyDefinition):
(GetRuntimeEnabledStaticProperties):
* bindings/scripts/IDLParser.pm:
(cloneOperation):
(applyTypedefs):
(parseOperationOrReadWriteAttributeOrMaplike):
(parseReadOnlyMember):
(parseOperation):
(parseSetLikeRest):
(parseSetLikeProperties):
(applyMemberList):
* bindings/scripts/test/JS/JSReadOnlySetLike.cpp: Added.
(WebCore::JSReadOnlySetLikePrototype::create):
(WebCore::JSReadOnlySetLikePrototype::createStructure):
(WebCore::JSReadOnlySetLikePrototype::JSReadOnlySetLikePrototype):
(WebCore::JSReadOnlySetLikeConstructor::prototypeForStructure):
(WebCore::JSReadOnlySetLikeConstructor::initializeProperties):
(WebCore::JSReadOnlySetLikePrototype::finishCreation):
(WebCore::JSReadOnlySetLike::JSReadOnlySetLike):
(WebCore::JSReadOnlySetLike::finishCreation):
(WebCore::JSReadOnlySetLike::createPrototype):
(WebCore::JSReadOnlySetLike::prototype):
(WebCore::JSReadOnlySetLike::getConstructor):
(WebCore::JSReadOnlySetLike::destroy):
(WebCore::IDLAttribute<JSReadOnlySetLike>::cast):
(WebCore::IDLOperation<JSReadOnlySetLike>::cast):
(WebCore::jsReadOnlySetLikeConstructor):
(WebCore::setJSReadOnlySetLikeConstructor):
(WebCore::jsReadOnlySetLikeSizeGetter):
(WebCore::jsReadOnlySetLikeSize):
(WebCore::jsReadOnlySetLikePrototypeFunctionHasBody):
(WebCore::jsReadOnlySetLikePrototypeFunctionHas):
(WebCore::jsReadOnlySetLikePrototypeFunctionEntriesBody):
(WebCore::jsReadOnlySetLikePrototypeFunctionEntries):
(WebCore::jsReadOnlySetLikePrototypeFunctionKeysBody):
(WebCore::jsReadOnlySetLikePrototypeFunctionKeys):
(WebCore::jsReadOnlySetLikePrototypeFunctionValuesBody):
(WebCore::jsReadOnlySetLikePrototypeFunctionValues):
(WebCore::JSReadOnlySetLike::analyzeHeap):
(WebCore::JSReadOnlySetLikeOwner::isReachableFromOpaqueRoots):
(WebCore::JSReadOnlySetLikeOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSReadOnlySetLike::toWrapped):
* bindings/scripts/test/JS/JSReadOnlySetLike.h: Added.
(WebCore::JSReadOnlySetLike::create):
(WebCore::JSReadOnlySetLike::createStructure):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* bindings/scripts/test/JS/JSSetLike.cpp: Added.
(WebCore::JSSetLikePrototype::create):
(WebCore::JSSetLikePrototype::createStructure):
(WebCore::JSSetLikePrototype::JSSetLikePrototype):
(WebCore::JSSetLikeConstructor::prototypeForStructure):
(WebCore::JSSetLikeConstructor::initializeProperties):
(WebCore::JSSetLikePrototype::finishCreation):
(WebCore::JSSetLike::JSSetLike):
(WebCore::JSSetLike::finishCreation):
(WebCore::JSSetLike::createPrototype):
(WebCore::JSSetLike::prototype):
(WebCore::JSSetLike::getConstructor):
(WebCore::JSSetLike::destroy):
(WebCore::IDLAttribute<JSSetLike>::cast):
(WebCore::IDLOperation<JSSetLike>::cast):
(WebCore::jsSetLikeConstructor):
(WebCore::setJSSetLikeConstructor):
(WebCore::jsSetLikeSizeGetter):
(WebCore::jsSetLikeSize):
(WebCore::jsSetLikePrototypeFunctionHasBody):
(WebCore::jsSetLikePrototypeFunctionHas):
(WebCore::jsSetLikePrototypeFunctionEntriesBody):
(WebCore::jsSetLikePrototypeFunctionEntries):
(WebCore::jsSetLikePrototypeFunctionKeysBody):
(WebCore::jsSetLikePrototypeFunctionKeys):
(WebCore::jsSetLikePrototypeFunctionValuesBody):
(WebCore::jsSetLikePrototypeFunctionValues):
(WebCore::jsSetLikePrototypeFunctionAddBody):
(WebCore::jsSetLikePrototypeFunctionAdd):
(WebCore::jsSetLikePrototypeFunctionClearBody):
(WebCore::jsSetLikePrototypeFunctionClear):
(WebCore::jsSetLikePrototypeFunctionDeleteBody):
(WebCore::jsSetLikePrototypeFunctionDelete):
(WebCore::JSSetLike::analyzeHeap):
(WebCore::JSSetLikeOwner::isReachableFromOpaqueRoots):
(WebCore::JSSetLikeOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSSetLike::toWrapped):
* bindings/scripts/test/JS/JSSetLike.h: Added.
(WebCore::JSSetLike::create):
(WebCore::JSSetLike::createStructure):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::jsTestGlobalObjectTestReadOnlySetLikeConstructorGetter):
(WebCore::jsTestGlobalObjectTestReadOnlySetLikeConstructor):
(WebCore::setJSTestGlobalObjectTestReadOnlySetLikeConstructorSetter):
(WebCore::setJSTestGlobalObjectTestReadOnlySetLikeConstructor):
(WebCore::jsTestGlobalObjectTestSetLikeConstructorGetter):
(WebCore::jsTestGlobalObjectTestSetLikeConstructor):
(WebCore::setJSTestGlobalObjectTestSetLikeConstructorSetter):
(WebCore::setJSTestGlobalObjectTestSetLikeConstructor):
* bindings/scripts/test/TestReadOnlySetLike.idl: Added.
* bindings/scripts/test/TestSetLike.idl: Added.
* testing/Internals.cpp:
(WebCore::Internals::createInternalsSetLike):
* testing/Internals.h:
* testing/Internals.idl:
* testing/InternalsSetLike.cpp: Added.
(WebCore::InternalsSetLike::InternalsSetLike):
(WebCore::InternalsSetLike::initializeSetLike):
* testing/InternalsSetLike.h: Added.
(WebCore::InternalsSetLike::create):
(WebCore::InternalsSetLike::clearFromSetLike):
(WebCore::InternalsSetLike::removeFromSetLike):
(WebCore::InternalsSetLike::items const):
(WebCore::InternalsSetLike::addToSetLike):
* testing/InternalsSetLike.idl: Added.

LayoutTests:

* js/dom/setlike-expected.txt: Added.
* js/dom/setlike.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253100 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/setlike-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/setlike.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDOMSetLike.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMSetLike.h [new file with mode: 0644]
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSSetLike.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSSetLike.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
Source/WebCore/bindings/scripts/test/TestReadOnlySetLike.idl [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/TestSetLike.idl [new file with mode: 0644]
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/InternalsSetLike.cpp [new file with mode: 0644]
Source/WebCore/testing/InternalsSetLike.h [new file with mode: 0644]
Source/WebCore/testing/InternalsSetLike.idl [new file with mode: 0644]

index 50d2ac1..1ad6e5c 100644 (file)
@@ -1,3 +1,13 @@
+2019-12-04  Youenn Fablet  <youenn@apple.com>
+
+        Add support for WebIDL setlike
+        https://bugs.webkit.org/show_bug.cgi?id=159140
+
+        Reviewed by Chris Dumez.
+
+        * js/dom/setlike-expected.txt: Added.
+        * js/dom/setlike.html: Added.
+
 2019-12-04  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: allow inspector to pause provisional page load and restore its state
diff --git a/LayoutTests/js/dom/setlike-expected.txt b/LayoutTests/js/dom/setlike-expected.txt
new file mode 100644 (file)
index 0000000..54a4095
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Basic add/remove/clear functionality 
+
diff --git a/LayoutTests/js/dom/setlike.html b/LayoutTests/js/dom/setlike.html
new file mode 100644 (file)
index 0000000..b2958bb
--- /dev/null
@@ -0,0 +1,50 @@
+<!doctype html>
+<html>
+<head>
+    <script src="../../resources/testharness.js"></script>
+    <script src="../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<script type="application/javascript">
+test(() => {
+    assert_true(!!window.internals);
+    const setlike = internals.createInternalsSetLike();
+    assert_array_equals(setlike.items(), ["init"]);
+    assert_true(setlike.has("init"));
+
+    setlike.add("test");
+    assert_array_equals(setlike.items(), ["init", "test"]);
+    setlike.add("test");
+    assert_array_equals(setlike.items(), ["init", "test"]);
+    setlike.add("test2");
+    assert_array_equals(setlike.items(), ["init", "test", "test2"]);
+
+    setlike.delete("init");
+    assert_array_equals(setlike.items(), ["test", "test2"]);
+
+    assert_equals(setlike.size, 2, "size");
+
+    let entriesTest = "";
+    for (let entry of setlike.entries()) {
+        entriesTest += entry;
+    }
+    assert_equals(entriesTest, "test,testtest2,test2", "entries test");
+
+    let valuesTest = "";
+    for (let entry of setlike.values()) {
+        valuesTest += entry;
+    }
+    assert_equals(valuesTest, "testtest2", "values test");
+
+    let keysTest = "";
+    for (let entry of setlike.keys()) {
+        keysTest += entry;
+    }
+    assert_equals(keysTest, "testtest2", "keys test");
+
+    setlike.clear();
+    assert_array_equals(setlike.items(), []);
+}, "Basic add/remove/clear functionality");
+</script>
+</body>
+</html>
index 40f3dd9..4bfb237 100644 (file)
@@ -1605,6 +1605,7 @@ set(WebCoreTestSupport_IDL_FILES
     testing/GCObservation.idl
     testing/InternalSettings.idl
     testing/Internals.idl
+    testing/InternalsSetLike.idl
     testing/MallocStatistics.idl
     testing/MemoryInfo.idl
     testing/MockCDMFactory.idl
@@ -1625,6 +1626,7 @@ list(APPEND WebCoreTestSupport_SOURCES
     testing/GCObservation.cpp
     testing/InternalSettings.cpp
     testing/Internals.cpp
+    testing/InternalsSetLike.cpp
     testing/MockCDMFactory.cpp
     testing/MockGamepad.cpp
     testing/MockGamepadProvider.cpp
index c9954f4..2f851fc 100644 (file)
@@ -1,3 +1,183 @@
+2019-12-04  Youenn Fablet  <youenn@apple.com>
+
+        Add support for WebIDL setlike
+        https://bugs.webkit.org/show_bug.cgi?id=159140
+
+        Reviewed by Chris Dumez.
+
+        Add preliminary support for https://heycam.github.io/webidl/#idl-setlike in the binding generator and IDL parser.
+        A setlike JS wrapper owns a JSSet as a private slot that mirrors values owned by the wrapped object.
+        forEach support is still missing.
+
+        A DOM class implementing setlike must currently implement the following methods:
+        - initializeSetLike
+        - addFromSetLike
+        - removeFromSetLike
+
+        Added an internals class implementing setlike to test it.
+        Also covered by binding tests.
+
+        Test: js/dom/setlike.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMSetLike.cpp: Added.
+        (WebCore::getBackingSet):
+        (WebCore::clearBackingSet):
+        (WebCore::addToBackingSet):
+        (WebCore::forwardAttributeGetterToBackingSet):
+        (WebCore::forwardFunctionCallToBackingSet):
+        * bindings/js/JSDOMSetLike.h: Added.
+        (WebCore::DOMSetAdapter::DOMSetAdapter):
+        (WebCore::DOMSetAdapter::add):
+        (WebCore::DOMSetAdapter::clear):
+        (WebCore::DOMSetAdapter::globalObject const):
+        (WebCore::getAndInitializeBackingSet):
+        (WebCore::forwardSizeToSetLike):
+        (WebCore::forwardEntriesToSetLike):
+        (WebCore::forwardKeysToSetLike):
+        (WebCore::forwardValuesToSetLike):
+        (WebCore::forwardHasToSetLike):
+        (WebCore::forwardClearToSetLike):
+        (WebCore::forwardAddToSetLike):
+        (WebCore::forwardDeleteToSetLike):
+        * bindings/js/WebCoreBuiltinNames.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetFullyQualifiedImplementationCallName):
+        (AddAdditionalArgumentsForImplementationCall):
+        (IsAcceleratedDOMAttribute):
+        (PrototypeOperationCount):
+        (GeneratePropertiesHashTable):
+        (InterfaceNeedsIterator):
+        (GenerateImplementation):
+        (GenerateAttributeGetterBodyDefinition):
+        (GenerateOperationBodyDefinition):
+        (GetRuntimeEnabledStaticProperties):
+        * bindings/scripts/IDLParser.pm:
+        (cloneOperation):
+        (applyTypedefs):
+        (parseOperationOrReadWriteAttributeOrMaplike):
+        (parseReadOnlyMember):
+        (parseOperation):
+        (parseSetLikeRest):
+        (parseSetLikeProperties):
+        (applyMemberList):
+        * bindings/scripts/test/JS/JSReadOnlySetLike.cpp: Added.
+        (WebCore::JSReadOnlySetLikePrototype::create):
+        (WebCore::JSReadOnlySetLikePrototype::createStructure):
+        (WebCore::JSReadOnlySetLikePrototype::JSReadOnlySetLikePrototype):
+        (WebCore::JSReadOnlySetLikeConstructor::prototypeForStructure):
+        (WebCore::JSReadOnlySetLikeConstructor::initializeProperties):
+        (WebCore::JSReadOnlySetLikePrototype::finishCreation):
+        (WebCore::JSReadOnlySetLike::JSReadOnlySetLike):
+        (WebCore::JSReadOnlySetLike::finishCreation):
+        (WebCore::JSReadOnlySetLike::createPrototype):
+        (WebCore::JSReadOnlySetLike::prototype):
+        (WebCore::JSReadOnlySetLike::getConstructor):
+        (WebCore::JSReadOnlySetLike::destroy):
+        (WebCore::IDLAttribute<JSReadOnlySetLike>::cast):
+        (WebCore::IDLOperation<JSReadOnlySetLike>::cast):
+        (WebCore::jsReadOnlySetLikeConstructor):
+        (WebCore::setJSReadOnlySetLikeConstructor):
+        (WebCore::jsReadOnlySetLikeSizeGetter):
+        (WebCore::jsReadOnlySetLikeSize):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionHasBody):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionHas):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionEntriesBody):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionEntries):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionKeysBody):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionKeys):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionValuesBody):
+        (WebCore::jsReadOnlySetLikePrototypeFunctionValues):
+        (WebCore::JSReadOnlySetLike::analyzeHeap):
+        (WebCore::JSReadOnlySetLikeOwner::isReachableFromOpaqueRoots):
+        (WebCore::JSReadOnlySetLikeOwner::finalize):
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        (WebCore::JSReadOnlySetLike::toWrapped):
+        * bindings/scripts/test/JS/JSReadOnlySetLike.h: Added.
+        (WebCore::JSReadOnlySetLike::create):
+        (WebCore::JSReadOnlySetLike::createStructure):
+        (WebCore::wrapperOwner):
+        (WebCore::wrapperKey):
+        (WebCore::toJS):
+        (WebCore::toJSNewlyCreated):
+        * bindings/scripts/test/JS/JSSetLike.cpp: Added.
+        (WebCore::JSSetLikePrototype::create):
+        (WebCore::JSSetLikePrototype::createStructure):
+        (WebCore::JSSetLikePrototype::JSSetLikePrototype):
+        (WebCore::JSSetLikeConstructor::prototypeForStructure):
+        (WebCore::JSSetLikeConstructor::initializeProperties):
+        (WebCore::JSSetLikePrototype::finishCreation):
+        (WebCore::JSSetLike::JSSetLike):
+        (WebCore::JSSetLike::finishCreation):
+        (WebCore::JSSetLike::createPrototype):
+        (WebCore::JSSetLike::prototype):
+        (WebCore::JSSetLike::getConstructor):
+        (WebCore::JSSetLike::destroy):
+        (WebCore::IDLAttribute<JSSetLike>::cast):
+        (WebCore::IDLOperation<JSSetLike>::cast):
+        (WebCore::jsSetLikeConstructor):
+        (WebCore::setJSSetLikeConstructor):
+        (WebCore::jsSetLikeSizeGetter):
+        (WebCore::jsSetLikeSize):
+        (WebCore::jsSetLikePrototypeFunctionHasBody):
+        (WebCore::jsSetLikePrototypeFunctionHas):
+        (WebCore::jsSetLikePrototypeFunctionEntriesBody):
+        (WebCore::jsSetLikePrototypeFunctionEntries):
+        (WebCore::jsSetLikePrototypeFunctionKeysBody):
+        (WebCore::jsSetLikePrototypeFunctionKeys):
+        (WebCore::jsSetLikePrototypeFunctionValuesBody):
+        (WebCore::jsSetLikePrototypeFunctionValues):
+        (WebCore::jsSetLikePrototypeFunctionAddBody):
+        (WebCore::jsSetLikePrototypeFunctionAdd):
+        (WebCore::jsSetLikePrototypeFunctionClearBody):
+        (WebCore::jsSetLikePrototypeFunctionClear):
+        (WebCore::jsSetLikePrototypeFunctionDeleteBody):
+        (WebCore::jsSetLikePrototypeFunctionDelete):
+        (WebCore::JSSetLike::analyzeHeap):
+        (WebCore::JSSetLikeOwner::isReachableFromOpaqueRoots):
+        (WebCore::JSSetLikeOwner::finalize):
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        (WebCore::JSSetLike::toWrapped):
+        * bindings/scripts/test/JS/JSSetLike.h: Added.
+        (WebCore::JSSetLike::create):
+        (WebCore::JSSetLike::createStructure):
+        (WebCore::wrapperOwner):
+        (WebCore::wrapperKey):
+        (WebCore::toJS):
+        (WebCore::toJSNewlyCreated):
+        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+        (WebCore::jsTestGlobalObjectTestReadOnlySetLikeConstructorGetter):
+        (WebCore::jsTestGlobalObjectTestReadOnlySetLikeConstructor):
+        (WebCore::setJSTestGlobalObjectTestReadOnlySetLikeConstructorSetter):
+        (WebCore::setJSTestGlobalObjectTestReadOnlySetLikeConstructor):
+        (WebCore::jsTestGlobalObjectTestSetLikeConstructorGetter):
+        (WebCore::jsTestGlobalObjectTestSetLikeConstructor):
+        (WebCore::setJSTestGlobalObjectTestSetLikeConstructorSetter):
+        (WebCore::setJSTestGlobalObjectTestSetLikeConstructor):
+        * bindings/scripts/test/TestReadOnlySetLike.idl: Added.
+        * bindings/scripts/test/TestSetLike.idl: Added.
+        * testing/Internals.cpp:
+        (WebCore::Internals::createInternalsSetLike):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * testing/InternalsSetLike.cpp: Added.
+        (WebCore::InternalsSetLike::InternalsSetLike):
+        (WebCore::InternalsSetLike::initializeSetLike):
+        * testing/InternalsSetLike.h: Added.
+        (WebCore::InternalsSetLike::create):
+        (WebCore::InternalsSetLike::clearFromSetLike):
+        (WebCore::InternalsSetLike::removeFromSetLike):
+        (WebCore::InternalsSetLike::items const):
+        (WebCore::InternalsSetLike::addToSetLike):
+        * testing/InternalsSetLike.idl: Added.
+
 2019-12-04  Zan Dobersek  <zdobersek@igalia.com>  and  Chris Lord  <clord@igalia.com>
 
         Implement OffscreenCanvas.transferToImageBitmap
index fec3c57..37e545d 100644 (file)
@@ -1092,6 +1092,7 @@ $(PROJECT_DIR)/svg/xlinkattrs.in
 $(PROJECT_DIR)/testing/GCObservation.idl
 $(PROJECT_DIR)/testing/InternalSettings.idl
 $(PROJECT_DIR)/testing/Internals.idl
+$(PROJECT_DIR)/testing/InternalsSetLike.idl
 $(PROJECT_DIR)/testing/MallocStatistics.idl
 $(PROJECT_DIR)/testing/MemoryInfo.idl
 $(PROJECT_DIR)/testing/MockCDMFactory.idl
index 5cdcb13..e14cd1f 100644 (file)
@@ -939,6 +939,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalSettingsGenerated.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalSettingsGenerated.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternals.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternals.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalsSetLike.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalsSetLike.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIntersectionObserver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIntersectionObserver.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIntersectionObserverCallback.cpp
index 883ca39..82d8dc3 100644 (file)
@@ -1082,6 +1082,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/testing/GCObservation.idl \
     $(WebCore)/testing/InternalSettings.idl \
     $(WebCore)/testing/Internals.idl \
+    $(WebCore)/testing/InternalsSetLike.idl \
     $(WebCore)/testing/MallocStatistics.idl \
     $(WebCore)/testing/MemoryInfo.idl \
     $(WebCore)/testing/MockCDMFactory.idl \
index 1cdc8a4..82da46f 100644 (file)
@@ -507,6 +507,7 @@ bindings/js/JSDOMGuardedObject.cpp
 bindings/js/JSDOMMapLike.cpp
 bindings/js/JSDOMPromise.cpp
 bindings/js/JSDOMPromiseDeferred.cpp
+bindings/js/JSDOMSetLike.cpp
 bindings/js/JSDOMWindowBase.cpp
 bindings/js/JSDOMWindowCustom.cpp
 bindings/js/JSDOMWindowProperties.cpp
index ceea452..f836bfd 100644 (file)
                2D3EF4481917915C00034184 /* WebActionDisablingCALayerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4441917915C00034184 /* WebActionDisablingCALayerDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D3EF44A1917915C00034184 /* WebCoreCALayerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4461917915C00034184 /* WebCoreCALayerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */; };
+               2D4150DE1C1F868C000A3BA3 /* JSInternalsSetLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D6F3E921C1F85550061DBD5 /* JSInternalsSetLike.cpp */; };
                2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */; };
                2D481F04146B5C6B00AA7834 /* GradientImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0571460CD6F00263633 /* GradientImage.h */; };
                2D4F96F61A1ECC240098BF88 /* TextIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D4F96F21A1ECC240098BF88 /* TextIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4129C9AF1F59CF5B009D7403 /* ReadableStreamSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 4129C9801F5861C7009D7403 /* ReadableStreamSink.h */; settings = {ATTRIBUTES = (Private, ); }; };
                412DE4B8219285C00075F3A7 /* RTCRtpCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 412DE4B6219285BF0075F3A7 /* RTCRtpCapabilities.h */; };
                4133CB8B20F80E9900E89B11 /* MediaStreamAudioSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4133CB8920F80E8600E89B11 /* MediaStreamAudioSourceCocoa.cpp */; };
+               4136EC0C23838870000ADBCE /* InternalsSetLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4136EC09238387C3000ADBCE /* InternalsSetLike.cpp */; };
+               4136EC0D23838A47000ADBCE /* InternalsSetLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 4136EC0A238387C4000ADBCE /* InternalsSetLike.h */; };
                41380C271F3436AC00155FDA /* DOMCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41380C251F34369A00155FDA /* DOMCache.h */; };
                41380C291F3436AC00155FDA /* DOMCacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 41380C221F34369000155FDA /* DOMCacheStorage.h */; };
                4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; };
                4138F8581D253F0E001CB61E /* JSDOMIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138F8561D253EEE001CB61E /* JSDOMIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               413A1AA22371A8B4007EF3A5 /* JSDOMSetLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A1A9F2371A8A8007EF3A5 /* JSDOMSetLike.h */; };
                413C2C341BC29A8F0075204C /* JSDOMConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */; };
                413CCD4A20DE034F0065A21A /* MockMediaDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 413CCD4820DE013C0065A21A /* MockMediaDevice.h */; settings = {ATTRIBUTES = (Private, ); }; };
                413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */ = {isa = PBXBuildFile; fileRef = 413E00781DB0E4DE002341D2 /* MemoryRelease.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D6F3E8B1C1ECB1C0061DBD4 /* MockPageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockPageOverlay.h; sourceTree = "<group>"; };
                2D6F3E8C1C1ECB1C0061DBD4 /* MockPageOverlay.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MockPageOverlay.idl; sourceTree = "<group>"; };
                2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockPageOverlay.cpp; sourceTree = "<group>"; };
+               2D6F3E921C1F85550061DBD5 /* JSInternalsSetLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalsSetLike.cpp; sourceTree = "<group>"; };
                2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockPageOverlay.h; sourceTree = "<group>"; };
                2D70BA1218074DDF0001908A /* PlatformCALayerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerCocoa.h; sourceTree = "<group>"; };
                2D70BA1418074F850001908A /* PlatformCALayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayer.cpp; sourceTree = "<group>"; };
                4131F3B51F955BC50059995A /* ExtendableEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ExtendableEventInit.idl; sourceTree = "<group>"; };
                4133CB8920F80E8600E89B11 /* MediaStreamAudioSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamAudioSourceCocoa.cpp; sourceTree = "<group>"; };
                41369E55218C76E300792E29 /* RTCRtpCapabilities.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpCapabilities.idl; sourceTree = "<group>"; };
+               4136EC0723838746000ADBCE /* InternalsSetLike.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = InternalsSetLike.idl; sourceTree = "<group>"; };
+               4136EC09238387C3000ADBCE /* InternalsSetLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalsSetLike.cpp; sourceTree = "<group>"; };
+               4136EC0A238387C4000ADBCE /* InternalsSetLike.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InternalsSetLike.h; sourceTree = "<group>"; };
                41380C201F34368A00155FDA /* DOMCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DOMCache.cpp; path = Modules/cache/DOMCache.cpp; sourceTree = SOURCE_ROOT; };
                41380C211F34368D00155FDA /* DOMCacheStorage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DOMCacheStorage.cpp; path = Modules/cache/DOMCacheStorage.cpp; sourceTree = SOURCE_ROOT; };
                41380C221F34369000155FDA /* DOMCacheStorage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DOMCacheStorage.h; path = Modules/cache/DOMCacheStorage.h; sourceTree = SOURCE_ROOT; };
                4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; };
                4138F8551D253EEE001CB61E /* JSDOMIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMIterator.cpp; sourceTree = "<group>"; };
                4138F8561D253EEE001CB61E /* JSDOMIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMIterator.h; sourceTree = "<group>"; };
+               413A1A9F2371A8A8007EF3A5 /* JSDOMSetLike.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSDOMSetLike.h; sourceTree = "<group>"; };
+               413A1AA12371A8A9007EF3A5 /* JSDOMSetLike.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMSetLike.cpp; sourceTree = "<group>"; };
                413C2C331BC29A7B0075204C /* JSDOMConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConstructor.h; sourceTree = "<group>"; };
                413CCD4820DE013C0065A21A /* MockMediaDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockMediaDevice.h; sourceTree = "<group>"; };
                413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryRelease.cpp; sourceTree = "<group>"; };
                                A7BF7EDC14C9175A0014489D /* InternalSettings.cpp */,
                                A7BF7EDD14C9175A0014489D /* InternalSettings.h */,
                                A7BF7EDE14C9175A0014489D /* InternalSettings.idl */,
+                               4136EC09238387C3000ADBCE /* InternalsSetLike.cpp */,
+                               4136EC0A238387C4000ADBCE /* InternalsSetLike.h */,
+                               4136EC0723838746000ADBCE /* InternalsSetLike.idl */,
                                CDC26B3C160A62B00026757B /* LegacyMockCDM.cpp */,
                                CDC26B3D160A62B00026757B /* LegacyMockCDM.h */,
                                A7BE7EDD14C9175A0014489D /* MallocStatistics.h */,
                                A7B4EA7914C9348400C8F5BF /* JSInternalSettings.h */,
                                53ED3FDC167A88E7006762E6 /* JSInternalSettingsGenerated.cpp */,
                                53ED3FDD167A88E7006762E6 /* JSInternalSettingsGenerated.h */,
+                               2D6F3E921C1F85550061DBD5 /* JSInternalsSetLike.cpp */,
                                A7B4EA6814C9348400C8F5BF /* JSMallocStatistics.cpp */,
                                A7B4EA6914C9348400C8F5BF /* JSMallocStatistics.h */,
                                CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */,
                                E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */,
                                E172AF8D1811BC3700FBADB9 /* JSDOMPromiseDeferred.cpp */,
                                E172AF8E1811BC3700FBADB9 /* JSDOMPromiseDeferred.h */,
+                               413A1AA12371A8A9007EF3A5 /* JSDOMSetLike.cpp */,
+                               413A1A9F2371A8A8007EF3A5 /* JSDOMSetLike.h */,
                                BC6932710D7E293900AE44D1 /* JSDOMWindowBase.cpp */,
                                BC6932720D7E293900AE44D1 /* JSDOMWindowBase.h */,
                                460CBF331D4BCCFE0092E88E /* JSDOMWindowProperties.cpp */,
                                417DA6DA13734E6E007C57FB /* Internals.h in Headers */,
                                A7BF7EE014C9175A0014489D /* InternalSettings.h in Headers */,
                                53E29E5F167A8A1900586D3D /* InternalSettingsGenerated.h in Headers */,
+                               4136EC0D23838A47000ADBCE /* InternalsSetLike.h in Headers */,
                                51714EB11CF665CE004723C4 /* JSGCObservation.h in Headers */,
                                417DA71E13735DFA007C57FB /* JSInternals.h in Headers */,
                                A740B5A514C935AB00A77FA4 /* JSInternalSettings.h in Headers */,
                                466ED8D31EDE0144005E43F6 /* JSDOMRectList.h in Headers */,
                                0F4710C01DB56BE8002DCEC3 /* JSDOMRectReadOnly.h in Headers */,
                                BC5A86B60C3367E800EEA649 /* JSDOMSelection.h in Headers */,
+                               413A1AA22371A8B4007EF3A5 /* JSDOMSetLike.h in Headers */,
                                C5137CF311A58378004ADB99 /* JSDOMStringList.h in Headers */,
                                BC64649811D82349006455B0 /* JSDOMStringMap.h in Headers */,
                                7694563D1214D97C0007CBAE /* JSDOMTokenList.h in Headers */,
                                E179F0DA1B9774FE00ED0A27 /* Internals.mm in Sources */,
                                A7BF7EDF14C9175A0014489D /* InternalSettings.cpp in Sources */,
                                DE5F86111FA239DA006DB63A /* InternalSettingsGenerated.cpp in Sources */,
+                               4136EC0C23838870000ADBCE /* InternalsSetLike.cpp in Sources */,
                                DE5F86121FA239E7006DB63A /* JSGCObservation.cpp in Sources */,
                                417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */,
                                A740B5A714C935AF00A77FA4 /* JSInternalSettings.cpp in Sources */,
                                53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
+                               2D4150DE1C1F868C000A3BA3 /* JSInternalsSetLike.cpp in Sources */,
                                538EC9321F99B9F7004D22A8 /* JSMallocStatistics.cpp in Sources */,
                                CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
                                CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
diff --git a/Source/WebCore/bindings/js/JSDOMSetLike.cpp b/Source/WebCore/bindings/js/JSDOMSetLike.cpp
new file mode 100644 (file)
index 0000000..f1fab31
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDOMSetLike.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/CatchScope.h>
+
+namespace WebCore {
+
+std::pair<bool, std::reference_wrapper<JSC::JSObject>> getBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& setLike)
+{
+    auto& vm = lexicalGlobalObject.vm();
+    auto backingSet = setLike.get(&lexicalGlobalObject, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingSetPrivateName());
+    if (backingSet.isUndefined()) {
+        auto& vm = lexicalGlobalObject.vm();
+        auto scope = DECLARE_CATCH_SCOPE(vm);
+
+        backingSet = JSC::JSSet::create(&lexicalGlobalObject, vm, lexicalGlobalObject.setStructure());
+        scope.releaseAssertNoException();
+
+        setLike.putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingSetPrivateName(), backingSet, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
+        return { true, *JSC::asObject(backingSet) };
+    }
+    return { false, *JSC::asObject(backingSet) };
+}
+
+void clearBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& backingSet)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    JSC::JSValue function = backingSet.get(&lexicalGlobalObject, vm.propertyNames->clear);
+    ASSERT(!function.isUndefined());
+
+    JSC::CallData callData;
+    JSC::CallType callType = JSC::getCallData(vm, function, callData);
+    ASSERT(callType != JSC::CallType::None);
+    JSC::MarkedArgumentBuffer arguments;
+    JSC::call(&lexicalGlobalObject, function, callType, callData, &backingSet, arguments);
+}
+
+void addToBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& backingSet, JSC::JSValue item)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    JSC::JSValue function = backingSet.get(&lexicalGlobalObject, vm.propertyNames->add);
+    ASSERT(!function.isUndefined());
+
+    JSC::CallData callData;
+    JSC::CallType callType = JSC::getCallData(vm, function, callData);
+    ASSERT(callType != JSC::CallType::None);
+    JSC::MarkedArgumentBuffer arguments;
+    arguments.append(item);
+    JSC::call(&lexicalGlobalObject, function, callType, callData, &backingSet, arguments);
+}
+
+JSC::JSValue forwardAttributeGetterToBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& backingSet, const JSC::Identifier& attributeName)
+{
+    return backingSet.get(&lexicalGlobalObject, attributeName);
+}
+
+JSC::JSValue forwardFunctionCallToBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, JSC::JSObject& backingSet, const JSC::Identifier& functionName)
+{
+    JSC::JSValue function = backingSet.get(&lexicalGlobalObject, functionName);
+    ASSERT(!function.isUndefined());
+
+    JSC::CallData callData;
+    JSC::CallType callType = JSC::getCallData(lexicalGlobalObject.vm(), function, callData);
+    ASSERT(callType != JSC::CallType::None);
+    JSC::MarkedArgumentBuffer arguments;
+    for (size_t cptr = 0; cptr < callFrame.argumentCount(); ++cptr)
+        arguments.append(callFrame.uncheckedArgument(cptr));
+    ASSERT(!arguments.hasOverflowed());
+    return JSC::call(&lexicalGlobalObject, function, callType, callData, &backingSet, arguments);
+}
+
+}
diff --git a/Source/WebCore/bindings/js/JSDOMSetLike.h b/Source/WebCore/bindings/js/JSDOMSetLike.h
new file mode 100644 (file)
index 0000000..c81ea1d
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
+#include "JSDOMGlobalObject.h"
+#include <JavaScriptCore/BuiltinNames.h>
+#include <JavaScriptCore/CommonIdentifiers.h>
+#include <JavaScriptCore/JSSet.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT std::pair<bool, std::reference_wrapper<JSC::JSObject>> getBackingSet(JSC::JSGlobalObject&, JSC::JSObject& setLike);
+WEBCORE_EXPORT JSC::JSValue forwardAttributeGetterToBackingSet(JSC::JSGlobalObject&, JSC::JSObject&, const JSC::Identifier&);
+WEBCORE_EXPORT JSC::JSValue forwardFunctionCallToBackingSet(JSC::JSGlobalObject&, JSC::CallFrame&, JSC::JSObject&, const JSC::Identifier&);
+WEBCORE_EXPORT void clearBackingSet(JSC::JSGlobalObject&, JSC::JSObject&);
+WEBCORE_EXPORT void addToBackingSet(JSC::JSGlobalObject&, JSC::JSObject&, JSC::JSValue item);
+
+template<typename WrapperClass> JSC::JSObject& getAndInitializeBackingSet(JSC::JSGlobalObject&, WrapperClass&);
+template<typename WrapperClass> JSC::JSValue forwardSizeToSetLike(JSC::JSGlobalObject&, WrapperClass&);
+template<typename WrapperClass> JSC::JSValue forwardEntriesToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&);
+template<typename WrapperClass> JSC::JSValue forwardKeysToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&);
+template<typename WrapperClass> JSC::JSValue forwardValuesToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&);
+template<typename WrapperClass> JSC::JSValue forwardClearToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&);
+template<typename WrapperClass, typename ItemType> JSC::JSValue forwardHasToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&, ItemType&&);
+template<typename WrapperClass, typename ItemType> JSC::JSValue forwardAddToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&, ItemType&&);
+template<typename WrapperClass, typename ItemType> JSC::JSValue forwardDeleteToSetLike(JSC::JSGlobalObject&, JSC::CallFrame&, WrapperClass&, ItemType&&);
+
+class DOMSetAdapter {
+public:
+    DOMSetAdapter(JSC::JSGlobalObject&, JSC::JSObject&);
+    template<class IDLType> void add(typename IDLType::ParameterType value);
+    void clear();
+
+private:
+    JSC::JSGlobalObject& m_lexicalGlobalObject;
+    JSC::JSObject& m_backingSet;
+};
+
+inline DOMSetAdapter::DOMSetAdapter(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& backingSet)
+    : m_lexicalGlobalObject(lexicalGlobalObject)
+    , m_backingSet(backingSet)
+{
+}
+
+template<class IDLType>
+inline void DOMSetAdapter::add(typename IDLType::ParameterType value)
+{
+    JSC::JSLockHolder locker(&m_lexicalGlobalObject);
+    auto item = toJS<IDLType>(m_lexicalGlobalObject, *JSC::jsCast<JSDOMGlobalObject*>(&m_lexicalGlobalObject), std::forward<typename IDLType::ParameterType>(value));
+    addToBackingSet(m_lexicalGlobalObject, m_backingSet, item);
+}
+
+inline void DOMSetAdapter::clear()
+{
+    clearBackingSet(m_lexicalGlobalObject, m_backingSet);
+}
+
+template<typename WrapperClass> inline JSC::JSObject& getAndInitializeBackingSet(JSC::JSGlobalObject& lexicalGlobalObject, WrapperClass& setLike)
+{
+    auto pair = getBackingSet(lexicalGlobalObject, setLike);
+    if (pair.first) {
+        DOMSetAdapter adapter { lexicalGlobalObject, pair.second.get() };
+        setLike.wrapped().initializeSetLike(adapter);
+    }
+    return pair.second.get();
+}
+
+template<typename WrapperClass> inline JSC::JSValue forwardSizeToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, WrapperClass& setLike)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardAttributeGetterToBackingSet(lexicalGlobalObject, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->size);
+}
+
+template<typename WrapperClass> inline JSC::JSValue forwardEntriesToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->builtinNames().entriesPublicName());
+}
+
+template<typename WrapperClass> inline JSC::JSValue forwardKeysToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->builtinNames().keysPublicName());
+}
+
+template<typename WrapperClass> inline JSC::JSValue forwardValuesToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->builtinNames().valuesPublicName());
+}
+
+template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardHasToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike, ItemType&&)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->builtinNames().hasPublicName());
+}
+
+template<typename WrapperClass> inline JSC::JSValue forwardClearToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike)
+{
+    setLike.wrapped().clearFromSetLike();
+
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    return forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->clear);
+}
+
+template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardAddToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike, ItemType&& item)
+{
+    setLike.wrapped().addToSetLike(std::forward<ItemType>(item));
+
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->add);
+    return &setLike;
+}
+
+template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardDeleteToSetLike(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, WrapperClass& setLike, ItemType&& item)
+{
+    auto isDeleted = setLike.wrapped().removeFromSetLike(std::forward<ItemType>(item));
+    UNUSED_PARAM(isDeleted);
+
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    auto result = forwardFunctionCallToBackingSet(lexicalGlobalObject, callFrame, getAndInitializeBackingSet(lexicalGlobalObject, setLike), vm.propertyNames->deleteKeyword);
+    ASSERT_UNUSED(result, result.asBoolean() == isDeleted);
+    return result;
+}
+
+}
index 2f3985f..228c8e9 100644 (file)
@@ -247,6 +247,7 @@ namespace WebCore {
     macro(associatedReadableByteStreamController) \
     macro(autoAllocateChunkSize) \
     macro(backingMap) \
+    macro(backingSet) \
     macro(blur) \
     macro(body) \
     macro(byobRequest) \
index fbbadfc..d578626 100644 (file)
@@ -1618,6 +1618,10 @@ sub GetFullyQualifiedImplementationCallName
         return "forward" . $codeGenerator->WK_ucfirst($property->name) . "ToMapLike";
     }
     
+    if ($property->isSetLike) {
+        return "forward" . $codeGenerator->WK_ucfirst($property->name) . "ToSetLike";
+    }
+
     return "${implExpression}.${implementationName}";
 }
 
@@ -1629,7 +1633,7 @@ sub AddAdditionalArgumentsForImplementationCall
         unshift(@$arguments, $implExpression);
     }
     
-    if ($property->isMapLike) {
+    if ($property->isMapLike or $property->isSetLike) {
         push(@$arguments, $globalObject);
         if (ref($property) eq "IDLOperation") {
             push(@$arguments, $callFrame);
@@ -1766,6 +1770,7 @@ sub IsAcceleratedDOMAttribute
 
     return 0 if $attribute->isStatic;
     return 0 if $attribute->isMapLike;
+    return 0 if $attribute->isSetLike;
     return 0 if $codeGenerator->IsConstructorType($attribute->type);
     return 0 if IsJSBuiltin($interface, $attribute);
     return 0 if $attribute->extendedAttributes->{LenientThis};
@@ -1846,6 +1851,7 @@ sub PrototypeOperationCount
 
     $count += scalar @{$interface->iterable->operations} if $interface->iterable;
     $count += scalar @{$interface->mapLike->operations} if $interface->mapLike;
+    $count += scalar @{$interface->setLike->operations} if $interface->setLike;
     $count += scalar @{$interface->serializable->operations} if $interface->serializable;
 
     return $count;
@@ -3103,6 +3109,7 @@ sub GeneratePropertiesHashTable
 
     my @attributes = @{$interface->attributes};
     push(@attributes, @{$interface->mapLike->attributes}) if $interface->mapLike;
+    push(@attributes, @{$interface->setLike->attributes}) if $interface->setLike;
 
     foreach my $attribute (@attributes) {
         next if ($attribute->isStatic);
@@ -3148,6 +3155,7 @@ sub GeneratePropertiesHashTable
     my @operations = @{$interface->operations};
     push(@operations, @{$interface->iterable->operations}) if IsKeyValueIterableInterface($interface);
     push(@operations, @{$interface->mapLike->operations}) if $interface->mapLike;
+    push(@operations, @{$interface->setLike->operations}) if $interface->setLike;
     push(@operations, @{$interface->serializable->operations}) if $interface->serializable;
     foreach my $operation (@operations) {
         next if ($operation->extendedAttributes->{PrivateIdentifier} and not $operation->extendedAttributes->{PublicIdentifier});
@@ -3900,7 +3908,7 @@ sub InterfaceNeedsIterator
 {
     my ($interface) = @_;
 
-    # FIXME: This should return 1 for setlike once we support it.
+    return 1 if $interface->setLike;
     return 1 if $interface->mapLike;
     return 1 if $interface->iterable;
 
@@ -3937,6 +3945,7 @@ sub GenerateImplementation
     AddToImplIncludes("<wtf/PointerPreparations.h>");
     AddToImplIncludes("<JavaScriptCore/PropertyNameArray.h>") if $indexedGetterOperation;
     AddToImplIncludes("JSDOMMapLike.h") if $interface->mapLike;
+    AddToImplIncludes("JSDOMSetLike.h") if $interface->setLike;
     AddJSBuiltinIncludesIfNeeded($interface);
 
     my $implType = GetImplClassName($interface);
@@ -3952,10 +3961,12 @@ sub GenerateImplementation
     my @operations = @{$interface->operations};
     push(@operations, @{$interface->iterable->operations}) if IsKeyValueIterableInterface($interface);
     push(@operations, @{$interface->mapLike->operations}) if $interface->mapLike;
+    push(@operations, @{$interface->setLike->operations}) if $interface->setLike;
     push(@operations, @{$interface->serializable->operations}) if $interface->serializable;
 
     my @attributes = @{$interface->attributes};
     push(@attributes, @{$interface->mapLike->attributes}) if $interface->mapLike;
+    push(@attributes, @{$interface->setLike->attributes}) if $interface->setLike;
 
     my $numConstants = @{$interface->constants};
     my $numOperations = @operations;
@@ -4306,7 +4317,7 @@ sub GenerateImplementation
 
         if (InterfaceNeedsIterator($interface)) {
             AddToImplIncludes("<JavaScriptCore/BuiltinNames.h>");
-            if (IsKeyValueIterableInterface($interface) or $interface->mapLike) {
+            if (IsKeyValueIterableInterface($interface) or $interface->mapLike or $interface->setLike) {
                 push(@implContent, "    putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));\n");
             } else {
                 AddToImplIncludes("<JavaScriptCore/ArrayPrototype.h>");
@@ -4937,7 +4948,7 @@ sub GenerateAttributeGetterBodyDefinition
 
         my $globalObjectReference = $attribute->isStatic ? "*jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject)" : "*thisObject.globalObject()";
         my $toJSExpression = NativeToJSValueUsingReferences($attribute, $interface, "${functionName}(" . join(", ", @arguments) . ")", $globalObjectReference);
-        push(@$outputArray, "    auto& impl = thisObject.wrapped();\n") unless $attribute->isStatic or $attribute->isMapLike;
+        push(@$outputArray, "    auto& impl = thisObject.wrapped();\n") unless $attribute->isStatic or $attribute->isMapLike or $attribute->isSetLike;
 
         if (!IsReadonly($attribute)) {
             my $callTracingCallback = $attribute->extendedAttributes->{CallTracingCallback} || $interface->extendedAttributes->{CallTracingCallback};
@@ -5268,7 +5279,7 @@ sub GenerateOperationBodyDefinition
     } elsif (HasCustomMethod($operation)) {
         GenerateImplementationCustomFunctionCall($outputArray, $operation, $interface, $className, $functionImplementationName, $indent);
     } else {
-        if (!$operation->isMapLike && !$operation->isStatic) {
+        if (!$operation->isMapLike && !$operation->isSetLike && !$operation->isStatic) {
             push(@$outputArray, "    auto& impl = castedThis->wrapped();\n");
         }
 
@@ -7333,6 +7344,7 @@ sub GetRuntimeEnabledStaticProperties
 
     my @attributes = @{$interface->attributes};
     push(@attributes, @{$interface->mapLike->attributes}) if $interface->mapLike;
+    push(@attributes, @{$interface->setLike->attributes}) if $interface->setLike;
 
     foreach my $attribute (@attributes) {
         next if AttributeShouldBeOnInstance($interface, $attribute) != 0;
@@ -7346,6 +7358,7 @@ sub GetRuntimeEnabledStaticProperties
     my @operations = @{$interface->operations};
     push(@operations, @{$interface->iterable->operations}) if IsKeyValueIterableInterface($interface);
     push(@operations, @{$interface->mapLike->operations}) if $interface->mapLike;
+    push(@operations, @{$interface->setLike->operations}) if $interface->setLike;
     push(@operations, @{$interface->serializable->operations}) if $interface->serializable;
     foreach my $operation (@operations) {
         next if ($operation->extendedAttributes->{PrivateIdentifier} and not $operation->extendedAttributes->{PublicIdentifier});
index ddf4976..34ce719 100644 (file)
@@ -69,6 +69,7 @@ struct( IDLInterface => {
     isPartial => '$', # Used for partial interfaces
     iterable => '$', # Used for iterable interfaces
     mapLike => '$', # Used for mapLike interfaces
+    setLike => '$', # Used for setLike interfaces
     serializable => '$', # Used for serializable interfaces
     extendedAttributes => '$',
 });
@@ -93,6 +94,7 @@ struct( IDLOperation => {
     isSerializer => '$',
     isStringifier => '$',
     isMapLike => '$',
+    isSetLike => '$',
     specials => '@',
     extendedAttributes => '%',
 });
@@ -104,6 +106,7 @@ struct( IDLAttribute => {
     type => 'IDLType',
     isStatic => '$',
     isMapLike => '$',
+    isSetLike => '$',
     isStringifier => '$',
     isReadOnly => '$',
     isInherit => '$',
@@ -129,6 +132,15 @@ struct( IDLMapLike => {
     extendedAttributes => '$',
 });
 
+# https://heycam.github.io/webidl/#es-setlike
+struct( IDLSetLike => {
+    isReadOnly => '$',
+    itemType => 'IDLType',
+    attributes => '@', # SetLike attributes (size)
+    operations => '@', # SetLike operations (entries, keys, values, forEach, has and if not readonly, delete, set and clear)
+    extendedAttributes => '$',
+});
+
 # https://heycam.github.io/webidl/#idl-serializers
 struct( IDLSerializable => {
     attributes => '@', # List of attributes to serialize
@@ -583,6 +595,7 @@ sub cloneOperation
     $clonedOperation->isSerializer($operation->isSerializer);
     $clonedOperation->isStringifier($operation->isStringifier);
     $clonedOperation->isMapLike($operation->isMapLike);
+    $clonedOperation->isSetLike($operation->isSetLike);
     $clonedOperation->specials($operation->specials);
 
     copyExtendedAttributes($clonedOperation->extendedAttributes, $operation->extendedAttributes);
@@ -710,6 +723,17 @@ sub applyTypedefs
                     $self->applyTypedefsToOperation($operation);
                 }
             }
+            if ($definition->setLike) {
+                if ($definition->setLike->itemType) {
+                    $definition->setLike->itemType($self->typeByApplyingTypedefs($definition->setLike->itemType));
+                }
+                foreach my $attribute (@{$definition->setLike->attributes}) {
+                    $attribute->type($self->typeByApplyingTypedefs($attribute->type));
+                }
+                foreach my $operation (@{$definition->setLike->operations}) {
+                    $self->applyTypedefsToOperation($operation);
+                }
+            }
         } elsif (ref($definition) eq "IDLDictionary") {
             foreach my $member (@{$definition->members}) {
                 $member->type($self->typeByApplyingTypedefs($member->type));
@@ -1377,6 +1401,9 @@ sub parseOperationOrReadWriteAttributeOrMaplike
     if ($next->value() eq "maplike") {
         return $self->parseMapLikeRest($extendedAttributeList, 0);
     }
+    if ($next->value() eq "setlike") {
+        return $self->parseSetLikeRest($extendedAttributeList, 0);
+    }
     if ($next->type() == IdentifierToken || $next->value() =~ /$nextOperation_1/) {
         return $self->parseOperation($extendedAttributeList);
     }
@@ -1401,6 +1428,9 @@ sub parseReadOnlyMember
         if ($next->value() eq "maplike") {
             return $self->parseMapLikeRest($extendedAttributeList, 1);
         }
+        if ($next->value() eq "setlike") {
+            return $self->parseSetLikeRest($extendedAttributeList, 1);
+        }
     }
     $self->assertUnexpectedToken($next->value(), __LINE__);
 }
@@ -1697,6 +1727,7 @@ sub parseOperation
 {
     my $self = shift;
     my $extendedAttributeList = shift;
+    my $isReadOnly = shift;
 
     my $next = $self->nextToken();
     if ($next->value() =~ /$nextSpecials_1/) {
@@ -2001,6 +2032,123 @@ sub parseMapLikeProperties
     return $maplike;
 }
 
+sub parseSetLikeRest
+{
+    my $self = shift;
+    my $extendedAttributeList = shift;
+    my $isReadOnly = shift;
+
+    my $next = $self->nextToken();
+    if ($next->value() eq "setlike") {
+        $self->assertTokenValue($self->getToken(), "setlike", __LINE__);
+        my $setLikeNode = $self->parseSetLikeProperties($extendedAttributeList, $isReadOnly);
+        $self->assertTokenValue($self->getToken(), ";", __LINE__);
+        return $setLikeNode;
+    }
+    $self->assertUnexpectedToken($next->value(), __LINE__);
+}
+
+sub parseSetLikeProperties
+{
+    my $self = shift;
+    my $extendedAttributeList = shift;
+    my $isReadOnly = shift;
+
+    my $setlike = IDLSetLike->new();
+    $setlike->extendedAttributes($extendedAttributeList);
+
+    $self->assertTokenValue($self->getToken(), "<", __LINE__);
+    $setlike->itemType($self->parseTypeWithExtendedAttributes());
+    $self->assertTokenValue($self->getToken(), ">", __LINE__);
+
+    # FIXME: Synthetic operations should not be added during parsing. Instead, the CodeGenerator
+    # should be responsible for them.
+
+    my $notEnumerableExtendedAttributeList = $extendedAttributeList;
+    $notEnumerableExtendedAttributeList->{NotEnumerable} = 1;
+
+    my $sizeAttribute = IDLAttribute->new();
+    $sizeAttribute->name("size");
+    $sizeAttribute->isSetLike(1);
+    $sizeAttribute->extendedAttributes($extendedAttributeList);
+    $sizeAttribute->isReadOnly(1);
+    $sizeAttribute->type(makeSimpleType("any"));
+    push(@{$setlike->attributes}, $sizeAttribute);
+
+    my $hasOperation = IDLOperation->new();
+    $hasOperation->name("has");
+    $hasOperation->isSetLike(1);
+    my $hasArgument = IDLArgument->new();
+    $hasArgument->name("key");
+    $hasArgument->type($setlike->itemType);
+    $hasArgument->extendedAttributes($extendedAttributeList);
+    push(@{$hasOperation->arguments}, ($hasArgument));
+    $hasOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $hasOperation->type(makeSimpleType("any"));
+
+    my $entriesOperation = IDLOperation->new();
+    $entriesOperation->name("entries");
+    $entriesOperation->isSetLike(1);
+    $entriesOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $entriesOperation->type(makeSimpleType("any"));
+
+    my $keysOperation = IDLOperation->new();
+    $keysOperation->name("keys");
+    $keysOperation->isSetLike(1);
+    $keysOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $keysOperation->type(makeSimpleType("any"));
+
+    my $valuesOperation = IDLOperation->new();
+    $valuesOperation->name("values");
+    $valuesOperation->isSetLike(1);
+    $valuesOperation->extendedAttributes($extendedAttributeList);
+    $valuesOperation->extendedAttributes->{NotEnumerable} = 1;
+    $valuesOperation->type(makeSimpleType("any"));
+
+    # FIXME: Add support to forEach
+
+    push(@{$setlike->operations}, $hasOperation);
+    push(@{$setlike->operations}, $entriesOperation);
+    push(@{$setlike->operations}, $keysOperation);
+    push(@{$setlike->operations}, $valuesOperation);
+
+    return $setlike if $isReadOnly;
+
+    my $addOperation = IDLOperation->new();
+    $addOperation->name("add");
+    $addOperation->isSetLike(1);
+    my $addArgument = IDLArgument->new();
+    $addArgument->name("key");
+    $addArgument->type($setlike->itemType);
+    $addArgument->extendedAttributes($extendedAttributeList);
+    push(@{$addOperation->arguments}, ($addArgument));
+    $addOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $addOperation->type(makeSimpleType("any"));
+
+    my $clearOperation = IDLOperation->new();
+    $clearOperation->name("clear");
+    $clearOperation->isSetLike(1);
+    $clearOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $clearOperation->type(makeSimpleType("void"));
+
+    my $deleteOperation = IDLOperation->new();
+    $deleteOperation->name("delete");
+    $deleteOperation->isSetLike(1);
+    my $deleteArgument = IDLArgument->new();
+    $deleteArgument->name("key");
+    $deleteArgument->type($setlike->itemType);
+    $deleteArgument->extendedAttributes($extendedAttributeList);
+    push(@{$deleteOperation->arguments}, ($deleteArgument));
+    $deleteOperation->extendedAttributes($notEnumerableExtendedAttributeList);
+    $deleteOperation->type(makeSimpleType("any"));
+
+    push(@{$setlike->operations}, $addOperation);
+    push(@{$setlike->operations}, $clearOperation);
+    push(@{$setlike->operations}, $deleteOperation);
+
+    return $setlike;
+}
+
 sub parseOperationRest
 {
     my $self = shift;
@@ -2851,6 +2999,10 @@ sub applyMemberList
             $interface->mapLike($item);
             next;
         }
+        if (ref($item) eq "IDLSetLike") {
+            $interface->setLike($item);
+            next;
+        }
         if (ref($item) eq "IDLOperation") {
             if ($item->name eq "") {
                 push(@{$interface->anonymousOperations}, $item);
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.cpp b/Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.cpp
new file mode 100644 (file)
index 0000000..372fcc6
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadOnlySetLike.h"
+
+#include "ActiveDOMObject.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConstructorNotConstructable.h"
+#include "JSDOMConvertAny.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMOperation.h"
+#include "JSDOMSetLike.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include <JavaScriptCore/BuiltinNames.h>
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionHas(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionEntries(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionKeys(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionValues(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+// Attributes
+
+JSC::EncodedJSValue jsReadOnlySetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSReadOnlySetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsReadOnlySetLikeSize(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+
+class JSReadOnlySetLikePrototype : public JSC::JSNonFinalObject {
+public:
+    using Base = JSC::JSNonFinalObject;
+    static JSReadOnlySetLikePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        JSReadOnlySetLikePrototype* ptr = new (NotNull, JSC::allocateCell<JSReadOnlySetLikePrototype>(vm.heap)) JSReadOnlySetLikePrototype(vm, globalObject, structure);
+        ptr->finishCreation(vm);
+        return ptr;
+    }
+
+    DECLARE_INFO;
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+private:
+    JSReadOnlySetLikePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+        : JSC::JSNonFinalObject(vm, structure)
+    {
+    }
+
+    void finishCreation(JSC::VM&);
+};
+
+using JSReadOnlySetLikeConstructor = JSDOMConstructorNotConstructable<JSReadOnlySetLike>;
+
+template<> JSValue JSReadOnlySetLikeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+    UNUSED_PARAM(vm);
+    return globalObject.functionPrototype();
+}
+
+template<> void JSReadOnlySetLikeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    putDirect(vm, vm.propertyNames->prototype, JSReadOnlySetLike::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+    putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("ReadOnlySetLike"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+}
+
+template<> const ClassInfo JSReadOnlySetLikeConstructor::s_info = { "ReadOnlySetLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadOnlySetLikeConstructor) };
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadOnlySetLikePrototypeTableValues[] =
+{
+    { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadOnlySetLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSReadOnlySetLikeConstructor) } },
+    { "size", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadOnlySetLikeSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+    { "has", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadOnlySetLikePrototypeFunctionHas), (intptr_t) (1) } },
+    { "entries", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadOnlySetLikePrototypeFunctionEntries), (intptr_t) (0) } },
+    { "keys", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadOnlySetLikePrototypeFunctionKeys), (intptr_t) (0) } },
+    { "values", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadOnlySetLikePrototypeFunctionValues), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadOnlySetLikePrototype::s_info = { "ReadOnlySetLikePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadOnlySetLikePrototype) };
+
+void JSReadOnlySetLikePrototype::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    reifyStaticProperties(vm, JSReadOnlySetLike::info(), JSReadOnlySetLikePrototypeTableValues, *this);
+    putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
+}
+
+const ClassInfo JSReadOnlySetLike::s_info = { "ReadOnlySetLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadOnlySetLike) };
+
+JSReadOnlySetLike::JSReadOnlySetLike(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadOnlySetLike>&& impl)
+    : JSDOMWrapper<ReadOnlySetLike>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSReadOnlySetLike::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(vm, info()));
+
+    static_assert(!std::is_base_of<ActiveDOMObject, ReadOnlySetLike>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+
+}
+
+JSObject* JSReadOnlySetLike::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return JSReadOnlySetLikePrototype::create(vm, &globalObject, JSReadOnlySetLikePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadOnlySetLike::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return getDOMPrototype<JSReadOnlySetLike>(vm, globalObject);
+}
+
+JSValue JSReadOnlySetLike::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+    return getDOMConstructor<JSReadOnlySetLikeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadOnlySetLike::destroy(JSC::JSCell* cell)
+{
+    JSReadOnlySetLike* thisObject = static_cast<JSReadOnlySetLike*>(cell);
+    thisObject->JSReadOnlySetLike::~JSReadOnlySetLike();
+}
+
+template<> inline JSReadOnlySetLike* IDLAttribute<JSReadOnlySetLike>::cast(JSGlobalObject& lexicalGlobalObject, EncodedJSValue thisValue)
+{
+    return jsDynamicCast<JSReadOnlySetLike*>(JSC::getVM(&lexicalGlobalObject), JSValue::decode(thisValue));
+}
+
+template<> inline JSReadOnlySetLike* IDLOperation<JSReadOnlySetLike>::cast(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame)
+{
+    return jsDynamicCast<JSReadOnlySetLike*>(JSC::getVM(&lexicalGlobalObject), callFrame.thisValue());
+}
+
+EncodedJSValue jsReadOnlySetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    VM& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicCast<JSReadOnlySetLikePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype))
+        return throwVMTypeError(lexicalGlobalObject, throwScope);
+    return JSValue::encode(JSReadOnlySetLike::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+bool setJSReadOnlySetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    VM& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicCast<JSReadOnlySetLikePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype)) {
+        throwVMTypeError(lexicalGlobalObject, throwScope);
+        return false;
+    }
+    // Shadowing a built-in constructor
+    return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
+}
+
+static inline JSValue jsReadOnlySetLikeSizeGetter(JSGlobalObject& lexicalGlobalObject, JSReadOnlySetLike& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(lexicalGlobalObject);
+    JSValue result = toJS<IDLAny>(lexicalGlobalObject, throwScope, forwardSizeToSetLike(lexicalGlobalObject, thisObject));
+    return result;
+}
+
+EncodedJSValue jsReadOnlySetLikeSize(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSReadOnlySetLike>::get<jsReadOnlySetLikeSizeGetter>(*lexicalGlobalObject, thisValue, "size");
+}
+
+static inline JSC::EncodedJSValue jsReadOnlySetLikePrototypeFunctionHasBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadOnlySetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    if (UNLIKELY(callFrame->argumentCount() < 1))
+        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+    auto key = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    return JSValue::encode(toJS<IDLAny>(forwardHasToSetLike(*lexicalGlobalObject, *callFrame, *castedThis, WTFMove(key))));
+}
+
+EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionHas(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSReadOnlySetLike>::call<jsReadOnlySetLikePrototypeFunctionHasBody>(*lexicalGlobalObject, *callFrame, "has");
+}
+
+static inline JSC::EncodedJSValue jsReadOnlySetLikePrototypeFunctionEntriesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadOnlySetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardEntriesToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionEntries(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSReadOnlySetLike>::call<jsReadOnlySetLikePrototypeFunctionEntriesBody>(*lexicalGlobalObject, *callFrame, "entries");
+}
+
+static inline JSC::EncodedJSValue jsReadOnlySetLikePrototypeFunctionKeysBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadOnlySetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardKeysToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionKeys(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSReadOnlySetLike>::call<jsReadOnlySetLikePrototypeFunctionKeysBody>(*lexicalGlobalObject, *callFrame, "keys");
+}
+
+static inline JSC::EncodedJSValue jsReadOnlySetLikePrototypeFunctionValuesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadOnlySetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardValuesToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsReadOnlySetLikePrototypeFunctionValues(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSReadOnlySetLike>::call<jsReadOnlySetLikePrototypeFunctionValuesBody>(*lexicalGlobalObject, *callFrame, "values");
+}
+
+void JSReadOnlySetLike::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+    auto* thisObject = jsCast<JSReadOnlySetLike*>(cell);
+    analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+    if (thisObject->scriptExecutionContext())
+        analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+    Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSReadOnlySetLikeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
+{
+    UNUSED_PARAM(handle);
+    UNUSED_PARAM(visitor);
+    UNUSED_PARAM(reason);
+    return false;
+}
+
+void JSReadOnlySetLikeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+    auto* jsReadOnlySetLike = static_cast<JSReadOnlySetLike*>(handle.slot()->asCell());
+    auto& world = *static_cast<DOMWrapperWorld*>(context);
+    uncacheWrapper(world, &jsReadOnlySetLike->wrapped(), jsReadOnlySetLike);
+}
+
+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable: 4483)
+extern "C" { extern void (*const __identifier("??_7ReadOnlySetLike@WebCore@@6B@")[])(); }
+#else
+extern "C" { extern void* _ZTVN7WebCore15ReadOnlySetLikeE[]; }
+#endif
+#endif
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<ReadOnlySetLike>&& impl)
+{
+
+#if ENABLE(BINDING_INTEGRITY)
+    void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
+#if PLATFORM(WIN)
+    void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7ReadOnlySetLike@WebCore@@6B@"));
+#else
+    void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15ReadOnlySetLikeE[2]);
+#endif
+
+    // If this fails ReadOnlySetLike does not have a vtable, so you need to add the
+    // ImplementationLacksVTable attribute to the interface definition
+    static_assert(std::is_polymorphic<ReadOnlySetLike>::value, "ReadOnlySetLike is not polymorphic");
+
+    // If you hit this assertion you either have a use after free bug, or
+    // ReadOnlySetLike has subclasses. If ReadOnlySetLike has subclasses that get passed
+    // to toJS() we currently require ReadOnlySetLike you to opt out of binding hardening
+    // by adding the SkipVTableValidation attribute to the interface IDL definition
+    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+    return createWrapper<ReadOnlySetLike>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadOnlySetLike& impl)
+{
+    return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+ReadOnlySetLike* JSReadOnlySetLike::toWrapped(JSC::VM& vm, JSC::JSValue value)
+{
+    if (auto* wrapper = jsDynamicCast<JSReadOnlySetLike*>(vm, value))
+        return &wrapper->wrapped();
+    return nullptr;
+}
+
+}
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.h b/Source/WebCore/bindings/scripts/test/JS/JSReadOnlySetLike.h
new file mode 100644 (file)
index 0000000..d311be4
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "ReadOnlySetLike.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSReadOnlySetLike : public JSDOMWrapper<ReadOnlySetLike> {
+public:
+    using Base = JSDOMWrapper<ReadOnlySetLike>;
+    static JSReadOnlySetLike* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<ReadOnlySetLike>&& impl)
+    {
+        JSReadOnlySetLike* ptr = new (NotNull, JSC::allocateCell<JSReadOnlySetLike>(globalObject->vm().heap)) JSReadOnlySetLike(structure, *globalObject, WTFMove(impl));
+        ptr->finishCreation(globalObject->vm());
+        return ptr;
+    }
+
+    static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+    static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+    static ReadOnlySetLike* toWrapped(JSC::VM&, JSC::JSValue);
+    static void destroy(JSC::JSCell*);
+
+    DECLARE_INFO;
+
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+    static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+protected:
+    JSReadOnlySetLike(JSC::Structure*, JSDOMGlobalObject&, Ref<ReadOnlySetLike>&&);
+
+    void finishCreation(JSC::VM&);
+};
+
+class JSReadOnlySetLikeOwner : public JSC::WeakHandleOwner {
+public:
+    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&, const char**);
+    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, ReadOnlySetLike*)
+{
+    static NeverDestroyed<JSReadOnlySetLikeOwner> owner;
+    return &owner.get();
+}
+
+inline void* wrapperKey(ReadOnlySetLike* wrappableObject)
+{
+    return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, ReadOnlySetLike&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadOnlySetLike* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadOnlySetLike>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<ReadOnlySetLike>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<ReadOnlySetLike> {
+    using WrapperClass = JSReadOnlySetLike;
+    using ToWrappedReturnType = ReadOnlySetLike*;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSSetLike.cpp b/Source/WebCore/bindings/scripts/test/JS/JSSetLike.cpp
new file mode 100644 (file)
index 0000000..bd7c30f
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSSetLike.h"
+
+#include "ActiveDOMObject.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConstructorNotConstructable.h"
+#include "JSDOMConvertAny.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMOperation.h"
+#include "JSDOMSetLike.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include <JavaScriptCore/BuiltinNames.h>
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionHas(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionEntries(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionKeys(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionValues(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionAdd(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionClear(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC::EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionDelete(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+// Attributes
+
+JSC::EncodedJSValue jsSetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSSetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsSetLikeSize(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+
+class JSSetLikePrototype : public JSC::JSNonFinalObject {
+public:
+    using Base = JSC::JSNonFinalObject;
+    static JSSetLikePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        JSSetLikePrototype* ptr = new (NotNull, JSC::allocateCell<JSSetLikePrototype>(vm.heap)) JSSetLikePrototype(vm, globalObject, structure);
+        ptr->finishCreation(vm);
+        return ptr;
+    }
+
+    DECLARE_INFO;
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+private:
+    JSSetLikePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+        : JSC::JSNonFinalObject(vm, structure)
+    {
+    }
+
+    void finishCreation(JSC::VM&);
+};
+
+using JSSetLikeConstructor = JSDOMConstructorNotConstructable<JSSetLike>;
+
+template<> JSValue JSSetLikeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+    UNUSED_PARAM(vm);
+    return globalObject.functionPrototype();
+}
+
+template<> void JSSetLikeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    putDirect(vm, vm.propertyNames->prototype, JSSetLike::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+    putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("SetLike"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+}
+
+template<> const ClassInfo JSSetLikeConstructor::s_info = { "SetLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSetLikeConstructor) };
+
+/* Hash table for prototype */
+
+static const HashTableValue JSSetLikePrototypeTableValues[] =
+{
+    { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSetLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSetLikeConstructor) } },
+    { "size", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSetLikeSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+    { "has", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionHas), (intptr_t) (1) } },
+    { "entries", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionEntries), (intptr_t) (0) } },
+    { "keys", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionKeys), (intptr_t) (0) } },
+    { "values", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionValues), (intptr_t) (0) } },
+    { "add", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionAdd), (intptr_t) (1) } },
+    { "clear", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionClear), (intptr_t) (0) } },
+    { "delete", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSetLikePrototypeFunctionDelete), (intptr_t) (1) } },
+};
+
+const ClassInfo JSSetLikePrototype::s_info = { "SetLikePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSetLikePrototype) };
+
+void JSSetLikePrototype::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    reifyStaticProperties(vm, JSSetLike::info(), JSSetLikePrototypeTableValues, *this);
+    putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
+}
+
+const ClassInfo JSSetLike::s_info = { "SetLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSetLike) };
+
+JSSetLike::JSSetLike(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SetLike>&& impl)
+    : JSDOMWrapper<SetLike>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSSetLike::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(vm, info()));
+
+    static_assert(!std::is_base_of<ActiveDOMObject, SetLike>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+
+}
+
+JSObject* JSSetLike::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return JSSetLikePrototype::create(vm, &globalObject, JSSetLikePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSSetLike::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return getDOMPrototype<JSSetLike>(vm, globalObject);
+}
+
+JSValue JSSetLike::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+    return getDOMConstructor<JSSetLikeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSSetLike::destroy(JSC::JSCell* cell)
+{
+    JSSetLike* thisObject = static_cast<JSSetLike*>(cell);
+    thisObject->JSSetLike::~JSSetLike();
+}
+
+template<> inline JSSetLike* IDLAttribute<JSSetLike>::cast(JSGlobalObject& lexicalGlobalObject, EncodedJSValue thisValue)
+{
+    return jsDynamicCast<JSSetLike*>(JSC::getVM(&lexicalGlobalObject), JSValue::decode(thisValue));
+}
+
+template<> inline JSSetLike* IDLOperation<JSSetLike>::cast(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame)
+{
+    return jsDynamicCast<JSSetLike*>(JSC::getVM(&lexicalGlobalObject), callFrame.thisValue());
+}
+
+EncodedJSValue jsSetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    VM& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicCast<JSSetLikePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype))
+        return throwVMTypeError(lexicalGlobalObject, throwScope);
+    return JSValue::encode(JSSetLike::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+bool setJSSetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    VM& vm = JSC::getVM(lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicCast<JSSetLikePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype)) {
+        throwVMTypeError(lexicalGlobalObject, throwScope);
+        return false;
+    }
+    // Shadowing a built-in constructor
+    return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
+}
+
+static inline JSValue jsSetLikeSizeGetter(JSGlobalObject& lexicalGlobalObject, JSSetLike& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(lexicalGlobalObject);
+    JSValue result = toJS<IDLAny>(lexicalGlobalObject, throwScope, forwardSizeToSetLike(lexicalGlobalObject, thisObject));
+    return result;
+}
+
+EncodedJSValue jsSetLikeSize(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSSetLike>::get<jsSetLikeSizeGetter>(*lexicalGlobalObject, thisValue, "size");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionHasBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    if (UNLIKELY(callFrame->argumentCount() < 1))
+        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+    auto key = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    return JSValue::encode(toJS<IDLAny>(forwardHasToSetLike(*lexicalGlobalObject, *callFrame, *castedThis, WTFMove(key))));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionHas(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionHasBody>(*lexicalGlobalObject, *callFrame, "has");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionEntriesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardEntriesToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionEntries(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionEntriesBody>(*lexicalGlobalObject, *callFrame, "entries");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionKeysBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardKeysToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionKeys(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionKeysBody>(*lexicalGlobalObject, *callFrame, "keys");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionValuesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    return JSValue::encode(toJS<IDLAny>(forwardValuesToSetLike(*lexicalGlobalObject, *callFrame, *castedThis)));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionValues(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionValuesBody>(*lexicalGlobalObject, *callFrame, "values");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionAddBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    if (UNLIKELY(callFrame->argumentCount() < 1))
+        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+    auto key = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    return JSValue::encode(toJS<IDLAny>(forwardAddToSetLike(*lexicalGlobalObject, *callFrame, *castedThis, WTFMove(key))));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionAdd(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionAddBody>(*lexicalGlobalObject, *callFrame, "add");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionClearBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    forwardClearToSetLike(*lexicalGlobalObject, *callFrame, *castedThis);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionClear(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionClearBody>(*lexicalGlobalObject, *callFrame, "clear");
+}
+
+static inline JSC::EncodedJSValue jsSetLikePrototypeFunctionDeleteBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSSetLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    UNUSED_PARAM(callFrame);
+    UNUSED_PARAM(throwScope);
+    if (UNLIKELY(callFrame->argumentCount() < 1))
+        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+    auto key = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    return JSValue::encode(toJS<IDLAny>(forwardDeleteToSetLike(*lexicalGlobalObject, *callFrame, *castedThis, WTFMove(key))));
+}
+
+EncodedJSValue JSC_HOST_CALL jsSetLikePrototypeFunctionDelete(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+    return IDLOperation<JSSetLike>::call<jsSetLikePrototypeFunctionDeleteBody>(*lexicalGlobalObject, *callFrame, "delete");
+}
+
+void JSSetLike::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+    auto* thisObject = jsCast<JSSetLike*>(cell);
+    analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+    if (thisObject->scriptExecutionContext())
+        analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+    Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSSetLikeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
+{
+    UNUSED_PARAM(handle);
+    UNUSED_PARAM(visitor);
+    UNUSED_PARAM(reason);
+    return false;
+}
+
+void JSSetLikeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+    auto* jsSetLike = static_cast<JSSetLike*>(handle.slot()->asCell());
+    auto& world = *static_cast<DOMWrapperWorld*>(context);
+    uncacheWrapper(world, &jsSetLike->wrapped(), jsSetLike);
+}
+
+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable: 4483)
+extern "C" { extern void (*const __identifier("??_7SetLike@WebCore@@6B@")[])(); }
+#else
+extern "C" { extern void* _ZTVN7WebCore7SetLikeE[]; }
+#endif
+#endif
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<SetLike>&& impl)
+{
+
+#if ENABLE(BINDING_INTEGRITY)
+    void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
+#if PLATFORM(WIN)
+    void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SetLike@WebCore@@6B@"));
+#else
+    void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore7SetLikeE[2]);
+#endif
+
+    // If this fails SetLike does not have a vtable, so you need to add the
+    // ImplementationLacksVTable attribute to the interface definition
+    static_assert(std::is_polymorphic<SetLike>::value, "SetLike is not polymorphic");
+
+    // If you hit this assertion you either have a use after free bug, or
+    // SetLike has subclasses. If SetLike has subclasses that get passed
+    // to toJS() we currently require SetLike you to opt out of binding hardening
+    // by adding the SkipVTableValidation attribute to the interface IDL definition
+    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+    return createWrapper<SetLike>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, SetLike& impl)
+{
+    return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+SetLike* JSSetLike::toWrapped(JSC::VM& vm, JSC::JSValue value)
+{
+    if (auto* wrapper = jsDynamicCast<JSSetLike*>(vm, value))
+        return &wrapper->wrapped();
+    return nullptr;
+}
+
+}
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSSetLike.h b/Source/WebCore/bindings/scripts/test/JS/JSSetLike.h
new file mode 100644 (file)
index 0000000..0b2ff45
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "SetLike.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSSetLike : public JSDOMWrapper<SetLike> {
+public:
+    using Base = JSDOMWrapper<SetLike>;
+    static JSSetLike* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<SetLike>&& impl)
+    {
+        JSSetLike* ptr = new (NotNull, JSC::allocateCell<JSSetLike>(globalObject->vm().heap)) JSSetLike(structure, *globalObject, WTFMove(impl));
+        ptr->finishCreation(globalObject->vm());
+        return ptr;
+    }
+
+    static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+    static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+    static SetLike* toWrapped(JSC::VM&, JSC::JSValue);
+    static void destroy(JSC::JSCell*);
+
+    DECLARE_INFO;
+
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+    static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+protected:
+    JSSetLike(JSC::Structure*, JSDOMGlobalObject&, Ref<SetLike>&&);
+
+    void finishCreation(JSC::VM&);
+};
+
+class JSSetLikeOwner : public JSC::WeakHandleOwner {
+public:
+    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&, const char**);
+    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, SetLike*)
+{
+    static NeverDestroyed<JSSetLikeOwner> owner;
+    return &owner.get();
+}
+
+inline void* wrapperKey(SetLike* wrappableObject)
+{
+    return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, SetLike&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, SetLike* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<SetLike>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<SetLike>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<SetLike> {
+    using WrapperClass = JSSetLike;
+    using ToWrappedReturnType = SetLike*;
+};
+
+} // namespace WebCore
index f5acb1a..a1345e7 100644 (file)
 #include "JSTestOverrideBuiltins.h"
 #include "JSTestPluginInterface.h"
 #include "JSTestReadOnlyMapLike.h"
+#include "JSTestReadOnlySetLike.h"
 #include "JSTestReportExtraMemoryCost.h"
 #include "JSTestSerialization.h"
 #include "JSTestSerializationIndirectInheritance.h"
 #include "JSTestSerializationInherit.h"
 #include "JSTestSerializationInheritFinal.h"
+#include "JSTestSetLike.h"
 #include "JSTestStringifier.h"
 #include "JSTestStringifierAnonymousOperation.h"
 #include "JSTestStringifierNamedOperation.h"
@@ -256,6 +258,8 @@ JSC::EncodedJSValue jsTestGlobalObjectTestPluginInterfaceConstructor(JSC::JSGlob
 bool setJSTestGlobalObjectTestPluginInterfaceConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestGlobalObjectTestReadOnlyMapLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectTestReadOnlyMapLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestGlobalObjectTestReadOnlySetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestGlobalObjectTestReadOnlySetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestGlobalObjectTestReportExtraMemoryCostConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectTestReportExtraMemoryCostConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestGlobalObjectTestSerializationConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -270,6 +274,8 @@ bool setJSTestGlobalObjectTestSerializationInheritFinalConstructor(JSC::JSGlobal
 JSC::EncodedJSValue jsTestGlobalObjectTestSerializedScriptValueInterfaceConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectTestSerializedScriptValueInterfaceConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 #endif
+JSC::EncodedJSValue jsTestGlobalObjectTestSetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestGlobalObjectTestSetLikeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestGlobalObjectTestStringifierConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectTestStringifierConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestGlobalObjectTestStringifierAnonymousOperationConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -305,7 +311,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 50, -1 },
+    { 51, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -313,7 +319,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 61, -1 },
+    { 63, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -333,7 +339,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 64, -1 },
+    { 66, -1 },
     { 9, 258 },
     { -1, -1 },
     { -1, -1 },
@@ -377,7 +383,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { -1, -1 },
+    { 57, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -386,7 +392,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { 20, 256 },
     { -1, -1 },
-    { 56, -1 },
+    { 58, -1 },
     { 15, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -417,7 +423,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 54, -1 },
+    { 55, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -432,7 +438,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { -1, -1 },
+    { 50, -1 },
     { -1, -1 },
     { 10, -1 },
     { -1, -1 },
@@ -450,7 +456,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 62, -1 },
+    { 64, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -467,7 +473,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { 12, 257 },
     { -1, -1 },
-    { 57, -1 },
+    { 59, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -480,7 +486,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { 13, -1 },
     { -1, -1 },
-    { 60, -1 },
+    { 62, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -499,7 +505,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
-    { 52, -1 },
+    { 53, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
@@ -524,7 +530,7 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { 46, -1 },
     { 7, 260 },
     { -1, -1 },
-    { 58, -1 },
+    { 60, -1 },
     { -1, -1 },
     { 44, -1 },
     { -1, -1 },
@@ -553,11 +559,11 @@ static const struct CompactHashIndex JSTestGlobalObjectTableIndex[266] = {
     { 36, -1 },
     { 38, -1 },
     { 40, -1 },
-    { 51, -1 },
-    { 53, -1 },
-    { 55, -1 },
-    { 59, -1 },
-    { 63, -1 },
+    { 52, -1 },
+    { 54, -1 },
+    { 56, -1 },
+    { 61, -1 },
+    { 65, -1 },
 };
 
 
@@ -625,6 +631,7 @@ static const HashTableValue JSTestGlobalObjectTableValues[] =
     { "TestOverrideBuiltins", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestOverrideBuiltinsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestOverrideBuiltinsConstructor) } },
     { "TestPluginInterface", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestPluginInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestPluginInterfaceConstructor) } },
     { "TestReadOnlyMapLike", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestReadOnlyMapLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestReadOnlyMapLikeConstructor) } },
+    { "TestReadOnlySetLike", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestReadOnlySetLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestReadOnlySetLikeConstructor) } },
     { "TestReportExtraMemoryCost", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestReportExtraMemoryCostConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestReportExtraMemoryCostConstructor) } },
     { "TestSerialization", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestSerializationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestSerializationConstructor) } },
     { "TestSerializationIndirectInheritance", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestSerializationIndirectInheritanceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestSerializationIndirectInheritanceConstructor) } },
@@ -635,6 +642,7 @@ static const HashTableValue JSTestGlobalObjectTableValues[] =
 #else
     { 0, 0, NoIntrinsic, { 0, 0 } },
 #endif
+    { "TestSetLike", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestSetLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestSetLikeConstructor) } },
     { "TestStringifier", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestStringifierConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestStringifierConstructor) } },
     { "TestStringifierAnonymousOperation", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestStringifierAnonymousOperationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestStringifierAnonymousOperationConstructor) } },
     { "TestStringifierNamedOperation", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectTestStringifierNamedOperationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectTestStringifierNamedOperationConstructor) } },
@@ -646,7 +654,7 @@ static const HashTableValue JSTestGlobalObjectTableValues[] =
     { "regularOperation", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestGlobalObjectInstanceFunctionRegularOperation), (intptr_t) (1) } },
 };
 
-static const HashTable JSTestGlobalObjectTable = { 65, 255, true, JSTestGlobalObject::info(), JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
+static const HashTable JSTestGlobalObjectTable = { 67, 255, true, JSTestGlobalObject::info(), JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
 /* Hash table for constructor */
 
 static const HashTableValue JSTestGlobalObjectConstructorTableValues[] =
@@ -2142,6 +2150,31 @@ bool setJSTestGlobalObjectTestReadOnlyMapLikeConstructor(JSGlobalObject* lexical
     return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectTestReadOnlyMapLikeConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestReadOnlyMapLike");
 }
 
+static inline JSValue jsTestGlobalObjectTestReadOnlySetLikeConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(lexicalGlobalObject);
+    return JSTestReadOnlySetLike::getConstructor(JSC::getVM(&lexicalGlobalObject), thisObject.globalObject());
+}
+
+EncodedJSValue jsTestGlobalObjectTestReadOnlySetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectTestReadOnlySetLikeConstructorGetter>(*lexicalGlobalObject, thisValue, "TestReadOnlySetLike");
+}
+
+static inline bool setJSTestGlobalObjectTestReadOnlySetLikeConstructorSetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    VM& vm = throwScope.vm();
+    // Shadowing a built-in constructor.
+    return thisObject.putDirect(vm, Identifier::fromString(vm, reinterpret_cast<const LChar*>("TestReadOnlySetLike"), strlen("TestReadOnlySetLike")), value);
+}
+
+bool setJSTestGlobalObjectTestReadOnlySetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectTestReadOnlySetLikeConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestReadOnlySetLike");
+}
+
 static inline JSValue jsTestGlobalObjectTestReportExtraMemoryCostConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);
@@ -2298,6 +2331,31 @@ bool setJSTestGlobalObjectTestSerializedScriptValueInterfaceConstructor(JSGlobal
 
 #endif
 
+static inline JSValue jsTestGlobalObjectTestSetLikeConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(lexicalGlobalObject);
+    return JSTestSetLike::getConstructor(JSC::getVM(&lexicalGlobalObject), thisObject.globalObject());
+}
+
+EncodedJSValue jsTestGlobalObjectTestSetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectTestSetLikeConstructorGetter>(*lexicalGlobalObject, thisValue, "TestSetLike");
+}
+
+static inline bool setJSTestGlobalObjectTestSetLikeConstructorSetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    VM& vm = throwScope.vm();
+    // Shadowing a built-in constructor.
+    return thisObject.putDirect(vm, Identifier::fromString(vm, reinterpret_cast<const LChar*>("TestSetLike"), strlen("TestSetLike")), value);
+}
+
+bool setJSTestGlobalObjectTestSetLikeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectTestSetLikeConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestSetLike");
+}
+
 static inline JSValue jsTestGlobalObjectTestStringifierConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);
diff --git a/Source/WebCore/bindings/scripts/test/TestReadOnlySetLike.idl b/Source/WebCore/bindings/scripts/test/TestReadOnlySetLike.idl
new file mode 100644 (file)
index 0000000..628e1d9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+interface ReadOnlySetLike {
+    readonly setlike<DOMString>;
+};
diff --git a/Source/WebCore/bindings/scripts/test/TestSetLike.idl b/Source/WebCore/bindings/scripts/test/TestSetLike.idl
new file mode 100644 (file)
index 0000000..7075598
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+interface SetLike {
+    setlike<DOMString>;
+};
index 1e3d8f4..f623afd 100644 (file)
 #include "InstrumentingAgents.h"
 #include "IntRect.h"
 #include "InternalSettings.h"
+#include "InternalsSetLike.h"
 #include "JSDOMPromiseDeferred.h"
 #include "JSImageData.h"
 #include "LegacySchemeRegistry.h"
@@ -5292,4 +5293,9 @@ int Internals::processIdentifier() const
     return getCurrentProcessID();
 }
 
+Ref<InternalsSetLike> Internals::createInternalsSetLike()
+{
+    return InternalsSetLike::create();
+}
+
 } // namespace WebCore
index 9c7d253..78b9b28 100644 (file)
@@ -76,6 +76,7 @@ class HTMLVideoElement;
 class ImageData;
 class InspectorStubFrontend;
 class InternalSettings;
+class InternalsSetLike;
 class MallocStatistics;
 class MediaSession;
 class MediaStream;
@@ -905,6 +906,8 @@ public:
 
     int processIdentifier() const;
 
+    Ref<InternalsSetLike> createInternalsSetLike();
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;
index 0b7252d..936c2a7 100644 (file)
@@ -815,4 +815,6 @@ enum CompositingPolicy {
     [Conditional=WEB_AUTHN] void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration configuration);
 
     [Conditional=PICTURE_IN_PICTURE_API] void setPictureInPictureAPITestEnabled(HTMLVideoElement videoElement, boolean enabled);
+
+    InternalsSetLike createInternalsSetLike();
 };
diff --git a/Source/WebCore/testing/InternalsSetLike.cpp b/Source/WebCore/testing/InternalsSetLike.cpp
new file mode 100644 (file)
index 0000000..45b5679
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InternalsSetLike.h"
+
+#include "IDLTypes.h"
+#include "JSDOMSetLike.h"
+
+namespace WebCore {
+
+InternalsSetLike::InternalsSetLike()
+{
+    m_items.append("init"_s);
+}
+
+void InternalsSetLike::initializeSetLike(DOMSetAdapter& set)
+{
+    set.add<IDLDOMString>(m_items[0]);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/testing/InternalsSetLike.h b/Source/WebCore/testing/InternalsSetLike.h
new file mode 100644 (file)
index 0000000..a9dc958
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class DOMSetAdapter;
+
+class InternalsSetLike : public RefCounted<InternalsSetLike> {
+public:
+    static Ref<InternalsSetLike> create() { return adoptRef(*new InternalsSetLike); }
+
+    void clearFromSetLike() { m_items.clear(); }
+    bool addToSetLike(const String&);
+    bool removeFromSetLike(const String& item) { return m_items.removeFirst(item); }
+    void initializeSetLike(DOMSetAdapter&);
+
+    const Vector<String>& items() const { return m_items; }
+
+private:
+    InternalsSetLike();
+    Vector<String> m_items;
+};
+
+inline bool InternalsSetLike::addToSetLike(const String& value)
+{
+    bool hasValue = removeFromSetLike(value);
+    m_items.append(value);
+    return !hasValue;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/testing/InternalsSetLike.idl b/Source/WebCore/testing/InternalsSetLike.idl
new file mode 100644 (file)
index 0000000..627778d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    NoInterfaceObject,
+    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
+    SkipVTableValidation,
+] interface InternalsSetLike
+{
+    setlike<DOMString>;
+
+    sequence<DOMString> items();
+};