diff options
author | 2022-11-07 00:53:24 -0800 | |
---|---|---|
committer | 2022-11-07 00:53:24 -0800 | |
commit | 71d0e14210fb0fa1cd19c650dfd45e25dcafab98 (patch) | |
tree | 75e935f6e9859d058005672c2529bc9777245af8 | |
parent | d925367cae1f22ad85a29ae02456286d9ccc859a (diff) | |
download | bun-71d0e14210fb0fa1cd19c650dfd45e25dcafab98.tar.gz bun-71d0e14210fb0fa1cd19c650dfd45e25dcafab98.tar.zst bun-71d0e14210fb0fa1cd19c650dfd45e25dcafab98.zip |
[bun:test] Implement `expect` in faster Zig bindings
-rw-r--r-- | src/bun.js/base.zig | 3 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h | 3 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h | 3 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h | 6 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h | 41 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses.cpp | 4608 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses.h | 1292 | ||||
-rw-r--r-- | src/bun.js/bindings/generated_classes.zig | 252 | ||||
-rw-r--r-- | src/bun.js/bindings/generated_classes_list.zig | 1 | ||||
-rw-r--r-- | src/bun.js/test/jest.classes.ts | 186 | ||||
-rw-r--r-- | src/bun.js/test/jest.zig | 521 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 1 |
12 files changed, 4175 insertions, 2742 deletions
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 99f7ce779..225536591 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -2802,7 +2802,6 @@ const ModuleNamespace = @import("../js_ast.zig").Macro.ModuleNamespace; const Expect = Test.Expect; const DescribeScope = Test.DescribeScope; const TestScope = Test.TestScope; -const ExpectPrototype = Test.ExpectPrototype; const NodeFS = JSC.Node.NodeFS; const DirEnt = JSC.Node.DirEnt; const Stats = JSC.Node.Stats; @@ -2848,8 +2847,6 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{ DocType, Element, EndTag, - Expect, - ExpectPrototype, FetchEvent, HTMLRewriter, JSNode, diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h index 3ec74c09c..368708fe9 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h @@ -11,7 +11,8 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512Constructor;std: std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA384Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocket; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocketConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoder; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocketConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoder; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponseConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlob; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h index 11c6780ac..752456c7b 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h @@ -11,7 +11,8 @@ std::unique_ptr<IsoSubspace> m_subspaceForSHA512Constructor;std::unique_ptr<IsoS std::unique_ptr<IsoSubspace> m_subspaceForSHA384Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA256; std::unique_ptr<IsoSubspace> m_subspaceForSHA256Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256; std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256Constructor;std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocket; -std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocketConstructor;std::unique_ptr<IsoSubspace> m_subspaceForTextDecoder; +std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocketConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpect; +std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoSubspace> m_subspaceForTextDecoder; std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest; std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResponse; std::unique_ptr<IsoSubspace> m_subspaceForResponseConstructor;std::unique_ptr<IsoSubspace> m_subspaceForBlob; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h index 0ca7db3db..ff158b59e 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h @@ -76,6 +76,12 @@ JSC::Structure* JSServerWebSocketStructure() { return m_JSServerWebSocket.getIni JSC::LazyClassStructure m_JSServerWebSocket; bool hasJSServerWebSocketSetterValue { false }; mutable JSC::WriteBarrier<JSC::Unknown> m_JSServerWebSocketSetterValue; +JSC::Structure* JSExpectStructure() { return m_JSExpect.getInitializedOnMainThread(this); } + JSC::JSObject* JSExpectConstructor() { return m_JSExpect.constructorInitializedOnMainThread(this); } + JSC::JSValue JSExpectPrototype() { return m_JSExpect.prototypeInitializedOnMainThread(this); } + JSC::LazyClassStructure m_JSExpect; + bool hasJSExpectSetterValue { false }; + mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectSetterValue; JSC::Structure* JSTextDecoderStructure() { return m_JSTextDecoder.getInitializedOnMainThread(this); } JSC::JSObject* JSTextDecoderConstructor() { return m_JSTextDecoder.constructorInitializedOnMainThread(this); } JSC::JSValue JSTextDecoderPrototype() { return m_JSTextDecoder.prototypeInitializedOnMainThread(this); } diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h index b1144a1e8..b04e10089 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h @@ -3,103 +3,109 @@ void GlobalObject::initGeneratedLazyClasses() { [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSTCPSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSTCPSocket::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSTCPSocketConstructor::create(init.vm, init.global, WebCore::JSTCPSocketConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSTCPSocketPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSTCPSocket::createConstructor(init.vm, init.global, init.prototype)); }); m_JSTLSSocket.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSTLSSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSTLSSocket::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSTLSSocketConstructor::create(init.vm, init.global, WebCore::JSTLSSocketConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSTLSSocketPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSTLSSocket::createConstructor(init.vm, init.global, init.prototype)); }); m_JSListener.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSListener::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSListener::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSListenerConstructor::create(init.vm, init.global, WebCore::JSListenerConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSListenerPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSListener::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSubprocess.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSubprocess::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSubprocess::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSubprocessConstructor::create(init.vm, init.global, WebCore::JSSubprocessConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSubprocessPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSSubprocess::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA1.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA1::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA1::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA1Constructor::create(init.vm, init.global, WebCore::JSSHA1Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA1Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA1::createConstructor(init.vm, init.global, init.prototype)); }); m_JSMD5.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSMD5::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSMD5::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSMD5Constructor::create(init.vm, init.global, WebCore::JSMD5Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSMD5Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSMD5::createConstructor(init.vm, init.global, init.prototype)); }); m_JSMD4.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSMD4::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSMD4::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSMD4Constructor::create(init.vm, init.global, WebCore::JSMD4Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSMD4Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSMD4::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA224.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA224::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA224::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA224Constructor::create(init.vm, init.global, WebCore::JSSHA224Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA224Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA224::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA512.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA512::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA512::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA512Constructor::create(init.vm, init.global, WebCore::JSSHA512Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA512Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA512::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA384.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA384::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA384::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA384Constructor::create(init.vm, init.global, WebCore::JSSHA384Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA384Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA384::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA256.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA256::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA256Constructor::create(init.vm, init.global, WebCore::JSSHA256Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA256Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA256::createConstructor(init.vm, init.global, init.prototype)); }); m_JSSHA512_256.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSSHA512_256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSSHA512_256::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA512_256Constructor::create(init.vm, init.global, WebCore::JSSHA512_256Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSSHA512_256Prototype*>(init.prototype))); + init.setConstructor(WebCore::JSSHA512_256::createConstructor(init.vm, init.global, init.prototype)); }); m_JSServerWebSocket.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSServerWebSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSServerWebSocket::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSServerWebSocketConstructor::create(init.vm, init.global, WebCore::JSServerWebSocketConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSServerWebSocketPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSServerWebSocket::createConstructor(init.vm, init.global, init.prototype)); + }); + m_JSExpect.initLater( + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpect::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpect::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSExpect::createConstructor(init.vm, init.global, init.prototype)); }); m_JSTextDecoder.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSTextDecoder::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSTextDecoder::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSTextDecoderConstructor::create(init.vm, init.global, WebCore::JSTextDecoderConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSTextDecoderPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSTextDecoder::createConstructor(init.vm, init.global, init.prototype)); }); m_JSRequest.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSRequest::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSRequest::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSRequestConstructor::create(init.vm, init.global, WebCore::JSRequestConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSRequestPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSRequest::createConstructor(init.vm, init.global, init.prototype)); }); m_JSResponse.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSResponse::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSResponse::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSResponseConstructor::create(init.vm, init.global, WebCore::JSResponseConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSResponsePrototype*>(init.prototype))); + init.setConstructor(WebCore::JSResponse::createConstructor(init.vm, init.global, init.prototype)); }); m_JSBlob.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSBlob::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); init.setStructure(WebCore::JSBlob::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSBlobConstructor::create(init.vm, init.global, WebCore::JSBlobConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<WebCore::JSBlobPrototype*>(init.prototype))); + init.setConstructor(WebCore::JSBlob::createConstructor(init.vm, init.global, init.prototype)); }); } template<typename Visitor> @@ -118,6 +124,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& thisObject->m_JSSHA256.visit(visitor); visitor.append(thisObject->m_JSSHA256SetterValue); thisObject->m_JSSHA512_256.visit(visitor); visitor.append(thisObject->m_JSSHA512_256SetterValue); thisObject->m_JSServerWebSocket.visit(visitor); visitor.append(thisObject->m_JSServerWebSocketSetterValue); + thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue); thisObject->m_JSTextDecoder.visit(visitor); visitor.append(thisObject->m_JSTextDecoderSetterValue); thisObject->m_JSRequest.visit(visitor); visitor.append(thisObject->m_JSRequestSetterValue); thisObject->m_JSResponse.visit(visitor); visitor.append(thisObject->m_JSResponseSetterValue); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index 72064b583..63df5bffe 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -3,6 +3,12 @@ // Generated by make codegen #include "root.h" +#include <JavaScriptCore/JSFunction.h> +#include <JavaScriptCore/InternalFunction.h> +#include <JavaScriptCore/LazyClassStructure.h> +#include <JavaScriptCore/LazyClassStructureInlines.h> +#include <JavaScriptCore/FunctionPrototype.h> + #include "ZigGlobalObject.h" #include <JavaScriptCore/DOMJITAbstractHeap.h> @@ -23,10 +29,80 @@ namespace WebCore { using namespace JSC; using namespace Zig; +class JSTCPSocketPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSTCPSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSTCPSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketPrototype>(vm)) JSTCPSocketPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSTCPSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSTCPSocketConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSTCPSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTCPSocketPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSTCPSocketConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForTCPSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTCPSocketConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForTCPSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForTCPSocketConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTCPSocketPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSTCPSocketConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTCPSocketPrototype* prototype); + }; + + extern "C" void* TCPSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsTCPSocketConstructor); extern "C" void TCPSocketClass__finalize(void*); + extern "C" JSC::EncodedJSValue TCPSocketPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__dataGetterWrap); @@ -142,20 +218,20 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__dataGetterWrap, (JSGlobalObject * l } -extern "C" void TCPSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void TCPSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); + thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue TCPSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); - thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue TCPSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_data.get()); -} - - + return JSValue::encode(thisObject->m_data.get()); + } + + JSC_DEFINE_CUSTOM_SETTER(TCPSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName)) { @@ -169,39 +245,39 @@ JSC_DEFINE_CUSTOM_SETTER(TCPSocketPrototype__dataSetterWrap, (JSGlobalObject * l } -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TCPSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return TCPSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TCPSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TCPSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -242,39 +318,39 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap, (JSGlobalObje } -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TCPSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return TCPSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TCPSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TCPSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__remoteAddressGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -296,88 +372,88 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__remoteAddressGetterWrap, (JSGlobalO } -extern "C" void TCPSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void TCPSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); + thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue TCPSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); - thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_remoteAddress.get()); + } + + -extern "C" EncodedJSValue TCPSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_remoteAddress.get()); -} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return TCPSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return TCPSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TCPSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return TCPSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); + JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TCPSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return TCPSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSTCPSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -394,8 +470,12 @@ void JSTCPSocketConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalO ASSERT(inherits(info())); } +JSTCPSocketConstructor::JSTCPSocketConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSTCPSocketConstructor* JSTCPSocketConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTCPSocketPrototype* prototype) { - JSTCPSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketConstructor>(vm)) JSTCPSocketConstructor(vm, structure, construct); + JSTCPSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketConstructor>(vm)) JSTCPSocketConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -515,6 +595,11 @@ void JSTCPSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSTCPSocket::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSTCPSocketConstructor::create(vm, globalObject, WebCore::JSTCPSocketConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTCPSocketPrototype*>(prototype)); +} + JSObject* JSTCPSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSTCPSocketPrototype::create(vm, globalObject, JSTCPSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -532,10 +617,80 @@ void JSTCPSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_remoteAddress); } -DEFINE_VISIT_CHILDREN(JSTCPSocket);extern "C" void* TLSSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSTCPSocket);class JSTLSSocketPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSTLSSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSTLSSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketPrototype>(vm)) JSTLSSocketPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSTLSSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSTLSSocketConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSTLSSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTLSSocketPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSTLSSocketConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForTLSSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTLSSocketConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForTLSSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForTLSSocketConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTLSSocketPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSTLSSocketConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTLSSocketPrototype* prototype); + }; + + +extern "C" void* TLSSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsTLSSocketConstructor); extern "C" void TLSSocketClass__finalize(void*); + extern "C" JSC::EncodedJSValue TLSSocketPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__dataGetterWrap); @@ -651,20 +806,20 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__dataGetterWrap, (JSGlobalObject * l } -extern "C" void TLSSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void TLSSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); + thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue TLSSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); - thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue TLSSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_data.get()); -} - - + return JSValue::encode(thisObject->m_data.get()); + } + + JSC_DEFINE_CUSTOM_SETTER(TLSSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName)) { @@ -678,39 +833,39 @@ JSC_DEFINE_CUSTOM_SETTER(TLSSocketPrototype__dataSetterWrap, (JSGlobalObject * l } -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TLSSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return TLSSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TLSSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TLSSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -751,39 +906,39 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap, (JSGlobalObje } -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TLSSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return TLSSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TLSSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TLSSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__remoteAddressGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -805,88 +960,88 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__remoteAddressGetterWrap, (JSGlobalO } -extern "C" void TLSSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void TLSSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); + thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue TLSSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); - thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_remoteAddress.get()); + } + + -extern "C" EncodedJSValue TLSSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_remoteAddress.get()); -} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return TLSSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return TLSSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TLSSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return TLSSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); + JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TLSSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return TLSSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSTLSSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -903,8 +1058,12 @@ void JSTLSSocketConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalO ASSERT(inherits(info())); } +JSTLSSocketConstructor::JSTLSSocketConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSTLSSocketConstructor* JSTLSSocketConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTLSSocketPrototype* prototype) { - JSTLSSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketConstructor>(vm)) JSTLSSocketConstructor(vm, structure, construct); + JSTLSSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketConstructor>(vm)) JSTLSSocketConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -1024,6 +1183,11 @@ void JSTLSSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSTLSSocket::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSTLSSocketConstructor::create(vm, globalObject, WebCore::JSTLSSocketConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTLSSocketPrototype*>(prototype)); +} + JSObject* JSTLSSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSTLSSocketPrototype::create(vm, globalObject, JSTLSSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -1041,10 +1205,80 @@ void JSTLSSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_remoteAddress); } -DEFINE_VISIT_CHILDREN(JSTLSSocket);extern "C" void* ListenerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSTLSSocket);class JSListenerPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSListenerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSListenerPrototype* ptr = new (NotNull, JSC::allocateCell<JSListenerPrototype>(vm)) JSListenerPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSListenerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSListenerConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSListenerConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSListenerPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSListenerConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForListenerConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForListenerConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForListenerConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForListenerConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSListenerPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSListenerConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSListenerPrototype* prototype); + }; + + +extern "C" void* ListenerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsListenerConstructor); extern "C" void ListenerClass__finalize(void*); + extern "C" JSC::EncodedJSValue ListenerPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(ListenerPrototype__dataGetterWrap); @@ -1160,20 +1394,20 @@ JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__hostnameGetterWrap, (JSGlobalObject } -extern "C" void ListenerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ListenerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); + thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ListenerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); - thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue ListenerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_hostname.get()); -} - - + return JSValue::encode(thisObject->m_hostname.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1188,56 +1422,56 @@ JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__portGetterWrap, (JSGlobalObject * le } -JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ListenerPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return ListenerPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ListenerPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ListenerPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ListenerPrototype__stop(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ListenerPrototype__stop(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__unixGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1259,37 +1493,37 @@ JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__unixGetterWrap, (JSGlobalObject * le } -extern "C" void ListenerPrototype__unixSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ListenerPrototype__unixSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); + thisObject->m_unix.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ListenerPrototype__unixGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); - thisObject->m_unix.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_unix.get()); + } + + -extern "C" EncodedJSValue ListenerPrototype__unixGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_unix.get()); -} + JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ListenerPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ListenerPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - void JSListenerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -1306,8 +1540,12 @@ void JSListenerConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalOb ASSERT(inherits(info())); } +JSListenerConstructor::JSListenerConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSListenerConstructor* JSListenerConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSListenerPrototype* prototype) { - JSListenerConstructor* ptr = new (NotNull, JSC::allocateCell<JSListenerConstructor>(vm)) JSListenerConstructor(vm, structure, construct); + JSListenerConstructor* ptr = new (NotNull, JSC::allocateCell<JSListenerConstructor>(vm)) JSListenerConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -1427,6 +1665,11 @@ void JSListener::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSListener::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSListenerConstructor::create(vm, globalObject, WebCore::JSListenerConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSListenerPrototype*>(prototype)); +} + JSObject* JSListener::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSListenerPrototype::create(vm, globalObject, JSListenerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -1444,10 +1687,80 @@ void JSListener::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_unix); } -DEFINE_VISIT_CHILDREN(JSListener);extern "C" void* SubprocessClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSListener);class JSSubprocessPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSubprocessPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSubprocessPrototype* ptr = new (NotNull, JSC::allocateCell<JSSubprocessPrototype>(vm)) JSSubprocessPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSubprocessPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSubprocessConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSubprocessConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSubprocessPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSubprocessConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSubprocessConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSubprocessConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSubprocessConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSubprocessConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSubprocessPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSubprocessConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSubprocessPrototype* prototype); + }; + + +extern "C" void* SubprocessClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSubprocessConstructor); extern "C" void SubprocessClass__finalize(void*); + extern "C" JSC::EncodedJSValue SubprocessPrototype__getExitCode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__exitCodeGetterWrap); @@ -1560,22 +1873,22 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitedGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SubprocessPrototype__kill(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SubprocessPrototype__kill(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__killedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1623,37 +1936,37 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__readableGetterWrap, (JSGlobalObjec } -extern "C" void SubprocessPrototype__readableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void SubprocessPrototype__readableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); + thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue SubprocessPrototype__readableGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_stdout.get()); + } + + -extern "C" EncodedJSValue SubprocessPrototype__readableGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_stdout.get()); -} + JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return SubprocessPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return SubprocessPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stderrGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1675,20 +1988,20 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stderrGetterWrap, (JSGlobalObject } -extern "C" void SubprocessPrototype__stderrSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void SubprocessPrototype__stderrSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); + thisObject->m_stderr.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue SubprocessPrototype__stderrGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - thisObject->m_stderr.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue SubprocessPrototype__stderrGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_stderr.get()); -} - - + return JSValue::encode(thisObject->m_stderr.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdinGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1710,20 +2023,20 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdinGetterWrap, (JSGlobalObject * } -extern "C" void SubprocessPrototype__stdinSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void SubprocessPrototype__stdinSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); + thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue SubprocessPrototype__stdinGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue SubprocessPrototype__stdinGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_stdin.get()); -} - - + return JSValue::encode(thisObject->m_stdin.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdoutGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1745,37 +2058,37 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdoutGetterWrap, (JSGlobalObject } -extern "C" void SubprocessPrototype__stdoutSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void SubprocessPrototype__stdoutSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); + thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue SubprocessPrototype__stdoutGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_stdout.get()); + } + + -extern "C" EncodedJSValue SubprocessPrototype__stdoutGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_stdout.get()); -} + JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return SubprocessPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return SubprocessPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__writableGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -1797,20 +2110,20 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__writableGetterWrap, (JSGlobalObjec } -extern "C" void SubprocessPrototype__writableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void SubprocessPrototype__writableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); + thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue SubprocessPrototype__writableGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue SubprocessPrototype__writableGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_stdin.get()); -} - - + return JSValue::encode(thisObject->m_stdin.get()); + } + + void JSSubprocessPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -1827,8 +2140,12 @@ void JSSubprocessConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* global ASSERT(inherits(info())); } +JSSubprocessConstructor::JSSubprocessConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSubprocessConstructor* JSSubprocessConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSubprocessPrototype* prototype) { - JSSubprocessConstructor* ptr = new (NotNull, JSC::allocateCell<JSSubprocessConstructor>(vm)) JSSubprocessConstructor(vm, structure, construct); + JSSubprocessConstructor* ptr = new (NotNull, JSC::allocateCell<JSSubprocessConstructor>(vm)) JSSubprocessConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -1948,6 +2265,11 @@ void JSSubprocess::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSubprocess::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSubprocessConstructor::create(vm, globalObject, WebCore::JSSubprocessConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSubprocessPrototype*>(prototype)); +} + JSObject* JSSubprocess::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSubprocessPrototype::create(vm, globalObject, JSSubprocessPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -1966,10 +2288,80 @@ void JSSubprocess::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_stdout); } -DEFINE_VISIT_CHILDREN(JSSubprocess);extern "C" void* SHA1Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSSubprocess);class JSSHA1Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA1Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA1Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA1Prototype>(vm)) JSSHA1Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA1Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA1Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA1Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA1Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA1Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA1Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype); + }; + + +extern "C" void* SHA1Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA1Constructor); extern "C" void SHA1Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA1Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA1Prototype__byteLengthGetterWrap); @@ -2024,39 +2416,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA1Prototype__byteLengthGetterWrap, (JSGlobalObject * } -JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA1Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA1Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA1Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SHA1Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA1Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -2082,8 +2474,12 @@ void JSSHA1Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject ASSERT(inherits(info())); } +JSSHA1Constructor::JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA1Constructor* JSSHA1Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype) { - JSSHA1Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA1Constructor>(vm)) JSSHA1Constructor(vm, structure, construct); + JSSHA1Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA1Constructor>(vm)) JSSHA1Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -2203,13 +2599,88 @@ void JSSHA1::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA1::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA1Constructor::create(vm, globalObject, WebCore::JSSHA1Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA1Prototype*>(prototype)); +} + JSObject* JSSHA1::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA1Prototype::create(vm, globalObject, JSSHA1Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* MD5Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSMD5Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSMD5Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSMD5Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD5Prototype>(vm)) JSMD5Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSMD5Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSMD5Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSMD5Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSMD5Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForMD5Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForMD5Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype); + }; + + +extern "C" void* MD5Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsMD5Constructor); extern "C" void MD5Class__finalize(void*); + extern "C" JSC::EncodedJSValue MD5Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(MD5Prototype__byteLengthGetterWrap); @@ -2264,39 +2735,39 @@ JSC_DEFINE_CUSTOM_GETTER(MD5Prototype__byteLengthGetterWrap, (JSGlobalObject * l } -JSC_DEFINE_HOST_FUNCTION(MD5Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(MD5Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return MD5Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(MD5Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return MD5Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(MD5Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return MD5Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return MD5Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSMD5Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -2322,8 +2793,12 @@ void JSMD5Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, ASSERT(inherits(info())); } +JSMD5Constructor::JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSMD5Constructor* JSMD5Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype) { - JSMD5Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD5Constructor>(vm)) JSMD5Constructor(vm, structure, construct); + JSMD5Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD5Constructor>(vm)) JSMD5Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -2443,13 +2918,88 @@ void JSMD5::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSMD5::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSMD5Constructor::create(vm, globalObject, WebCore::JSMD5Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD5Prototype*>(prototype)); +} + JSObject* JSMD5::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSMD5Prototype::create(vm, globalObject, JSMD5Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* MD4Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSMD4Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSMD4Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSMD4Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD4Prototype>(vm)) JSMD4Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSMD4Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSMD4Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSMD4Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSMD4Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForMD4Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForMD4Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype); + }; + + +extern "C" void* MD4Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsMD4Constructor); extern "C" void MD4Class__finalize(void*); + extern "C" JSC::EncodedJSValue MD4Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(MD4Prototype__byteLengthGetterWrap); @@ -2504,39 +3054,39 @@ JSC_DEFINE_CUSTOM_GETTER(MD4Prototype__byteLengthGetterWrap, (JSGlobalObject * l } -JSC_DEFINE_HOST_FUNCTION(MD4Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(MD4Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return MD4Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(MD4Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return MD4Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(MD4Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return MD4Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return MD4Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSMD4Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -2562,8 +3112,12 @@ void JSMD4Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, ASSERT(inherits(info())); } +JSMD4Constructor::JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSMD4Constructor* JSMD4Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype) { - JSMD4Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD4Constructor>(vm)) JSMD4Constructor(vm, structure, construct); + JSMD4Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD4Constructor>(vm)) JSMD4Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -2683,13 +3237,88 @@ void JSMD4::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSMD4::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSMD4Constructor::create(vm, globalObject, WebCore::JSMD4Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD4Prototype*>(prototype)); +} + JSObject* JSMD4::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSMD4Prototype::create(vm, globalObject, JSMD4Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* SHA224Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSSHA224Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA224Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA224Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA224Prototype>(vm)) JSSHA224Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA224Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA224Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA224Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA224Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA224Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA224Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype); + }; + + +extern "C" void* SHA224Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA224Constructor); extern "C" void SHA224Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA224Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA224Prototype__byteLengthGetterWrap); @@ -2744,39 +3373,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA224Prototype__byteLengthGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA224Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA224Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA224Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SHA224Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA224Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -2802,8 +3431,12 @@ void JSSHA224Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje ASSERT(inherits(info())); } +JSSHA224Constructor::JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA224Constructor* JSSHA224Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype) { - JSSHA224Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA224Constructor>(vm)) JSSHA224Constructor(vm, structure, construct); + JSSHA224Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA224Constructor>(vm)) JSSHA224Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -2923,13 +3556,88 @@ void JSSHA224::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA224::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA224Constructor::create(vm, globalObject, WebCore::JSSHA224Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA224Prototype*>(prototype)); +} + JSObject* JSSHA224::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA224Prototype::create(vm, globalObject, JSSHA224Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* SHA512Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSSHA512Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA512Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA512Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512Prototype>(vm)) JSSHA512Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA512Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA512Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA512Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA512Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA512Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA512Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype); + }; + + +extern "C" void* SHA512Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA512Constructor); extern "C" void SHA512Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA512Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA512Prototype__byteLengthGetterWrap); @@ -2984,39 +3692,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA512Prototype__byteLengthGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA512Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA512Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA512Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return SHA512Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA512Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -3042,8 +3750,12 @@ void JSSHA512Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje ASSERT(inherits(info())); } +JSSHA512Constructor::JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA512Constructor* JSSHA512Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype) { - JSSHA512Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512Constructor>(vm)) JSSHA512Constructor(vm, structure, construct); + JSSHA512Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512Constructor>(vm)) JSSHA512Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -3163,13 +3875,88 @@ void JSSHA512::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA512::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA512Constructor::create(vm, globalObject, WebCore::JSSHA512Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512Prototype*>(prototype)); +} + JSObject* JSSHA512::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA512Prototype::create(vm, globalObject, JSSHA512Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* SHA384Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSSHA384Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA384Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA384Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA384Prototype>(vm)) JSSHA384Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA384Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA384Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA384Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA384Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA384Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA384Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype); + }; + + +extern "C" void* SHA384Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA384Constructor); extern "C" void SHA384Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA384Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA384Prototype__byteLengthGetterWrap); @@ -3224,39 +4011,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA384Prototype__byteLengthGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA384Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA384Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA384Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SHA384Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA384Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -3282,8 +4069,12 @@ void JSSHA384Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje ASSERT(inherits(info())); } +JSSHA384Constructor::JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA384Constructor* JSSHA384Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype) { - JSSHA384Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA384Constructor>(vm)) JSSHA384Constructor(vm, structure, construct); + JSSHA384Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA384Constructor>(vm)) JSSHA384Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -3403,13 +4194,88 @@ void JSSHA384::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA384::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA384Constructor::create(vm, globalObject, WebCore::JSSHA384Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA384Prototype*>(prototype)); +} + JSObject* JSSHA384::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA384Prototype::create(vm, globalObject, JSSHA384Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* SHA256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSSHA256Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA256Prototype>(vm)) JSSHA256Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA256Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA256Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA256Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA256Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype); + }; + + +extern "C" void* SHA256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA256Constructor); extern "C" void SHA256Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA256Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA256Prototype__byteLengthGetterWrap); @@ -3464,39 +4330,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA256Prototype__byteLengthGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SHA256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -3522,8 +4388,12 @@ void JSSHA256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje ASSERT(inherits(info())); } +JSSHA256Constructor::JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA256Constructor* JSSHA256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype) { - JSSHA256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA256Constructor>(vm)) JSSHA256Constructor(vm, structure, construct); + JSSHA256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA256Constructor>(vm)) JSSHA256Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -3643,13 +4513,88 @@ void JSSHA256::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA256::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA256Constructor::create(vm, globalObject, WebCore::JSSHA256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA256Prototype*>(prototype)); +} + JSObject* JSSHA256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA256Prototype::create(vm, globalObject, JSSHA256Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* SHA512_256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSSHA512_256Prototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSSHA512_256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSSHA512_256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Prototype>(vm)) JSSHA512_256Prototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSSHA512_256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSSHA512_256Constructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSSHA512_256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSSHA512_256Constructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256Constructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForSHA512_256Constructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256Constructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype); + }; + + +extern "C" void* SHA512_256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsSHA512_256Constructor); extern "C" void SHA512_256Class__finalize(void*); + extern "C" JSC::EncodedJSValue SHA512_256Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(SHA512_256Prototype__byteLengthGetterWrap); @@ -3704,39 +4649,39 @@ JSC_DEFINE_CUSTOM_GETTER(SHA512_256Prototype__byteLengthGetterWrap, (JSGlobalObj } -JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA512_256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return SHA512_256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return SHA512_256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return SHA512_256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSSHA512_256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -3762,8 +4707,12 @@ void JSSHA512_256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* global ASSERT(inherits(info())); } +JSSHA512_256Constructor::JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSSHA512_256Constructor* JSSHA512_256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype) { - JSSHA512_256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Constructor>(vm)) JSSHA512_256Constructor(vm, structure, construct); + JSSHA512_256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Constructor>(vm)) JSSHA512_256Constructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -3883,13 +4832,88 @@ void JSSHA512_256::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSSHA512_256::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSSHA512_256Constructor::create(vm, globalObject, WebCore::JSSHA512_256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512_256Prototype*>(prototype)); +} + JSObject* JSSHA512_256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSSHA512_256Prototype::create(vm, globalObject, JSSHA512_256Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -}extern "C" void* ServerWebSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +}class JSServerWebSocketPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSServerWebSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSServerWebSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketPrototype>(vm)) JSServerWebSocketPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSServerWebSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSServerWebSocketConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSServerWebSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSServerWebSocketConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocketConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForServerWebSocketConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocketConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype); + }; + + +extern "C" void* ServerWebSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsServerWebSocketConstructor); extern "C" void ServerWebSocketClass__finalize(void*); + extern "C" JSC::EncodedJSValue ServerWebSocketPrototype__getBinaryType(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(ServerWebSocketPrototype__binaryTypeGetterWrap); @@ -4101,39 +5125,39 @@ JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__binaryTypeSetterWrap, (JSGlob } -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ServerWebSocketPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return ServerWebSocketPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ServerWebSocketPrototype__cork(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return ServerWebSocketPrototype__cork(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__dataGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -4155,20 +5179,20 @@ JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__dataGetterWrap, (JSGlobalObje } -extern "C" void ServerWebSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ServerWebSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); + thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ServerWebSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); - thisObject->m_data.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue ServerWebSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_data.get()); -} - - + return JSValue::encode(thisObject->m_data.get()); + } + + JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName)) { @@ -4182,90 +5206,90 @@ JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__dataSetterWrap, (JSGlobalObje } -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ServerWebSocketPrototype__getBufferedAmount(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return ServerWebSocketPrototype__getBufferedAmount(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ServerWebSocketPrototype__isSubscribed(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ServerWebSocketPrototype__isSubscribed(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ServerWebSocketPrototype__publish(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__publish(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return ServerWebSocketPrototype__publishBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__publishBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return ServerWebSocketPrototype__publishText(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__publishText(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -4300,105 +5324,105 @@ JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__remoteAddressGetterWrap, (JSG } -extern "C" void ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); + thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); - thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_remoteAddress.get()); + } + + -extern "C" EncodedJSValue ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_remoteAddress.get()); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ServerWebSocketPrototype__send(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ServerWebSocketPrototype__send(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__sendBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return ServerWebSocketPrototype__sendBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__sendText(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return ServerWebSocketPrototype__sendText(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ServerWebSocketPrototype__subscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - return ServerWebSocketPrototype__subscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); -JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); + JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ServerWebSocketPrototype__unsubscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return ServerWebSocketPrototype__unsubscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSServerWebSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -4415,8 +5439,12 @@ void JSServerWebSocketConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* g ASSERT(inherits(info())); } +JSServerWebSocketConstructor::JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSServerWebSocketConstructor* JSServerWebSocketConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype) { - JSServerWebSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketConstructor>(vm)) JSServerWebSocketConstructor(vm, structure, construct); + JSServerWebSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketConstructor>(vm)) JSServerWebSocketConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -4536,6 +5564,11 @@ void JSServerWebSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSServerWebSocket::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSServerWebSocketConstructor::create(vm, globalObject, WebCore::JSServerWebSocketConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSServerWebSocketPrototype*>(prototype)); +} + JSObject* JSServerWebSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSServerWebSocketPrototype::create(vm, globalObject, JSServerWebSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -4553,10 +5586,1075 @@ void JSServerWebSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_remoteAddress); } -DEFINE_VISIT_CHILDREN(JSServerWebSocket);extern "C" void* TextDecoderClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSServerWebSocket);class JSExpectPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSExpectPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSExpectPrototype* ptr = new (NotNull, JSC::allocateCell<JSExpectPrototype>(vm)) JSExpectPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSExpectPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSExpectConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSExpectConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSExpectConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForExpectConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpectConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForExpectConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForExpectConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype); + }; + + +extern "C" void* ExpectClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +JSC_DECLARE_CUSTOM_GETTER(jsExpectConstructor); +extern "C" void ExpectClass__finalize(void*); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__call); + +extern "C" JSC::EncodedJSValue ExpectPrototype__getNot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); +JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__notGetterWrap); + + +extern "C" JSC::EncodedJSValue ExpectPrototype__getRejects(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); +JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__rejectsGetterWrap); + + +extern "C" JSC::EncodedJSValue ExpectPrototype__getResolves(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); +JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__resolvesGetterWrap); + + +extern "C" EncodedJSValue ExpectPrototype__toBe(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeCloseTo(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeGreaterThan(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeGreaterThanOrEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeInstanceOf(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeLessThan(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toBeLessThanOrEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toContain(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toContainCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toContainEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toEqualCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveBeenCalledTimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveBeenCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveBeenLastCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveBeenNthCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveLastReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveNthReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveProperty(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveReturnedTimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toHaveReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toMatch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toMatchInlineSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toMatchObject(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toMatchSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toStrictEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toThrow(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toThrowErrorMatchingInlineSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback); + + +extern "C" EncodedJSValue ExpectPrototype__toThrowErrorMatchingSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback); + + +STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectPrototype, JSExpectPrototype::Base); + + + static const HashTableValue JSExpectPrototypeTableValues[] = { +{ "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__notGetterWrap, 0 } } , +{ "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__rejectsGetterWrap, 0 } } , +{ "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__resolvesGetterWrap, 0 } } , +{ "toBe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCallback, 1 } } , +{ "toBeCloseTo"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCloseToCallback, 1 } } , +{ "toBeGreaterThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanCallback, 1 } } , +{ "toBeGreaterThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanOrEqualCallback, 1 } } , +{ "toBeInstanceOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeInstanceOfCallback, 1 } } , +{ "toBeLessThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanCallback, 1 } } , +{ "toBeLessThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanOrEqualCallback, 1 } } , +{ "toContain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainCallback, 1 } } , +{ "toContainEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainEqualCallback, 1 } } , +{ "toEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toEqualCallback, 1 } } , +{ "toHaveBeenCalledTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledTimesCallback, 1 } } , +{ "toHaveBeenCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledWithCallback, 1 } } , +{ "toHaveBeenLastCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenLastCalledWithCallback, 1 } } , +{ "toHaveBeenNthCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenNthCalledWithCallback, 1 } } , +{ "toHaveLastReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLastReturnedWithCallback, 1 } } , +{ "toHaveLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLengthCallback, 1 } } , +{ "toHaveNthReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveNthReturnedWithCallback, 1 } } , +{ "toHaveProperty"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHavePropertyCallback, 1 } } , +{ "toHaveReturnedTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedTimesCallback, 1 } } , +{ "toHaveReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedWithCallback, 1 } } , +{ "toMatch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchCallback, 1 } } , +{ "toMatchInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchInlineSnapshotCallback, 1 } } , +{ "toMatchObject"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchObjectCallback, 1 } } , +{ "toMatchSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchSnapshotCallback, 1 } } , +{ "toStrictEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toStrictEqualCallback, 1 } } , +{ "toThrow"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowCallback, 1 } } , +{ "toThrowErrorMatchingInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, 1 } } , +{ "toThrowErrorMatchingSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingSnapshotCallback, 1 } } + }; + + + +const ClassInfo JSExpectPrototype::s_info = { "Expect"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectPrototype) }; + + + +JSC_DEFINE_CUSTOM_GETTER(jsExpectConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); + auto* prototype = jsDynamicCast<JSExpectPrototype*>(JSValue::decode(thisValue)); + + if (UNLIKELY(!prototype)) + return throwVMTypeError(lexicalGlobalObject, throwScope); + return JSValue::encode(globalObject->JSExpectConstructor()); +} + + + +JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__notGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +{ + auto& vm = lexicalGlobalObject->vm(); + Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EncodedJSValue result = ExpectPrototype__getNot(thisObject->wrapped(), globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, result); +} + + +JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__rejectsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +{ + auto& vm = lexicalGlobalObject->vm(); + Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EncodedJSValue result = ExpectPrototype__getRejects(thisObject->wrapped(), globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, result); +} + + +JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__resolvesGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +{ + auto& vm = lexicalGlobalObject->vm(); + Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EncodedJSValue result = ExpectPrototype__getResolves(thisObject->wrapped(), globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, result); +} + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBe(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeCloseTo(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeGreaterThan(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeGreaterThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeInstanceOf(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeLessThan(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toBeLessThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toContain(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toContainEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveBeenCalledTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveBeenCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveBeenLastCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveBeenNthCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveLastReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveLength(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveNthReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveProperty(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveReturnedTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toHaveReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toMatch(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toMatchInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toMatchObject(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toMatchSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toStrictEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toThrow(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toThrowErrorMatchingInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return ExpectPrototype__toThrowErrorMatchingSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + + + + extern "C" void ExpectPrototype__capturedValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + thisObject->m_capturedValue.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ExpectPrototype__capturedValueGetCachedValue(JSC::EncodedJSValue thisValue) + { + auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + return JSValue::encode(thisObject->m_capturedValue.get()); + } + + + + + extern "C" void ExpectPrototype__resultValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + thisObject->m_resultValue.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ExpectPrototype__resultValueGetCachedValue(JSC::EncodedJSValue thisValue) + { + auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue)); + return JSValue::encode(thisObject->m_resultValue.get()); + } + + + +void JSExpectPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + Base::finishCreation(vm); + reifyStaticProperties(vm, JSExpect::info(), JSExpectPrototypeTableValues, *this); + JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); +} + +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__addSnapshotSerializer); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__any); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__anything); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__arrayContaining); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__assertions); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__extend); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__hasAssertions); +extern "C" JSC_DECLARE_CUSTOM_GETTER(ExpectClass__getStaticNot); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__objectContaining); +extern "C" JSC_DECLARE_CUSTOM_GETTER(ExpectClass__getStaticRejects); +extern "C" JSC_DECLARE_CUSTOM_GETTER(ExpectClass__getStaticResolves); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__stringContaining); +extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__stringMatching); + + static const HashTableValue JSExpectConstructorTableValues[] = { +{ "addSnapshotSerializer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__addSnapshotSerializer, 1 } } , +{ "any"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__any, 1 } } , +{ "anything"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__anything, 1 } } , +{ "arrayContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__arrayContaining, 1 } } , +{ "assertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__assertions, 1 } } , +{ "extend"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__extend, 1 } } , +{ "hasAssertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__hasAssertions, 1 } } , +{ "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticNot, 0 } } , +{ "objectContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__objectContaining, 1 } } , +{ "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticRejects, 0 } } , +{ "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticResolves, 0 } } , +{ "stringContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringContaining, 1 } } , +{ "stringMatching"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringMatching, 1 } } + }; + + +void JSExpectConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype) +{ + Base::finishCreation(vm, 0, "Expect"_s, PropertyAdditionMode::WithoutStructureTransition); + reifyStaticProperties(vm, &JSExpectConstructor::s_info, JSExpectConstructorTableValues, *this); + putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); + ASSERT(inherits(info())); +} + +JSExpectConstructor::JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, ExpectClass__call, construct) { + + } + +JSExpectConstructor* JSExpectConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype) { + JSExpectConstructor* ptr = new (NotNull, JSC::allocateCell<JSExpectConstructor>(vm)) JSExpectConstructor(vm, structure); + ptr->finishCreation(vm, globalObject, prototype); + return ptr; +} + +JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSExpectConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) +{ + Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); + JSC::VM &vm = globalObject->vm(); + JSObject* newTarget = asObject(callFrame->newTarget()); + auto* constructor = globalObject->JSExpectConstructor(); + Structure* structure = globalObject->JSExpectStructure(); + if (constructor != newTarget) { + auto scope = DECLARE_THROW_SCOPE(vm); + + auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>( + // ShadowRealm functions belong to a different global object. + getFunctionRealm(globalObject, newTarget) + ); + RETURN_IF_EXCEPTION(scope, {}); + structure = InternalFunction::createSubclassStructure( + globalObject, + newTarget, + functionGlobalObject->JSExpectStructure() + ); + } + + void* ptr = ExpectClass__construct(globalObject, callFrame); + + if (UNLIKELY(!ptr)) { + return JSValue::encode(JSC::jsUndefined()); + } + + JSExpect* instance = JSExpect::create(vm, globalObject, structure, ptr); + + + return JSValue::encode(instance); +} + +extern "C" EncodedJSValue Expect__create(Zig::GlobalObject* globalObject, void* ptr) { + auto &vm = globalObject->vm(); + JSC::Structure* structure = globalObject->JSExpectStructure(); + JSExpect* instance = JSExpect::create(vm, globalObject, structure, ptr); + + return JSValue::encode(instance); +} + +void JSExpectConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype) +{ + +} + +const ClassInfo JSExpectConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectConstructor) }; + + + extern "C" EncodedJSValue Expect__getConstructor(Zig::GlobalObject* globalObject) { + return JSValue::encode(globalObject->JSExpectConstructor()); + } + +JSExpect::~JSExpect() +{ + if (m_ctx) { + ExpectClass__finalize(m_ctx); + } +} +void JSExpect::destroy(JSCell* cell) +{ + static_cast<JSExpect*>(cell)->JSExpect::~JSExpect(); +} + +const ClassInfo JSExpect::s_info = { "Expect"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpect) }; + +void JSExpect::finishCreation(VM& vm) +{ + Base::finishCreation(vm); + ASSERT(inherits(info())); +} + + +JSExpect* JSExpect::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) { + JSExpect* ptr = new (NotNull, JSC::allocateCell<JSExpect>(vm)) JSExpect(vm, structure, ctx); + ptr->finishCreation(vm); + return ptr; +} + +extern "C" void* Expect__fromJS(JSC::EncodedJSValue value) { + JSC::JSValue decodedValue = JSC::JSValue::decode(value); + if (!decodedValue || decodedValue.isUndefinedOrNull()) + return nullptr; + + JSExpect* object = JSC::jsDynamicCast<JSExpect*>(decodedValue); + + if (!object) + return nullptr; + + return object->wrapped(); +} + +extern "C" bool Expect__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) { + JSExpect* object = JSC::jsDynamicCast<JSExpect*>(JSValue::decode(value)); + if (!object) + return false; + + object->m_ctx = ptr; + return true; +} + + +extern "C" const size_t Expect__ptrOffset = JSExpect::offsetOfWrapped(); + +void JSExpect::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) +{ + auto* thisObject = jsCast<JSExpect*>(cell); + if (void* wrapped = thisObject->wrapped()) { + // if (thisObject->scriptExecutionContext()) + // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); + } + Base::analyzeHeap(cell, analyzer); +} + +JSObject* JSExpect::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSExpectConstructor::create(vm, globalObject, WebCore::JSExpectConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSExpectPrototype*>(prototype)); +} + +JSObject* JSExpect::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) +{ + return JSExpectPrototype::create(vm, globalObject, JSExpectPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); +} + +template<typename Visitor> +void JSExpect::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + JSExpect* thisObject = jsCast<JSExpect*>(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + visitor.append(thisObject->m_capturedValue); +visitor.append(thisObject->m_resultValue); + + +} + +DEFINE_VISIT_CHILDREN(JSExpect);class JSTextDecoderPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSTextDecoderPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSTextDecoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderPrototype>(vm)) JSTextDecoderPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSTextDecoderPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSTextDecoderConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSTextDecoderConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSTextDecoderConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForTextDecoderConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype); + }; + + +extern "C" void* TextDecoderClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsTextDecoderConstructor); extern "C" void TextDecoderClass__finalize(void*); + extern "C" EncodedJSValue TextDecoderPrototype__decode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback); @@ -4598,22 +6696,22 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextDecoderConstructor, (JSGlobalObject * lexicalGlob -JSC_DEFINE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTextDecoder* thisObject = jsDynamicCast<JSTextDecoder*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSTextDecoder* thisObject = jsDynamicCast<JSTextDecoder*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return TextDecoderPrototype__decode(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return TextDecoderPrototype__decode(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__encodingGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -4635,20 +6733,20 @@ JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__encodingGetterWrap, (JSGlobalObje } -extern "C" void TextDecoderPrototype__encodingSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void TextDecoderPrototype__encodingSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue)); + thisObject->m_encoding.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue TextDecoderPrototype__encodingGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue)); - thisObject->m_encoding.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue TextDecoderPrototype__encodingGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_encoding.get()); -} - - + return JSValue::encode(thisObject->m_encoding.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__fatalGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -4678,8 +6776,12 @@ void JSTextDecoderConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globa ASSERT(inherits(info())); } +JSTextDecoderConstructor::JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSTextDecoderConstructor* JSTextDecoderConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype) { - JSTextDecoderConstructor* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderConstructor>(vm)) JSTextDecoderConstructor(vm, structure, construct); + JSTextDecoderConstructor* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderConstructor>(vm)) JSTextDecoderConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -4799,6 +6901,11 @@ void JSTextDecoder::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSTextDecoder::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSTextDecoderConstructor::create(vm, globalObject, WebCore::JSTextDecoderConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTextDecoderPrototype*>(prototype)); +} + JSObject* JSTextDecoder::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSTextDecoderPrototype::create(vm, globalObject, JSTextDecoderPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -4815,10 +6922,80 @@ void JSTextDecoder::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->m_encoding); } -DEFINE_VISIT_CHILDREN(JSTextDecoder);extern "C" void* RequestClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSTextDecoder);class JSRequestPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSRequestPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSRequestPrototype>(vm)) JSRequestPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSRequestConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSRequestConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSRequestConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForRequestConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequestConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForRequestConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForRequestConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype); + }; + + +extern "C" void* RequestClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsRequestConstructor); extern "C" void RequestClass__finalize(void*); + extern "C" EncodedJSValue RequestPrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback); @@ -4935,39 +7112,39 @@ JSC_DEFINE_CUSTOM_GETTER(jsRequestConstructor, (JSGlobalObject * lexicalGlobalOb -JSC_DEFINE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return RequestPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(RequestPrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return RequestPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(RequestPrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return RequestPrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return RequestPrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -4989,20 +7166,20 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyGetterWrap, (JSGlobalObject * lex } -extern "C" void RequestPrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void RequestPrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); + thisObject->m_body.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue RequestPrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - thisObject->m_body.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue RequestPrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_body.get()); -} - - + return JSValue::encode(thisObject->m_body.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyUsedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5030,22 +7207,22 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__cacheGetterWrap, (JSGlobalObject * le } -JSC_DEFINE_HOST_FUNCTION(RequestPrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(RequestPrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return RequestPrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return RequestPrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__credentialsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5093,20 +7270,20 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__headersGetterWrap, (JSGlobalObject * } -extern "C" void RequestPrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void RequestPrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); + thisObject->m_headers.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue RequestPrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - thisObject->m_headers.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue RequestPrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_headers.get()); -} - - + return JSValue::encode(thisObject->m_headers.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__integrityGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5121,22 +7298,22 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__integrityGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(RequestPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(RequestPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return RequestPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return RequestPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__methodGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5203,22 +7380,22 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__referrerPolicyGetterWrap, (JSGlobalOb } -JSC_DEFINE_HOST_FUNCTION(RequestPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(RequestPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return RequestPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return RequestPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__urlGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5240,20 +7417,20 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__urlGetterWrap, (JSGlobalObject * lexi } -extern "C" void RequestPrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void RequestPrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); + thisObject->m_url.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue RequestPrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - thisObject->m_url.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue RequestPrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_url.get()); -} - - + return JSValue::encode(thisObject->m_url.get()); + } + + void JSRequestPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -5274,8 +7451,12 @@ void JSRequestConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObj ASSERT(inherits(info())); } +JSRequestConstructor::JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSRequestConstructor* JSRequestConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype) { - JSRequestConstructor* ptr = new (NotNull, JSC::allocateCell<JSRequestConstructor>(vm)) JSRequestConstructor(vm, structure, construct); + JSRequestConstructor* ptr = new (NotNull, JSC::allocateCell<JSRequestConstructor>(vm)) JSRequestConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -5395,6 +7576,11 @@ void JSRequest::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSRequest::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSRequestConstructor::create(vm, globalObject, WebCore::JSRequestConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSRequestPrototype*>(prototype)); +} + JSObject* JSRequest::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSRequestPrototype::create(vm, globalObject, JSRequestPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -5415,10 +7601,80 @@ visitor.reportExtraMemoryVisited(Request__estimatedSize(ptr)); visitor.append(thisObject->m_url); } -DEFINE_VISIT_CHILDREN(JSRequest);extern "C" void* ResponseClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSRequest);class JSResponsePrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSResponsePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSResponsePrototype* ptr = new (NotNull, JSC::allocateCell<JSResponsePrototype>(vm)) JSResponsePrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSResponsePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSResponseConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSResponseConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSResponseConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForResponseConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponseConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForResponseConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForResponseConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype); + }; + + +extern "C" void* ResponseClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsResponseConstructor); extern "C" void ResponseClass__finalize(void*); + extern "C" EncodedJSValue ResponsePrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback); @@ -5515,39 +7771,39 @@ JSC_DEFINE_CUSTOM_GETTER(jsResponseConstructor, (JSGlobalObject * lexicalGlobalO -JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ResponsePrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return ResponsePrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ResponsePrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return ResponsePrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5569,20 +7825,20 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyGetterWrap, (JSGlobalObject * le } -extern "C" void ResponsePrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ResponsePrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); + thisObject->m_body.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ResponsePrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - thisObject->m_body.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue ResponsePrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_body.get()); -} - - + return JSValue::encode(thisObject->m_body.get()); + } + + JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyUsedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5597,22 +7853,22 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyUsedGetterWrap, (JSGlobalObject } -JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return ResponsePrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return ResponsePrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__headersGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5634,37 +7890,37 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__headersGetterWrap, (JSGlobalObject * } -extern "C" void ResponsePrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ResponsePrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); + thisObject->m_headers.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ResponsePrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - thisObject->m_headers.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_headers.get()); + } + + -extern "C" EncodedJSValue ResponsePrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_headers.get()); -} + JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ResponsePrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ResponsePrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__okGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5725,37 +7981,37 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__statusTextGetterWrap, (JSGlobalObjec } -extern "C" void ResponsePrototype__statusTextSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ResponsePrototype__statusTextSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); + thisObject->m_statusText.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ResponsePrototype__statusTextGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - thisObject->m_statusText.set(vm, thisObject, JSValue::decode(value)); -} + return JSValue::encode(thisObject->m_statusText.get()); + } + + -extern "C" EncodedJSValue ResponsePrototype__statusTextGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_statusText.get()); -} + JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return ResponsePrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return ResponsePrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__typeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -5790,20 +8046,20 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__urlGetterWrap, (JSGlobalObject * lex } -extern "C" void ResponsePrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) -{ - auto& vm = globalObject->vm(); + extern "C" void ResponsePrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) + { + auto& vm = globalObject->vm(); + auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); + thisObject->m_url.set(vm, thisObject, JSValue::decode(value)); + } + + extern "C" EncodedJSValue ResponsePrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue) + { auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - thisObject->m_url.set(vm, thisObject, JSValue::decode(value)); -} - -extern "C" EncodedJSValue ResponsePrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue) -{ - auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue)); - return JSValue::encode(thisObject->m_url.get()); -} - - + return JSValue::encode(thisObject->m_url.get()); + } + + void JSResponsePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -5832,8 +8088,12 @@ void JSResponseConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalOb ASSERT(inherits(info())); } +JSResponseConstructor::JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSResponseConstructor* JSResponseConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype) { - JSResponseConstructor* ptr = new (NotNull, JSC::allocateCell<JSResponseConstructor>(vm)) JSResponseConstructor(vm, structure, construct); + JSResponseConstructor* ptr = new (NotNull, JSC::allocateCell<JSResponseConstructor>(vm)) JSResponseConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -5953,6 +8213,11 @@ void JSResponse::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSResponse::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSResponseConstructor::create(vm, globalObject, WebCore::JSResponseConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSResponsePrototype*>(prototype)); +} + JSObject* JSResponse::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSResponsePrototype::create(vm, globalObject, JSResponsePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -5974,10 +8239,80 @@ visitor.reportExtraMemoryVisited(Response__estimatedSize(ptr)); visitor.append(thisObject->m_url); } -DEFINE_VISIT_CHILDREN(JSResponse);extern "C" void* BlobClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); +DEFINE_VISIT_CHILDREN(JSResponse);class JSBlobPrototype final : public JSC::JSNonFinalObject { + public: + using Base = JSC::JSNonFinalObject; + + static JSBlobPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSBlobPrototype* ptr = new (NotNull, JSC::allocateCell<JSBlobPrototype>(vm)) JSBlobPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + 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: + JSBlobPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + + class JSBlobConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSBlobConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype); + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSBlobConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForBlobConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlobConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForBlobConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForBlobConstructor = WTFMove(space); }); + } + + + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype); + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + DECLARE_EXPORT_INFO; + private: + JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure); + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype); + }; + + +extern "C" void* BlobClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*); JSC_DECLARE_CUSTOM_GETTER(jsBlobConstructor); extern "C" void BlobClass__finalize(void*); + extern "C" EncodedJSValue BlobPrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback); @@ -6048,39 +8383,39 @@ JSC_DEFINE_CUSTOM_GETTER(jsBlobConstructor, (JSGlobalObject * lexicalGlobalObjec -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return BlobPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return BlobPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return BlobPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return BlobPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__sizeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -6095,56 +8430,56 @@ JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__sizeGetterWrap, (JSGlobalObject * lexica } -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__sliceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__sliceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return BlobPrototype__getSlice(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__streamCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); + return BlobPrototype__getSlice(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__streamCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return BlobPrototype__getStream(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); + return BlobPrototype__getStream(thisObject->wrapped(), lexicalGlobalObject, callFrame); } - - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - return BlobPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); + + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + + return BlobPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__typeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { @@ -6171,22 +8506,22 @@ JSC_DEFINE_CUSTOM_SETTER(BlobPrototype__typeSetterWrap, (JSGlobalObject * lexica } -JSC_DEFINE_HOST_FUNCTION(BlobPrototype__writerCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__writerCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) + { + auto& vm = lexicalGlobalObject->vm(); - if (UNLIKELY(!thisObject)) { - auto throwScope = DECLARE_THROW_SCOPE(vm); - return throwVMTypeError(lexicalGlobalObject, throwScope); - } + JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue()); - JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); - - return BlobPrototype__getWriter(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + return BlobPrototype__getWriter(thisObject->wrapped(), lexicalGlobalObject, callFrame); + } + void JSBlobPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -6203,8 +8538,12 @@ void JSBlobConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject ASSERT(inherits(info())); } +JSBlobConstructor::JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) { + + } + JSBlobConstructor* JSBlobConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype) { - JSBlobConstructor* ptr = new (NotNull, JSC::allocateCell<JSBlobConstructor>(vm)) JSBlobConstructor(vm, structure, construct); + JSBlobConstructor* ptr = new (NotNull, JSC::allocateCell<JSBlobConstructor>(vm)) JSBlobConstructor(vm, structure); ptr->finishCreation(vm, globalObject, prototype); return ptr; } @@ -6324,6 +8663,11 @@ void JSBlob::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } +JSObject* JSBlob::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype) +{ + return WebCore::JSBlobConstructor::create(vm, globalObject, WebCore::JSBlobConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSBlobPrototype*>(prototype)); +} + JSObject* JSBlob::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) { return JSBlobPrototype::create(vm, globalObject, JSBlobPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index 1db660689..a8ad08046 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -40,6 +40,7 @@ class JSTCPSocket final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSTCPSocket(); @@ -71,79 +72,7 @@ class JSTCPSocket final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_data; mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress; - }; -class JSTCPSocketPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSTCPSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSTCPSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketPrototype>(vm)) JSTCPSocketPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSTCPSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSTCPSocketConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSTCPSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTCPSocketPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSTCPSocketConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForTCPSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTCPSocketConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForTCPSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForTCPSocketConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTCPSocketPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSTCPSocketConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTCPSocketPrototype* prototype); - }; -class JSTLSSocket final : public JSC::JSDestructibleObject { + };class JSTLSSocket final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSTLSSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -168,6 +97,7 @@ class JSTLSSocket final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSTLSSocket(); @@ -199,79 +129,7 @@ class JSTLSSocket final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_data; mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress; - }; -class JSTLSSocketPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSTLSSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSTLSSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketPrototype>(vm)) JSTLSSocketPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSTLSSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSTLSSocketConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSTLSSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTLSSocketPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSTLSSocketConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForTLSSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTLSSocketConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForTLSSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForTLSSocketConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTLSSocketPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSTLSSocketConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTLSSocketPrototype* prototype); - }; -class JSListener final : public JSC::JSDestructibleObject { + };class JSListener final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSListener* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -296,6 +154,7 @@ class JSListener final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSListener(); @@ -327,79 +186,7 @@ class JSListener final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_hostname; mutable JSC::WriteBarrier<JSC::Unknown> m_unix; - }; -class JSListenerPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSListenerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSListenerPrototype* ptr = new (NotNull, JSC::allocateCell<JSListenerPrototype>(vm)) JSListenerPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSListenerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSListenerConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSListenerConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSListenerPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSListenerConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForListenerConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForListenerConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForListenerConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForListenerConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSListenerPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSListenerConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSListenerPrototype* prototype); - }; -class JSSubprocess final : public JSC::JSDestructibleObject { + };class JSSubprocess final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSubprocess* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -424,6 +211,7 @@ class JSSubprocess final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSubprocess(); @@ -456,79 +244,7 @@ class JSSubprocess final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_stderr; mutable JSC::WriteBarrier<JSC::Unknown> m_stdin; mutable JSC::WriteBarrier<JSC::Unknown> m_stdout; - }; -class JSSubprocessPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSubprocessPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSubprocessPrototype* ptr = new (NotNull, JSC::allocateCell<JSSubprocessPrototype>(vm)) JSSubprocessPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSubprocessPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSubprocessConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSubprocessConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSubprocessPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSubprocessConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSubprocessConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSubprocessConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSubprocessConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSubprocessConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSubprocessPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSubprocessConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSubprocessPrototype* prototype); - }; -class JSSHA1 final : public JSC::JSDestructibleObject { + };class JSSHA1 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA1* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -553,6 +269,7 @@ class JSSHA1 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA1(); @@ -583,79 +300,7 @@ class JSSHA1 final : public JSC::JSDestructibleObject { - }; -class JSSHA1Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA1Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA1Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA1Prototype>(vm)) JSSHA1Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA1Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA1Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA1Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA1Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA1Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA1Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype); - }; -class JSMD5 final : public JSC::JSDestructibleObject { + };class JSMD5 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSMD5* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -680,6 +325,7 @@ class JSMD5 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSMD5(); @@ -710,79 +356,7 @@ class JSMD5 final : public JSC::JSDestructibleObject { - }; -class JSMD5Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSMD5Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSMD5Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD5Prototype>(vm)) JSMD5Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSMD5Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSMD5Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSMD5Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSMD5Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForMD5Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForMD5Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype); - }; -class JSMD4 final : public JSC::JSDestructibleObject { + };class JSMD4 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSMD4* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -807,6 +381,7 @@ class JSMD4 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSMD4(); @@ -837,79 +412,7 @@ class JSMD4 final : public JSC::JSDestructibleObject { - }; -class JSMD4Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSMD4Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSMD4Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD4Prototype>(vm)) JSMD4Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSMD4Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSMD4Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSMD4Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSMD4Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForMD4Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForMD4Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype); - }; -class JSSHA224 final : public JSC::JSDestructibleObject { + };class JSSHA224 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA224* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -934,6 +437,7 @@ class JSSHA224 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA224(); @@ -964,79 +468,7 @@ class JSSHA224 final : public JSC::JSDestructibleObject { - }; -class JSSHA224Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA224Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA224Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA224Prototype>(vm)) JSSHA224Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA224Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA224Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA224Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA224Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA224Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA224Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype); - }; -class JSSHA512 final : public JSC::JSDestructibleObject { + };class JSSHA512 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA512* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1061,6 +493,7 @@ class JSSHA512 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA512(); @@ -1091,79 +524,7 @@ class JSSHA512 final : public JSC::JSDestructibleObject { - }; -class JSSHA512Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA512Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA512Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512Prototype>(vm)) JSSHA512Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA512Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA512Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA512Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA512Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA512Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA512Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype); - }; -class JSSHA384 final : public JSC::JSDestructibleObject { + };class JSSHA384 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA384* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1188,6 +549,7 @@ class JSSHA384 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA384(); @@ -1218,79 +580,7 @@ class JSSHA384 final : public JSC::JSDestructibleObject { - }; -class JSSHA384Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA384Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA384Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA384Prototype>(vm)) JSSHA384Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA384Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA384Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA384Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA384Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA384Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA384Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype); - }; -class JSSHA256 final : public JSC::JSDestructibleObject { + };class JSSHA256 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1315,6 +605,7 @@ class JSSHA256 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA256(); @@ -1345,79 +636,7 @@ class JSSHA256 final : public JSC::JSDestructibleObject { - }; -class JSSHA256Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA256Prototype>(vm)) JSSHA256Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA256Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA256Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA256Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA256Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype); - }; -class JSSHA512_256 final : public JSC::JSDestructibleObject { + };class JSSHA512_256 final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSSHA512_256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1442,6 +661,7 @@ class JSSHA512_256 final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSSHA512_256(); @@ -1472,79 +692,7 @@ class JSSHA512_256 final : public JSC::JSDestructibleObject { - }; -class JSSHA512_256Prototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSSHA512_256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSSHA512_256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Prototype>(vm)) JSSHA512_256Prototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSSHA512_256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSSHA512_256Constructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSSHA512_256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSHA512_256Constructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256Constructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForSHA512_256Constructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256Constructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype); - }; -class JSServerWebSocket final : public JSC::JSDestructibleObject { + };class JSServerWebSocket final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSServerWebSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1569,6 +717,7 @@ class JSServerWebSocket final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSServerWebSocket(); @@ -1600,79 +749,64 @@ class JSServerWebSocket final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_data; mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress; - }; -class JSServerWebSocketPrototype final : public JSC::JSNonFinalObject { + };class JSExpect final : public JSC::JSDestructibleObject { public: - using Base = JSC::JSNonFinalObject; + using Base = JSC::JSDestructibleObject; + static JSExpect* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); - static JSServerWebSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { - JSServerWebSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketPrototype>(vm)) JSServerWebSocketPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSExpect, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForExpect.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpect = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForExpect.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForExpect = WTFMove(space); }); } - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } + static void destroy(JSC::JSCell*); 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: - JSServerWebSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info()); } - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); - class JSServerWebSocketConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSServerWebSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype); + ~JSExpect(); - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + void* wrapped() const { return m_ctx; } - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + void detach() { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSServerWebSocketConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocketConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForServerWebSocketConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocketConstructor = WTFMove(space); }); + m_ctx = nullptr; } - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSExpect, m_ctx); } + void* m_ctx { nullptr }; + + + JSExpect(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) { + m_ctx = sinkPtr; + } - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype); - }; -class JSTextDecoder final : public JSC::JSDestructibleObject { + void finishCreation(JSC::VM&); + + + + DECLARE_VISIT_CHILDREN; + + mutable JSC::WriteBarrier<JSC::Unknown> m_capturedValue; +mutable JSC::WriteBarrier<JSC::Unknown> m_resultValue; + };class JSTextDecoder final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSTextDecoder* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1697,6 +831,7 @@ class JSTextDecoder final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSTextDecoder(); @@ -1727,79 +862,7 @@ class JSTextDecoder final : public JSC::JSDestructibleObject { DECLARE_VISIT_CHILDREN; mutable JSC::WriteBarrier<JSC::Unknown> m_encoding; - }; -class JSTextDecoderPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSTextDecoderPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSTextDecoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderPrototype>(vm)) JSTextDecoderPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSTextDecoderPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSTextDecoderConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSTextDecoderConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSTextDecoderConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForTextDecoderConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype); - }; -class JSRequest final : public JSC::JSDestructibleObject { + };class JSRequest final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSRequest* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1824,6 +887,7 @@ class JSRequest final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSRequest(); @@ -1856,79 +920,7 @@ class JSRequest final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_body; mutable JSC::WriteBarrier<JSC::Unknown> m_headers; mutable JSC::WriteBarrier<JSC::Unknown> m_url; - }; -class JSRequestPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSRequestPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSRequestPrototype>(vm)) JSRequestPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSRequestConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSRequestConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSRequestConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForRequestConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequestConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForRequestConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForRequestConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype); - }; -class JSResponse final : public JSC::JSDestructibleObject { + };class JSResponse final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -1953,6 +945,7 @@ class JSResponse final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSResponse(); @@ -1986,79 +979,7 @@ class JSResponse final : public JSC::JSDestructibleObject { mutable JSC::WriteBarrier<JSC::Unknown> m_headers; mutable JSC::WriteBarrier<JSC::Unknown> m_statusText; mutable JSC::WriteBarrier<JSC::Unknown> m_url; - }; -class JSResponsePrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSResponsePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSResponsePrototype* ptr = new (NotNull, JSC::allocateCell<JSResponsePrototype>(vm)) JSResponsePrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSResponsePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSResponseConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSResponseConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSResponseConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForResponseConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponseConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForResponseConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForResponseConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype); - }; -class JSBlob final : public JSC::JSDestructibleObject { + };class JSBlob final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static JSBlob* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); @@ -2083,6 +1004,7 @@ class JSBlob final : public JSC::JSDestructibleObject { } static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); ~JSBlob(); @@ -2114,77 +1036,5 @@ class JSBlob final : public JSC::JSDestructibleObject { }; -class JSBlobPrototype final : public JSC::JSNonFinalObject { - public: - using Base = JSC::JSNonFinalObject; - - static JSBlobPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSBlobPrototype* ptr = new (NotNull, JSC::allocateCell<JSBlobPrototype>(vm)) JSBlobPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - 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: - JSBlobPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); - }; - - class JSBlobConstructor final : public JSC::InternalFunction { - public: - using Base = JSC::InternalFunction; - static JSBlobConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype); - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSBlobConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForBlobConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlobConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForBlobConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForBlobConstructor = WTFMove(space); }); - } - - - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - DECLARE_EXPORT_INFO; - private: - JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype); - }; - } diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index 82a9ac1a2..9ee3cfc94 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -1481,6 +1481,257 @@ pub const JSServerWebSocket = struct { } } }; +pub const JSExpect = struct { + const Expect = Classes.Expect; + const GetterType = fn (*Expect, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue; + const SetterType = fn (*Expect, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool; + const CallbackType = fn (*Expect, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue; + + /// Return the pointer to the wrapped object. + /// If the object does not match the type, return null. + pub fn fromJS(value: JSC.JSValue) ?*Expect { + JSC.markBinding(@src()); + return Expect__fromJS(value); + } + + extern fn ExpectPrototype__capturedValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void; + + extern fn ExpectPrototype__capturedValueGetCachedValue(JSC.JSValue) JSC.JSValue; + + /// `Expect.capturedValue` setter + /// This value will be visited by the garbage collector. + pub fn capturedValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void { + JSC.markBinding(@src()); + ExpectPrototype__capturedValueSetCachedValue(thisValue, globalObject, value); + } + + /// `Expect.capturedValue` getter + /// This value will be visited by the garbage collector. + pub fn capturedValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue { + JSC.markBinding(@src()); + const result = ExpectPrototype__capturedValueGetCachedValue(thisValue); + if (result == .zero) + return null; + + return result; + } + + extern fn ExpectPrototype__resultValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void; + + extern fn ExpectPrototype__resultValueGetCachedValue(JSC.JSValue) JSC.JSValue; + + /// `Expect.resultValue` setter + /// This value will be visited by the garbage collector. + pub fn resultValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void { + JSC.markBinding(@src()); + ExpectPrototype__resultValueSetCachedValue(thisValue, globalObject, value); + } + + /// `Expect.resultValue` getter + /// This value will be visited by the garbage collector. + pub fn resultValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue { + JSC.markBinding(@src()); + const result = ExpectPrototype__resultValueGetCachedValue(thisValue); + if (result == .zero) + return null; + + return result; + } + + /// Get the Expect constructor value. + /// This loads lazily from the global object. + pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue { + JSC.markBinding(@src()); + return Expect__getConstructor(globalObject); + } + + /// Create a new instance of Expect + pub fn toJS(this: *Expect, globalObject: *JSC.JSGlobalObject) JSC.JSValue { + JSC.markBinding(@src()); + if (comptime Environment.allow_assert) { + const value__ = Expect__create(globalObject, this); + std.debug.assert(value__.as(Expect).? == this); // If this fails, likely a C ABI issue. + return value__; + } else { + return Expect__create(globalObject, this); + } + } + + /// Modify the internal ptr to point to a new instance of Expect. + pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Expect) bool { + JSC.markBinding(@src()); + return Expect__dangerouslySetPtr(value, ptr); + } + + /// Detach the ptr from the thisValue + pub fn detachPtr(_: *Expect, value: JSC.JSValue) void { + JSC.markBinding(@src()); + std.debug.assert(Expect__dangerouslySetPtr(value, null)); + } + + extern fn Expect__fromJS(JSC.JSValue) ?*Expect; + extern fn Expect__getConstructor(*JSC.JSGlobalObject) JSC.JSValue; + + extern fn Expect__create(globalObject: *JSC.JSGlobalObject, ptr: ?*Expect) JSC.JSValue; + + extern fn Expect__dangerouslySetPtr(JSC.JSValue, ?*Expect) bool; + + comptime { + if (@TypeOf(Expect.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Expect)) { + @compileLog("Expect.constructor is not a constructor"); + } + + if (@TypeOf(Expect.finalize) != (fn (*Expect) callconv(.C) void)) { + @compileLog("Expect.finalize is not a finalizer"); + } + + if (@TypeOf(Expect.getNot) != GetterType) + @compileLog("Expected Expect.getNot to be a getter"); + + if (@TypeOf(Expect.getRejects) != GetterType) + @compileLog("Expected Expect.getRejects to be a getter"); + + if (@TypeOf(Expect.getResolves) != GetterType) + @compileLog("Expected Expect.getResolves to be a getter"); + + if (@TypeOf(Expect.toBe) != CallbackType) + @compileLog("Expected Expect.toBe to be a callback"); + if (@TypeOf(Expect.toBeCloseTo) != CallbackType) + @compileLog("Expected Expect.toBeCloseTo to be a callback"); + if (@TypeOf(Expect.toBeGreaterThan) != CallbackType) + @compileLog("Expected Expect.toBeGreaterThan to be a callback"); + if (@TypeOf(Expect.toBeGreaterThanOrEqual) != CallbackType) + @compileLog("Expected Expect.toBeGreaterThanOrEqual to be a callback"); + if (@TypeOf(Expect.toBeInstanceOf) != CallbackType) + @compileLog("Expected Expect.toBeInstanceOf to be a callback"); + if (@TypeOf(Expect.toBeLessThan) != CallbackType) + @compileLog("Expected Expect.toBeLessThan to be a callback"); + if (@TypeOf(Expect.toBeLessThanOrEqual) != CallbackType) + @compileLog("Expected Expect.toBeLessThanOrEqual to be a callback"); + if (@TypeOf(Expect.toContain) != CallbackType) + @compileLog("Expected Expect.toContain to be a callback"); + if (@TypeOf(Expect.toContainEqual) != CallbackType) + @compileLog("Expected Expect.toContainEqual to be a callback"); + if (@TypeOf(Expect.toEqual) != CallbackType) + @compileLog("Expected Expect.toEqual to be a callback"); + if (@TypeOf(Expect.toHaveBeenCalledTimes) != CallbackType) + @compileLog("Expected Expect.toHaveBeenCalledTimes to be a callback"); + if (@TypeOf(Expect.toHaveBeenCalledWith) != CallbackType) + @compileLog("Expected Expect.toHaveBeenCalledWith to be a callback"); + if (@TypeOf(Expect.toHaveBeenLastCalledWith) != CallbackType) + @compileLog("Expected Expect.toHaveBeenLastCalledWith to be a callback"); + if (@TypeOf(Expect.toHaveBeenNthCalledWith) != CallbackType) + @compileLog("Expected Expect.toHaveBeenNthCalledWith to be a callback"); + if (@TypeOf(Expect.toHaveLastReturnedWith) != CallbackType) + @compileLog("Expected Expect.toHaveLastReturnedWith to be a callback"); + if (@TypeOf(Expect.toHaveLength) != CallbackType) + @compileLog("Expected Expect.toHaveLength to be a callback"); + if (@TypeOf(Expect.toHaveNthReturnedWith) != CallbackType) + @compileLog("Expected Expect.toHaveNthReturnedWith to be a callback"); + if (@TypeOf(Expect.toHaveProperty) != CallbackType) + @compileLog("Expected Expect.toHaveProperty to be a callback"); + if (@TypeOf(Expect.toHaveReturnedTimes) != CallbackType) + @compileLog("Expected Expect.toHaveReturnedTimes to be a callback"); + if (@TypeOf(Expect.toHaveReturnedWith) != CallbackType) + @compileLog("Expected Expect.toHaveReturnedWith to be a callback"); + if (@TypeOf(Expect.toMatch) != CallbackType) + @compileLog("Expected Expect.toMatch to be a callback"); + if (@TypeOf(Expect.toMatchInlineSnapshot) != CallbackType) + @compileLog("Expected Expect.toMatchInlineSnapshot to be a callback"); + if (@TypeOf(Expect.toMatchObject) != CallbackType) + @compileLog("Expected Expect.toMatchObject to be a callback"); + if (@TypeOf(Expect.toMatchSnapshot) != CallbackType) + @compileLog("Expected Expect.toMatchSnapshot to be a callback"); + if (@TypeOf(Expect.toStrictEqual) != CallbackType) + @compileLog("Expected Expect.toStrictEqual to be a callback"); + if (@TypeOf(Expect.toThrow) != CallbackType) + @compileLog("Expected Expect.toThrow to be a callback"); + if (@TypeOf(Expect.toThrowErrorMatchingInlineSnapshot) != CallbackType) + @compileLog("Expected Expect.toThrowErrorMatchingInlineSnapshot to be a callback"); + if (@TypeOf(Expect.toThrowErrorMatchingSnapshot) != CallbackType) + @compileLog("Expected Expect.toThrowErrorMatchingSnapshot to be a callback"); + if (@TypeOf(Expect.addSnapshotSerializer) != StaticCallbackType) + @compileLog("Expected Expect.addSnapshotSerializer to be a static callback"); + if (@TypeOf(Expect.any) != StaticCallbackType) + @compileLog("Expected Expect.any to be a static callback"); + if (@TypeOf(Expect.anything) != StaticCallbackType) + @compileLog("Expected Expect.anything to be a static callback"); + if (@TypeOf(Expect.arrayContaining) != StaticCallbackType) + @compileLog("Expected Expect.arrayContaining to be a static callback"); + if (@TypeOf(Expect.assertions) != StaticCallbackType) + @compileLog("Expected Expect.assertions to be a static callback"); + if (@TypeOf(Expect.extend) != StaticCallbackType) + @compileLog("Expected Expect.extend to be a static callback"); + if (@TypeOf(Expect.hasAssertions) != StaticCallbackType) + @compileLog("Expected Expect.hasAssertions to be a static callback"); + if (@TypeOf(Expect.getStaticNot) != StaticGetterType) + @compileLog("Expected Expect.getStaticNot to be a static getter"); + + if (@TypeOf(Expect.objectContaining) != StaticCallbackType) + @compileLog("Expected Expect.objectContaining to be a static callback"); + if (@TypeOf(Expect.getStaticRejects) != StaticGetterType) + @compileLog("Expected Expect.getStaticRejects to be a static getter"); + + if (@TypeOf(Expect.getStaticResolves) != StaticGetterType) + @compileLog("Expected Expect.getStaticResolves to be a static getter"); + + if (@TypeOf(Expect.stringContaining) != StaticCallbackType) + @compileLog("Expected Expect.stringContaining to be a static callback"); + if (@TypeOf(Expect.stringMatching) != StaticCallbackType) + @compileLog("Expected Expect.stringMatching to be a static callback"); + if (@TypeOf(Expect.call) != StaticCallbackType) + @compileLog("Expected Expect.call to be a static callback"); + if (!JSC.is_bindgen) { + @export(Expect.addSnapshotSerializer, .{ .name = "ExpectClass__addSnapshotSerializer" }); + @export(Expect.any, .{ .name = "ExpectClass__any" }); + @export(Expect.anything, .{ .name = "ExpectClass__anything" }); + @export(Expect.arrayContaining, .{ .name = "ExpectClass__arrayContaining" }); + @export(Expect.assertions, .{ .name = "ExpectClass__assertions" }); + @export(Expect.call, .{ .name = "ExpectClass__call" }); + @export(Expect.constructor, .{ .name = "ExpectClass__construct" }); + @export(Expect.extend, .{ .name = "ExpectClass__extend" }); + @export(Expect.finalize, .{ .name = "ExpectClass__finalize" }); + @export(Expect.getNot, .{ .name = "ExpectPrototype__getNot" }); + @export(Expect.getRejects, .{ .name = "ExpectPrototype__getRejects" }); + @export(Expect.getResolves, .{ .name = "ExpectPrototype__getResolves" }); + @export(Expect.getStaticNot, .{ .name = "ExpectClass__getStaticNot" }); + @export(Expect.getStaticRejects, .{ .name = "ExpectClass__getStaticRejects" }); + @export(Expect.getStaticResolves, .{ .name = "ExpectClass__getStaticResolves" }); + @export(Expect.hasAssertions, .{ .name = "ExpectClass__hasAssertions" }); + @export(Expect.objectContaining, .{ .name = "ExpectClass__objectContaining" }); + @export(Expect.stringContaining, .{ .name = "ExpectClass__stringContaining" }); + @export(Expect.stringMatching, .{ .name = "ExpectClass__stringMatching" }); + @export(Expect.toBe, .{ .name = "ExpectPrototype__toBe" }); + @export(Expect.toBeCloseTo, .{ .name = "ExpectPrototype__toBeCloseTo" }); + @export(Expect.toBeGreaterThan, .{ .name = "ExpectPrototype__toBeGreaterThan" }); + @export(Expect.toBeGreaterThanOrEqual, .{ .name = "ExpectPrototype__toBeGreaterThanOrEqual" }); + @export(Expect.toBeInstanceOf, .{ .name = "ExpectPrototype__toBeInstanceOf" }); + @export(Expect.toBeLessThan, .{ .name = "ExpectPrototype__toBeLessThan" }); + @export(Expect.toBeLessThanOrEqual, .{ .name = "ExpectPrototype__toBeLessThanOrEqual" }); + @export(Expect.toContain, .{ .name = "ExpectPrototype__toContain" }); + @export(Expect.toContainEqual, .{ .name = "ExpectPrototype__toContainEqual" }); + @export(Expect.toEqual, .{ .name = "ExpectPrototype__toEqual" }); + @export(Expect.toHaveBeenCalledTimes, .{ .name = "ExpectPrototype__toHaveBeenCalledTimes" }); + @export(Expect.toHaveBeenCalledWith, .{ .name = "ExpectPrototype__toHaveBeenCalledWith" }); + @export(Expect.toHaveBeenLastCalledWith, .{ .name = "ExpectPrototype__toHaveBeenLastCalledWith" }); + @export(Expect.toHaveBeenNthCalledWith, .{ .name = "ExpectPrototype__toHaveBeenNthCalledWith" }); + @export(Expect.toHaveLastReturnedWith, .{ .name = "ExpectPrototype__toHaveLastReturnedWith" }); + @export(Expect.toHaveLength, .{ .name = "ExpectPrototype__toHaveLength" }); + @export(Expect.toHaveNthReturnedWith, .{ .name = "ExpectPrototype__toHaveNthReturnedWith" }); + @export(Expect.toHaveProperty, .{ .name = "ExpectPrototype__toHaveProperty" }); + @export(Expect.toHaveReturnedTimes, .{ .name = "ExpectPrototype__toHaveReturnedTimes" }); + @export(Expect.toHaveReturnedWith, .{ .name = "ExpectPrototype__toHaveReturnedWith" }); + @export(Expect.toMatch, .{ .name = "ExpectPrototype__toMatch" }); + @export(Expect.toMatchInlineSnapshot, .{ .name = "ExpectPrototype__toMatchInlineSnapshot" }); + @export(Expect.toMatchObject, .{ .name = "ExpectPrototype__toMatchObject" }); + @export(Expect.toMatchSnapshot, .{ .name = "ExpectPrototype__toMatchSnapshot" }); + @export(Expect.toStrictEqual, .{ .name = "ExpectPrototype__toStrictEqual" }); + @export(Expect.toThrow, .{ .name = "ExpectPrototype__toThrow" }); + @export(Expect.toThrowErrorMatchingInlineSnapshot, .{ .name = "ExpectPrototype__toThrowErrorMatchingInlineSnapshot" }); + @export(Expect.toThrowErrorMatchingSnapshot, .{ .name = "ExpectPrototype__toThrowErrorMatchingSnapshot" }); + } + } +}; pub const JSTextDecoder = struct { const TextDecoder = Classes.TextDecoder; const GetterType = fn (*TextDecoder, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue; @@ -2113,6 +2364,7 @@ comptime { _ = JSSHA256; _ = JSSHA512_256; _ = JSServerWebSocket; + _ = JSExpect; _ = JSTextDecoder; _ = JSRequest; _ = JSResponse; diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig index acae606e3..25365940b 100644 --- a/src/bun.js/bindings/generated_classes_list.zig +++ b/src/bun.js/bindings/generated_classes_list.zig @@ -18,4 +18,5 @@ pub const Classes = struct { pub const TCPSocket = JSC.API.TCPSocket; pub const TLSSocket = JSC.API.TLSSocket; pub const Listener = JSC.API.Listener; + pub const Expect = JSC.Jest.Expect; }; diff --git a/src/bun.js/test/jest.classes.ts b/src/bun.js/test/jest.classes.ts new file mode 100644 index 000000000..06a5232fc --- /dev/null +++ b/src/bun.js/test/jest.classes.ts @@ -0,0 +1,186 @@ +import { define } from "../scripts/class-definitions"; + +export default [ + define({ + name: "Expect", + construct: true, + call: true, + finalize: true, + JSType: "0b11101110", + values: ["capturedValue", "resultValue"], + klass: { + extend: { + fn: "extend", + length: 1, + }, + anything: { + fn: "anything", + length: 1, + }, + any: { + fn: "any", + length: 1, + }, + arrayContaining: { + fn: "arrayContaining", + length: 1, + }, + assertions: { + fn: "assertions", + length: 1, + }, + hasAssertions: { + fn: "hasAssertions", + length: 1, + }, + objectContaining: { + fn: "objectContaining", + length: 1, + }, + stringContaining: { + fn: "stringContaining", + length: 1, + }, + stringMatching: { + fn: "stringMatching", + length: 1, + }, + addSnapshotSerializer: { + fn: "addSnapshotSerializer", + length: 1, + }, + not: { + getter: "getStaticNot", + }, + resolves: { + getter: "getStaticResolves", + }, + rejects: { + getter: "getStaticRejects", + }, + }, + proto: { + toBe: { + fn: "toBe", + length: 1, + }, + toHaveBeenCalledTimes: { + fn: "toHaveBeenCalledTimes", + length: 1, + }, + toHaveBeenCalledWith: { + fn: "toHaveBeenCalledWith", + length: 1, + }, + toHaveBeenLastCalledWith: { + fn: "toHaveBeenLastCalledWith", + length: 1, + }, + toHaveBeenNthCalledWith: { + fn: "toHaveBeenNthCalledWith", + length: 1, + }, + toHaveReturnedTimes: { + fn: "toHaveReturnedTimes", + length: 1, + }, + toHaveReturnedWith: { + fn: "toHaveReturnedWith", + length: 1, + }, + toHaveLastReturnedWith: { + fn: "toHaveLastReturnedWith", + length: 1, + }, + toHaveNthReturnedWith: { + fn: "toHaveNthReturnedWith", + length: 1, + }, + toHaveLength: { + fn: "toHaveLength", + length: 1, + }, + toHaveProperty: { + fn: "toHaveProperty", + length: 1, + }, + toBeCloseTo: { + fn: "toBeCloseTo", + length: 1, + }, + toBeGreaterThan: { + fn: "toBeGreaterThan", + length: 1, + }, + toBeGreaterThanOrEqual: { + fn: "toBeGreaterThanOrEqual", + length: 1, + }, + toBeLessThan: { + fn: "toBeLessThan", + length: 1, + }, + toBeLessThanOrEqual: { + fn: "toBeLessThanOrEqual", + length: 1, + }, + toBeInstanceOf: { + fn: "toBeInstanceOf", + length: 1, + }, + toContain: { + fn: "toContain", + length: 1, + }, + toContainEqual: { + fn: "toContainEqual", + length: 1, + }, + toEqual: { + fn: "toEqual", + length: 1, + }, + toMatch: { + fn: "toMatch", + length: 1, + }, + toMatchObject: { + fn: "toMatchObject", + length: 1, + }, + toMatchSnapshot: { + fn: "toMatchSnapshot", + length: 1, + }, + toMatchInlineSnapshot: { + fn: "toMatchInlineSnapshot", + length: 1, + }, + toStrictEqual: { + fn: "toStrictEqual", + length: 1, + }, + toThrow: { + fn: "toThrow", + length: 1, + }, + toThrowErrorMatchingSnapshot: { + fn: "toThrowErrorMatchingSnapshot", + length: 1, + }, + toThrowErrorMatchingInlineSnapshot: { + fn: "toThrowErrorMatchingInlineSnapshot", + length: 1, + }, + not: { + getter: "getNot", + }, + resolves: { + getter: "getResolves", + }, + rejects: { + getter: "getRejects", + }, + }, + }), +]; diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 3e962c047..7440a9512 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -235,9 +235,10 @@ pub const Jest = struct { pub const Expect = struct { test_id: TestRunner.Test.ID, scope: *DescribeScope, - value: JSValue, op: Op.Set = Op.Set.init(.{}), + pub usingnamespace JSC.Codegen.JSExpect; + pub const Op = enum(u3) { resolves, rejects, @@ -247,410 +248,203 @@ pub const Expect = struct { pub fn finalize( this: *Expect, - ) void { - this.value.unprotect(); + ) callconv(.C) void { VirtualMachine.vm.allocator.destroy(this); } - pub const Class = NewClass( - Expect, - .{ .name = "Expect" }, - .{ - .toBe = .{ - .rfn = Expect.toBe, - .name = "toBe", - }, - .toHaveBeenCalledTimes = .{ - .rfn = Expect.toHaveBeenCalledTimes, - .name = "toHaveBeenCalledTimes", - }, - .finalize = .{ .rfn = Expect.finalize, .name = "finalize" }, - .toHaveBeenCalledWith = .{ - .rfn = Expect.toHaveBeenCalledWith, - .name = "toHaveBeenCalledWith", - }, - .toHaveBeenLastCalledWith = .{ - .rfn = Expect.toHaveBeenLastCalledWith, - .name = "toHaveBeenLastCalledWith", - }, - .toHaveBeenNthCalledWith = .{ - .rfn = Expect.toHaveBeenNthCalledWith, - .name = "toHaveBeenNthCalledWith", - }, - .toHaveReturnedTimes = .{ - .rfn = Expect.toHaveReturnedTimes, - .name = "toHaveReturnedTimes", - }, - .toHaveReturnedWith = .{ - .rfn = Expect.toHaveReturnedWith, - .name = "toHaveReturnedWith", - }, - .toHaveLastReturnedWith = .{ - .rfn = Expect.toHaveLastReturnedWith, - .name = "toHaveLastReturnedWith", - }, - .toHaveNthReturnedWith = .{ - .rfn = Expect.toHaveNthReturnedWith, - .name = "toHaveNthReturnedWith", - }, - .toHaveLength = .{ - .rfn = Expect.toHaveLength, - .name = "toHaveLength", - }, - .toHaveProperty = .{ - .rfn = Expect.toHaveProperty, - .name = "toHaveProperty", - }, - .toBeCloseTo = .{ - .rfn = Expect.toBeCloseTo, - .name = "toBeCloseTo", - }, - .toBeGreaterThan = .{ - .rfn = Expect.toBeGreaterThan, - .name = "toBeGreaterThan", - }, - .toBeGreaterThanOrEqual = .{ - .rfn = Expect.toBeGreaterThanOrEqual, - .name = "toBeGreaterThanOrEqual", - }, - .toBeLessThan = .{ - .rfn = Expect.toBeLessThan, - .name = "toBeLessThan", - }, - .toBeLessThanOrEqual = .{ - .rfn = Expect.toBeLessThanOrEqual, - .name = "toBeLessThanOrEqual", - }, - .toBeInstanceOf = .{ - .rfn = Expect.toBeInstanceOf, - .name = "toBeInstanceOf", - }, - .toContain = .{ - .rfn = Expect.toContain, - .name = "toContain", - }, - .toContainEqual = .{ - .rfn = Expect.toContainEqual, - .name = "toContainEqual", - }, - .toEqual = .{ - .rfn = Expect.toEqual, - .name = "toEqual", - }, - .toMatch = .{ - .rfn = Expect.toMatch, - .name = "toMatch", - }, - .toMatchObject = .{ - .rfn = Expect.toMatchObject, - .name = "toMatchObject", - }, - .toMatchSnapshot = .{ - .rfn = Expect.toMatchSnapshot, - .name = "toMatchSnapshot", - }, - .toMatchInlineSnapshot = .{ - .rfn = Expect.toMatchInlineSnapshot, - .name = "toMatchInlineSnapshot", - }, - .toStrictEqual = .{ - .rfn = Expect.toStrictEqual, - .name = "toStrictEqual", - }, - .toThrow = .{ - .rfn = Expect.toThrow, - .name = "toThrow", - }, - .toThrowErrorMatchingSnapshot = .{ - .rfn = Expect.toThrowErrorMatchingSnapshot, - .name = "toThrowErrorMatchingSnapshot", - }, - .toThrowErrorMatchingInlineSnapshot = .{ - .rfn = Expect.toThrowErrorMatchingInlineSnapshot, - .name = "toThrowErrorMatchingInlineSnapshot", - }, - }, - .{ - .not = .{ - .get = Expect.not, - .name = "not", - }, - .resolves = .{ - .get = Expect.resolves, - .name = "resolves", - }, - .rejects = .{ - .get = Expect.rejects, - .name = "rejects", - }, - }, - ); + pub fn call(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { + const arguments_ = callframe.arguments(1); + if (arguments_.len < 1) { + globalObject.throw("expect() requires one argument", .{}); + return .zero; + } + const arguments = arguments_.ptr[0..arguments_.len]; + + var expect = globalObject.bunVM().allocator.create(Expect) catch unreachable; + const value = arguments[0]; + + if (Jest.runner.?.pending_test == null) { + globalObject.throw("expect() must be called inside a test", .{}); + return .zero; + } + + expect.* = .{ + .scope = Jest.runner.?.pending_test.?.describe, + .test_id = Jest.runner.?.pending_test.?.test_id, + }; + const expect_js_value = expect.toJS(globalObject); + JSC.Jest.Expect.capturedValueSetCached(expect_js_value, globalObject, value); + return expect_js_value; + } + + pub fn constructor( + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) ?*Expect { + _ = callframe.arguments(1); + globalObject.throw("expect() cannot be called with new", .{}); + return null; + } /// Object.is() pub fn toBe( this: *Expect, - ctx: js.JSContextRef, - _: js.JSObjectRef, - thisObject: js.JSObjectRef, - arguments: []const js.JSValueRef, - exception: js.ExceptionRef, - ) js.JSValueRef { - if (arguments.len != 1) { - JSC.JSError( - getAllocator(ctx), - ".toBe() takes 1 argument", - .{}, - ctx, - exception, - ); - return js.JSValueMakeUndefined(ctx); + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSC.JSValue { + const thisValue = callframe.this(); + const arguments_ = callframe.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBe() takes 1 argument", .{}); + return .zero; } + if (this.scope.tests.items.len <= this.test_id) { - JSC.JSError( - getAllocator(ctx), - ".toBe() called in wrong scope", - .{}, - ctx, - exception, - ); - return js.JSValueMakeUndefined(ctx); + globalObject.throw("toBe() must be called in a test", .{}); + return .zero; } + active_test_expectation_counter.actual += 1; - const left = JSValue.fromRef(arguments[0]); + const left = arguments[0]; left.ensureStillAlive(); - const right = this.value; + const right = Expect.capturedValueGetCached(thisValue) orelse { + globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); + return .zero; + }; right.ensureStillAlive(); - const eql = left.isSameValue(right, ctx.ptr()); + const eql = left.isSameValue(right, globalObject); if (comptime Environment.allow_assert) { - std.debug.assert(eql == JSC.C.JSValueIsStrictEqual(ctx, left.asObjectRef(), right.asObjectRef())); + std.debug.assert(eql == JSC.C.JSValueIsStrictEqual(globalObject, left.asObjectRef(), right.asObjectRef())); } if (!eql) { - var lhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = ctx.ptr() }; - var rhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = ctx.ptr() }; + var lhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; + var rhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; if (comptime Environment.allow_assert) { Output.prettyErrorln("\nJSType: {s}\nJSType: {s}\n\n", .{ @tagName(left.jsType()), @tagName(right.jsType()) }); } - JSC.JSError( - getAllocator(ctx), - "Expected: {}\n\tReceived: {}", + globalObject.throw( + "Expected: {any}\n\tReceived: {any}", .{ - left.toFmt(ctx.ptr(), &lhs_formatter), - right.toFmt(ctx.ptr(), &rhs_formatter), + left.toFmt(globalObject, &lhs_formatter), + right.toFmt(globalObject, &rhs_formatter), }, - ctx, - exception, ); - return null; + return .zero; } - return thisObject; + return thisValue; } pub fn toHaveLength( this: *Expect, - ctx: js.JSContextRef, - _: js.JSObjectRef, - thisObject: js.JSObjectRef, - arguments: []const js.JSValueRef, - exception: js.ExceptionRef, - ) js.JSValueRef { - if (arguments.len != 1) { - JSC.JSError( - getAllocator(ctx), - ".toHaveLength() takes 1 argument", - .{}, - ctx, - exception, - ); - return js.JSValueMakeUndefined(ctx); + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSC.JSValue { + const thisValue = callframe.this(); + const arguments_ = callframe.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toHaveLength() takes 1 argument", .{}); + return .zero; } + if (this.scope.tests.items.len <= this.test_id) { - JSC.JSError( - getAllocator(ctx), - ".toHaveLength() called in wrong scope", - .{}, - ctx, - exception, - ); - return js.JSValueMakeUndefined(ctx); + globalObject.throw("toHaveLength() must be called in a test", .{}); + return .zero; } + active_test_expectation_counter.actual += 1; - const expected = JSC.JSValue.fromRef(arguments[0]).toU32(); - const actual = this.value.getLengthOfArray(ctx.ptr()); + const expected = arguments[0].coerce(i32, globalObject); + const value = JSC.Jest.Expect.capturedValueGetCached(thisValue) orelse { + globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); + return .zero; + }; + const actual = value.getLengthOfArray(globalObject); if (expected != actual) { - JSC.JSError( - getAllocator(ctx), - "Expected length to equal {d} but received {d}\n Expected: {d}\n Actual: {d}\n", - .{ - expected, - actual, - expected, - actual, - }, - ctx, - exception, - ); - return null; + globalObject.throw("Expected length to equal {d} but received {d}\n Expected: {d}\n Actual: {d}\n", .{ + expected, + actual, + expected, + actual, + }); + return .zero; } - return thisObject; - } - pub const toHaveBeenCalledTimes = notImplementedFn; - pub const toHaveBeenCalledWith = notImplementedFn; - pub const toHaveBeenLastCalledWith = notImplementedFn; - pub const toHaveBeenNthCalledWith = notImplementedFn; - pub const toHaveReturnedTimes = notImplementedFn; - pub const toHaveReturnedWith = notImplementedFn; - pub const toHaveLastReturnedWith = notImplementedFn; - pub const toHaveNthReturnedWith = notImplementedFn; - pub const toHaveProperty = notImplementedFn; - pub const toBeCloseTo = notImplementedFn; - pub const toBeGreaterThan = notImplementedFn; - pub const toBeGreaterThanOrEqual = notImplementedFn; - pub const toBeLessThan = notImplementedFn; - pub const toBeLessThanOrEqual = notImplementedFn; - pub const toBeInstanceOf = notImplementedFn; - pub const toContain = notImplementedFn; - pub const toContainEqual = notImplementedFn; - pub const toEqual = notImplementedFn; - pub const toMatch = notImplementedFn; - pub const toMatchObject = notImplementedFn; - pub const toMatchSnapshot = notImplementedFn; - pub const toMatchInlineSnapshot = notImplementedFn; - pub const toStrictEqual = notImplementedFn; - pub const toThrow = notImplementedFn; - pub const toThrowErrorMatchingSnapshot = notImplementedFn; - pub const toThrowErrorMatchingInlineSnapshot = notImplementedFn; - - pub const not = notImplementedProp; - pub const resolves = notImplementedProp; - pub const rejects = notImplementedProp; -}; + return thisValue; + } -pub const ExpectPrototype = struct { - scope: *DescribeScope, - test_id: TestRunner.Test.ID, - op: Expect.Op.Set = Expect.Op.Set.init(.{}), + pub const toHaveBeenCalledTimes = notImplementedJSCFn; + pub const toHaveBeenCalledWith = notImplementedJSCFn; + pub const toHaveBeenLastCalledWith = notImplementedJSCFn; + pub const toHaveBeenNthCalledWith = notImplementedJSCFn; + pub const toHaveReturnedTimes = notImplementedJSCFn; + pub const toHaveReturnedWith = notImplementedJSCFn; + pub const toHaveLastReturnedWith = notImplementedJSCFn; + pub const toHaveNthReturnedWith = notImplementedJSCFn; + pub const toHaveProperty = notImplementedJSCFn; + pub const toBeCloseTo = notImplementedJSCFn; + pub const toBeGreaterThan = notImplementedJSCFn; + pub const toBeGreaterThanOrEqual = notImplementedJSCFn; + pub const toBeLessThan = notImplementedJSCFn; + pub const toBeLessThanOrEqual = notImplementedJSCFn; + pub const toBeInstanceOf = notImplementedJSCFn; + pub const toContain = notImplementedJSCFn; + pub const toContainEqual = notImplementedJSCFn; + pub const toEqual = notImplementedJSCFn; + pub const toMatch = notImplementedJSCFn; + pub const toMatchObject = notImplementedJSCFn; + pub const toMatchSnapshot = notImplementedJSCFn; + pub const toMatchInlineSnapshot = notImplementedJSCFn; + pub const toStrictEqual = notImplementedJSCFn; + pub const toThrow = notImplementedJSCFn; + pub const toThrowErrorMatchingSnapshot = notImplementedJSCFn; + pub const toThrowErrorMatchingInlineSnapshot = notImplementedJSCFn; + + pub fn notImplementedJSCFn(_: *Expect, globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } - pub const Class = NewClass( - ExpectPrototype, - .{ - .name = "ExpectPrototype", - .read_only = true, - }, - .{ - .call = .{ - .rfn = ExpectPrototype.call, - }, - .extend = .{ - .name = "extend", - .rfn = ExpectPrototype.extend, - }, - .anything = .{ - .name = "anything", - .rfn = ExpectPrototype.anything, - }, - .any = .{ - .name = "any", - .rfn = ExpectPrototype.any, - }, - .arrayContaining = .{ - .name = "arrayContaining", - .rfn = ExpectPrototype.arrayContaining, - }, - .assertions = .{ - .name = "assertions", - .rfn = ExpectPrototype.assertions, - }, - .hasAssertions = .{ - .name = "hasAssertions", - .rfn = ExpectPrototype.hasAssertions, - }, - .objectContaining = .{ - .name = "objectContaining", - .rfn = ExpectPrototype.objectContaining, - }, - .stringContaining = .{ - .name = "stringContaining", - .rfn = ExpectPrototype.stringContaining, - }, - .stringMatching = .{ - .name = "stringMatching", - .rfn = ExpectPrototype.stringMatching, - }, - .addSnapshotSerializer = .{ - .name = "addSnapshotSerializer", - .rfn = ExpectPrototype.addSnapshotSerializer, - }, - }, - .{ - .not = .{ - .name = "not", - .get = ExpectPrototype.not, - }, - .resolves = .{ - .name = "resolves", - .get = ExpectPrototype.resolves, - }, - .rejects = .{ - .name = "rejects", - .get = ExpectPrototype.rejects, - }, - }, - ); - pub const extend = notImplementedFn; - pub const anything = notImplementedFn; - pub const any = notImplementedFn; - pub const arrayContaining = notImplementedFn; - pub const assertions = notImplementedFn; - pub const hasAssertions = notImplementedFn; - pub const objectContaining = notImplementedFn; - pub const stringContaining = notImplementedFn; - pub const stringMatching = notImplementedFn; - pub const addSnapshotSerializer = notImplementedFn; - pub const not = notImplementedProp; - pub const resolves = notImplementedProp; - pub const rejects = notImplementedProp; + pub fn notImplementedStaticFn(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } - pub fn call( - _: *ExpectPrototype, - ctx: js.JSContextRef, - _: js.JSObjectRef, - _: js.JSObjectRef, - arguments: []const js.JSValueRef, - exception: js.ExceptionRef, - ) js.JSObjectRef { - if (arguments.len != 1) { - JSError(getAllocator(ctx), "expect() requires one argument", .{}, ctx, exception); - return js.JSValueMakeUndefined(ctx); - } - var expect_ = getAllocator(ctx).create(Expect) catch unreachable; - const value = JSC.JSValue.c(arguments[0]); - if (Jest.runner.?.pending_test == null) { - JSError( - getAllocator(ctx), - "expect() must be called during a test", - .{}, - ctx, - exception, - ); - return js.JSValueMakeUndefined(ctx); - } + pub fn notImplementedJSCProp(_: *Expect, globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } - value.protect(); - expect_.* = .{ - .value = value, - .scope = Jest.runner.?.pending_test.?.describe, - .test_id = Jest.runner.?.pending_test.?.test_id, - }; - expect_.value.ensureStillAlive(); - return Expect.Class.make(ctx, expect_); + pub fn notImplementedStaticProp(globalObject: *JSC.JSGlobalObject, _: JSC.JSValue, _: JSC.JSValue) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; } + + pub const getStaticNot = notImplementedStaticProp; + pub const getStaticResolves = notImplementedStaticProp; + pub const getStaticRejects = notImplementedStaticProp; + pub const getNot = notImplementedJSCProp; + pub const getResolves = notImplementedJSCProp; + pub const getRejects = notImplementedJSCProp; + + pub const extend = notImplementedStaticFn; + pub const anything = notImplementedStaticFn; + pub const any = notImplementedStaticFn; + pub const arrayContaining = notImplementedStaticFn; + pub const assertions = notImplementedStaticFn; + pub const hasAssertions = notImplementedStaticFn; + pub const objectContaining = notImplementedStaticFn; + pub const stringContaining = notImplementedStaticFn; + pub const stringMatching = notImplementedStaticFn; + pub const addSnapshotSerializer = notImplementedStaticFn; }; pub const TestScope = struct { @@ -1140,12 +934,7 @@ pub const DescribeScope = struct { _: js.JSStringRef, _: js.ExceptionRef, ) js.JSObjectRef { - var expect_ = getAllocator(ctx).create(ExpectPrototype) catch unreachable; - expect_.* = .{ - .scope = DescribeScope.active, - .test_id = DescribeScope.active.current_test_id, - }; - return ExpectPrototype.Class.make(ctx, expect_); + return JSC.Jest.Expect.getConstructor(ctx).asObjectRef(); } pub fn createTest( diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index a6e6f9b94..b959445dc 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -432,7 +432,6 @@ pub const Resolver = struct { package_manager: ?*PackageManager = null, onWakePackageManager: PackageManager.WakeHandler = .{}, - main_file_for_package_manager: []const u8 = "", env_loader: ?*DotEnv.Loader = null, // These are sets that represent various conditions for the "exports" field |