diff options
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index d8593a9fa..1a9a1dc1b 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -127,7 +127,6 @@ using SourceOrigin = JSC::SourceOrigin; using JSObject = JSC::JSObject; using JSNonFinalObject = JSC::JSNonFinalObject; namespace JSCastingHelpers = JSC::JSCastingHelpers; -using JSBuffer = WebCore::JSBuffer; #include <dlfcn.h> #include "IDLTypes.h" @@ -574,6 +573,15 @@ JSC_DEFINE_CUSTOM_GETTER(JSCloseEvent_getter, WebCore::JSCloseEvent::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject)); } +JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter, + (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, + JSC::PropertyName)) +{ + Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject); + return JSC::JSValue::encode( + thisObject->JSBufferConstructor()); +} + GENERATED_CONSTRUCTOR_GETTER(JSTextDecoder); GENERATED_CONSTRUCTOR_SETTER(JSTextDecoder); @@ -589,9 +597,6 @@ GENERATED_CONSTRUCTOR_SETTER(JSBlob); WEBCORE_GENERATED_CONSTRUCTOR_GETTER(JSMessageEvent); WEBCORE_GENERATED_CONSTRUCTOR_SETTER(JSMessageEvent); -WEBCORE_GENERATED_CONSTRUCTOR_GETTER(JSBuffer); -WEBCORE_GENERATED_CONSTRUCTOR_SETTER(JSBuffer); - WEBCORE_GENERATED_CONSTRUCTOR_GETTER(JSWebSocket); WEBCORE_GENERATED_CONSTRUCTOR_SETTER(JSWebSocket); @@ -2419,6 +2424,15 @@ void GlobalObject::finishCreation(VM& vm) init.set(JSModuleNamespaceObject::createStructure(init.vm, init.owner, init.owner->objectPrototype())); }); + m_JSBufferSubclassStructure.initLater( + [](const Initializer<Structure>& init) { + auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(init.owner); + auto clientData = WebCore::clientData(init.vm); + + auto* baseStructure = globalObject->typedArrayStructure(JSC::TypeUint8, false); + JSC::Structure* subclassStructure = JSC::InternalFunction::createSubclassStructure(globalObject, globalObject->JSBufferConstructor(), baseStructure); + init.set(subclassStructure); + }); m_performMicrotaskFunction.initLater( [](const Initializer<JSFunction>& init) { init.set(JSFunction::create(init.vm, init.owner, 4, "performMicrotask"_s, jsFunctionPerformMicrotask, ImplementationVisibility::Public)); @@ -2596,6 +2610,16 @@ void GlobalObject::finishCreation(VM& vm) init.setConstructor(constructor); }); + m_JSBufferClassStructure.initLater( + [](LazyClassStructure::Initializer& init) { + auto prototype = WebCore::createBufferPrototype(init.vm, init.global); + auto* structure = WebCore::createBufferStructure(init.vm, init.global, JSValue(prototype)); + auto* constructor = WebCore::createBufferConstructor(init.vm, init.global, jsCast<JSObject*>(prototype)); + init.setPrototype(prototype); + init.setStructure(structure); + init.setConstructor(constructor); + }); + m_JSHTTPSResponseSinkClassStructure.initLater( [](LazyClassStructure::Initializer& init) { auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::HTTPSResponseSink); @@ -3087,7 +3111,9 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CloseEvent"_s), JSC::CustomGetterSetter::create(vm, JSCloseEvent_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - PUT_WEBCORE_GENERATED_CONSTRUCTOR("Buffer"_s, JSBuffer); + putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr), + JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + PUT_WEBCORE_GENERATED_CONSTRUCTOR("TextEncoder"_s, JSTextEncoder); PUT_WEBCORE_GENERATED_CONSTRUCTOR("MessageEvent"_s, JSMessageEvent); PUT_WEBCORE_GENERATED_CONSTRUCTOR("WebSocket"_s, JSWebSocket); @@ -3405,6 +3431,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_JSReadableStateClassStructure.visit(visitor); thisObject->m_JSStringDecoderClassStructure.visit(visitor); thisObject->m_NapiClassStructure.visit(visitor); + thisObject->m_JSBufferClassStructure.visit(visitor); thisObject->m_pendingVirtualModuleResultStructure.visit(visitor); thisObject->m_performMicrotaskFunction.visit(visitor); @@ -3424,6 +3451,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_JSHTTPResponseController.visit(visitor); thisObject->m_callSiteStructure.visit(visitor); thisObject->m_emitReadableNextTickFunction.visit(visitor); + thisObject->m_JSBufferSubclassStructure.visit(visitor); for (auto& barrier : thisObject->m_thenables) { visitor.append(barrier); |