aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/JSSink.cpp112
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h493
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp24
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.h3
-rw-r--r--src/bun.js/bindings/webcore/JSAbortSignal.cpp6
-rw-r--r--src/bun.js/bindings/webcore/ReadableStream.cpp18
6 files changed, 320 insertions, 336 deletions
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index 09163fb62..87cdae923 100644
--- a/src/bun.js/bindings/JSSink.cpp
+++ b/src/bun.js/bindings/JSSink.cpp
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2022-08-17T12:00:00.776Z
+// Generated by 'make generate-sink' at 2022-08-18T01:38:52.472Z
// To regenerate this file, run:
//
// make generate-sink
@@ -378,75 +378,70 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
/* Source for JSArrayBufferSinkPrototypeTableValues.lut.h
@begin JSArrayBufferSinkPrototypeTable
- close ArrayBufferSink__doClose ReadOnly|DontDelete|Function 0
- flush ArrayBufferSink__flush ReadOnly|DontDelete|Function 1
- end ArrayBufferSink__end ReadOnly|DontDelete|Function 0
- start ArrayBufferSink__start ReadOnly|DontDelete|Function 1
- write ArrayBufferSink__write ReadOnly|DontDelete|Function 1
-
+ close ArrayBufferSink__doClose ReadOnly|DontDelete|Function 0
+ flush ArrayBufferSink__flush ReadOnly|DontDelete|Function 1
+ end ArrayBufferSink__end ReadOnly|DontDelete|Function 0
+ start ArrayBufferSink__start ReadOnly|DontDelete|Function 1
+ write ArrayBufferSink__write ReadOnly|DontDelete|Function 1
@end
*/
/* Source for JSReadableArrayBufferSinkControllerPrototypeTableValues.lut.h
@begin JSReadableArrayBufferSinkControllerPrototypeTable
- close JSReadableArrayBufferSinkController__close ReadOnly|DontDelete|Function 0
- flush ArrayBufferSink__flush ReadOnly|DontDelete|Function 1
- end JSReadableArrayBufferSinkController__end ReadOnly|DontDelete|Function 0
- start ArrayBufferSink__start ReadOnly|DontDelete|Function 1
- write ArrayBufferSink__write ReadOnly|DontDelete|Function 1
+ close JSReadableArrayBufferSinkController__close ReadOnly|DontDelete|Function 0
+ flush ArrayBufferSink__flush ReadOnly|DontDelete|Function 1
+ end JSReadableArrayBufferSinkController__end ReadOnly|DontDelete|Function 0
+ start ArrayBufferSink__start ReadOnly|DontDelete|Function 1
+ write ArrayBufferSink__write ReadOnly|DontDelete|Function 1
@end
*/
/* Source for JSHTTPResponseSinkPrototypeTableValues.lut.h
@begin JSHTTPResponseSinkPrototypeTable
- close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0
- flush HTTPResponseSink__flush ReadOnly|DontDelete|Function 1
- end HTTPResponseSink__end ReadOnly|DontDelete|Function 0
- start HTTPResponseSink__start ReadOnly|DontDelete|Function 1
- write HTTPResponseSink__write ReadOnly|DontDelete|Function 1
-
+ close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0
+ flush HTTPResponseSink__flush ReadOnly|DontDelete|Function 1
+ end HTTPResponseSink__end ReadOnly|DontDelete|Function 0
+ start HTTPResponseSink__start ReadOnly|DontDelete|Function 1
+ write HTTPResponseSink__write ReadOnly|DontDelete|Function 1
@end
*/
/* Source for JSReadableHTTPResponseSinkControllerPrototypeTableValues.lut.h
@begin JSReadableHTTPResponseSinkControllerPrototypeTable
- close JSReadableHTTPResponseSinkController__close ReadOnly|DontDelete|Function 0
- flush HTTPResponseSink__flush ReadOnly|DontDelete|Function 1
- end JSReadableHTTPResponseSinkController__end ReadOnly|DontDelete|Function 0
- start HTTPResponseSink__start ReadOnly|DontDelete|Function 1
- write HTTPResponseSink__write ReadOnly|DontDelete|Function 1
+ close JSReadableHTTPResponseSinkController__close ReadOnly|DontDelete|Function 0
+ flush HTTPResponseSink__flush ReadOnly|DontDelete|Function 1
+ end JSReadableHTTPResponseSinkController__end ReadOnly|DontDelete|Function 0
+ start HTTPResponseSink__start ReadOnly|DontDelete|Function 1
+ write HTTPResponseSink__write ReadOnly|DontDelete|Function 1
@end
*/
/* Source for JSHTTPSResponseSinkPrototypeTableValues.lut.h
@begin JSHTTPSResponseSinkPrototypeTable
- close HTTPSResponseSink__doClose ReadOnly|DontDelete|Function 0
- flush HTTPSResponseSink__flush ReadOnly|DontDelete|Function 1
- end HTTPSResponseSink__end ReadOnly|DontDelete|Function 0
- start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1
- write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1
-
+ close HTTPSResponseSink__doClose ReadOnly|DontDelete|Function 0
+ flush HTTPSResponseSink__flush ReadOnly|DontDelete|Function 1
+ end HTTPSResponseSink__end ReadOnly|DontDelete|Function 0
+ start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1
+ write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1
@end
*/
/* Source for JSReadableHTTPSResponseSinkControllerPrototypeTableValues.lut.h
@begin JSReadableHTTPSResponseSinkControllerPrototypeTable
- close JSReadableHTTPSResponseSinkController__close ReadOnly|DontDelete|Function 0
- flush HTTPSResponseSink__flush ReadOnly|DontDelete|Function 1
- end JSReadableHTTPSResponseSinkController__end ReadOnly|DontDelete|Function 0
- start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1
- write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1
+ close JSReadableHTTPSResponseSinkController__close ReadOnly|DontDelete|Function 0
+ flush HTTPSResponseSink__flush ReadOnly|DontDelete|Function 1
+ end JSReadableHTTPSResponseSinkController__end ReadOnly|DontDelete|Function 0
+ start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1
+ write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1
@end
*/
-
-
#pragma mark - ArrayBufferSink
class JSArrayBufferSinkPrototype final : public JSC::JSNonFinalObject {
@@ -1284,24 +1279,11 @@ extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
- auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
- auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableArrayBufferSinkController>(vm, *globalObject);
WebCore::JSReadableArrayBufferSinkController *controller = WebCore::JSReadableArrayBufferSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
- auto callData = JSC::getCallData(function);
- JSC::MarkedArgumentBuffer arguments;
- arguments.append(JSC::JSValue::decode(stream));
- arguments.append(controller);
-
- auto result = JSC::call(arg0, function, callData, JSC::jsUndefined(), arguments);
- if (scope.exception())
- return JSC::JSValue::encode(scope.exception());
-
- return JSC::JSValue::encode(result);
+ return globalObject->assignToStream(JSC::JSValue::decode(stream), controller);
}
extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSValue amt, JSC__JSValue offset)
@@ -1387,24 +1369,11 @@ extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* ar
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
- auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
- auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPResponseSinkController>(vm, *globalObject);
WebCore::JSReadableHTTPResponseSinkController *controller = WebCore::JSReadableHTTPResponseSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
- auto callData = JSC::getCallData(function);
- JSC::MarkedArgumentBuffer arguments;
- arguments.append(JSC::JSValue::decode(stream));
- arguments.append(controller);
-
- auto result = JSC::call(arg0, function, callData, JSC::jsUndefined(), arguments);
- if (scope.exception())
- return JSC::JSValue::encode(scope.exception());
-
- return JSC::JSValue::encode(result);
+ return globalObject->assignToStream(JSC::JSValue::decode(stream), controller);
}
extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSValue amt, JSC__JSValue offset)
@@ -1490,24 +1459,11 @@ extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* a
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
- auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
- auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPSResponseSinkController>(vm, *globalObject);
WebCore::JSReadableHTTPSResponseSinkController *controller = WebCore::JSReadableHTTPSResponseSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
- auto callData = JSC::getCallData(function);
- JSC::MarkedArgumentBuffer arguments;
- arguments.append(JSC::JSValue::decode(stream));
- arguments.append(controller);
-
- auto result = JSC::call(arg0, function, callData, JSC::jsUndefined(), arguments);
- if (scope.exception())
- return JSC::JSValue::encode(scope.exception());
-
- return JSC::JSValue::encode(result);
+ return globalObject->assignToStream(JSC::JSValue::decode(stream), controller);
}
extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSValue amt, JSC__JSValue offset)
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index 655397493..74466d154 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -16,253 +16,256 @@ using namespace Zig;
using namespace JSC;
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);
-
- DECLARE_EXPORT_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<JSRequest, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForRequest.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequest = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForRequest.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForRequest = WTFMove(space); });
- }
-
- 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(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
-
- ~JSRequest();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSRequest, m_ctx); }
-
- void* m_ctx { nullptr };
-
- JSRequest(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
-
- DECLARE_VISIT_CHILDREN;
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
- mutable JSC::WriteBarrier<JSC::Unknown> m_url;
-};
+ public:
+ using Base = JSC::JSDestructibleObject;
+ static JSRequest* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_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<JSRequest, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForRequest.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequest = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForRequest.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForRequest = WTFMove(space); });
+ }
+
+ 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(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+
+ ~JSRequest();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSRequest, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+
+ JSRequest(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+
+ 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);
-};
+ 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 {
-public:
- using Base = JSC::JSDestructibleObject;
- static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_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<JSResponse, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForResponse.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponse = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForResponse.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForResponse = WTFMove(space); });
- }
-
- 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(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
-
- ~JSResponse();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSResponse, m_ctx); }
-
- void* m_ctx { nullptr };
-
- JSResponse(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
-
- DECLARE_VISIT_CHILDREN;
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
- mutable JSC::WriteBarrier<JSC::Unknown> m_statusText;
- mutable JSC::WriteBarrier<JSC::Unknown> m_url;
-};
+ public:
+ using Base = JSC::JSDestructibleObject;
+ static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_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<JSResponse, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForResponse.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponse = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForResponse.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForResponse = WTFMove(space); });
+ }
+
+ 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(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+
+ ~JSResponse();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSResponse, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+
+ JSResponse(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+
+ 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);
-};
+ 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);
+ };
}
+
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index b0eebfecd..5141ef866 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -1941,6 +1941,28 @@ static JSC_DEFINE_HOST_FUNCTION(functionSetImmediate,
return Bun__Timer__setTimeout(globalObject, JSC::JSValue::encode(job), JSC::JSValue::encode(jsNumber(0)));
}
+EncodedJSValue GlobalObject::assignToStream(JSValue stream, JSValue controller)
+{
+ JSC::VM& vm = this->vm();
+ JSC::JSFunction* function = this->m_assignToStream.get();
+ if (!function) {
+ function = JSFunction::create(vm, static_cast<JSC::FunctionExecutable*>(readableStreamInternalsAssignToStreamCodeGenerator(vm)), this);
+ this->m_assignToStream.set(vm, this, function);
+ }
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto callData = JSC::getCallData(function);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(stream);
+ arguments.append(controller);
+
+ auto result = JSC::call(this, function, callData, JSC::jsUndefined(), arguments);
+ if (scope.exception())
+ return JSC::JSValue::encode(scope.exception());
+
+ return JSC::JSValue::encode(result);
+}
+
void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
{
m_builtinInternalFunctions.initialize(*this);
@@ -2065,7 +2087,6 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectBuiltinFunction(vm, this, builtinNames.createNativeReadableStreamPrivateName(), readableStreamCreateNativeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
putDirectBuiltinFunction(vm, this, builtinNames.createEmptyReadableStreamPrivateName(), readableStreamCreateEmptyReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
putDirectBuiltinFunction(vm, this, builtinNames.consumeReadableStreamPrivateName(), readableStreamConsumeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
- putDirectBuiltinFunction(vm, this, builtinNames.assignToStreamPrivateName(), readableStreamInternalsAssignToStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
putDirectBuiltinFunction(vm, this, builtinNames.createNativeReadableStreamPrivateName(), readableStreamCreateNativeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
// putDirectBuiltinFunction(vm, this, builtinNames.loadModulePrivateName(), jsZigGlobalObjectInternalsLoadModuleCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
@@ -2363,6 +2384,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
visitor.append(thisObject->m_readableStreamToJSON);
visitor.append(thisObject->m_readableStreamToBlob);
visitor.append(thisObject->m_readableStreamToArrayBuffer);
+ visitor.append(thisObject->m_assignToStream);
ScriptExecutionContext* context = thisObject->scriptExecutionContext();
visitor.addOpaqueRoot(context);
diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h
index 9d71b91ac..8bdd3fafe 100644
--- a/src/bun.js/bindings/ZigGlobalObject.h
+++ b/src/bun.js/bindings/ZigGlobalObject.h
@@ -211,11 +211,14 @@ public:
void* bunVM() { return m_bunVM; }
bool isThreadLocalDefaultGlobalObject = false;
+ EncodedJSValue assignToStream(JSValue stream, JSValue controller);
+
mutable WriteBarrier<JSFunction> m_readableStreamToArrayBufferResolve;
mutable WriteBarrier<JSFunction> m_readableStreamToText;
mutable WriteBarrier<JSFunction> m_readableStreamToBlob;
mutable WriteBarrier<JSFunction> m_readableStreamToJSON;
mutable WriteBarrier<JSFunction> m_readableStreamToArrayBuffer;
+ mutable WriteBarrier<JSFunction> m_assignToStream;
void trackFFIFunction(JSC::JSFunction* function)
{
diff --git a/src/bun.js/bindings/webcore/JSAbortSignal.cpp b/src/bun.js/bindings/webcore/JSAbortSignal.cpp
index 2aa0c0dcc..9f4526cf7 100644
--- a/src/bun.js/bindings/webcore/JSAbortSignal.cpp
+++ b/src/bun.js/bindings/webcore/JSAbortSignal.cpp
@@ -129,12 +129,6 @@ template<> void JSAbortSignalDOMConstructor::initializeProperties(VM& vm, JSDOMG
putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
putDirect(vm, vm.propertyNames->prototype, JSAbortSignal::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
reifyStaticProperties(vm, JSAbortSignal::info(), JSAbortSignalConstructorTableValues, *this);
- if (!(jsCast<JSDOMGlobalObject*>(&globalObject)->scriptExecutionContext()->isDocument() || jsCast<JSDOMGlobalObject*>(&globalObject)->scriptExecutionContext()->isWorkerGlobalScope())) {
- auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("timeout"), strlen("timeout"));
- VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- DeletePropertySlot slot;
- JSObject::deleteProperty(this, &globalObject, propertyName, slot);
- }
}
/* Hash table for prototype */
diff --git a/src/bun.js/bindings/webcore/ReadableStream.cpp b/src/bun.js/bindings/webcore/ReadableStream.cpp
index 0a85942b9..16658638b 100644
--- a/src/bun.js/bindings/webcore/ReadableStream.cpp
+++ b/src/bun.js/bindings/webcore/ReadableStream.cpp
@@ -197,24 +197,30 @@ static inline bool checkReadableStream(JSDOMGlobalObject& globalObject, JSReadab
bool ReadableStream::isLocked() const
{
- return checkReadableStream(*globalObject(), readableStream(), globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get());
+ auto clientData = WebCore::clientData(m_globalObject->vm());
+ auto& privateName = clientData->builtinNames().readerPrivateName();
+ return readableStream()->getDirect(m_globalObject->vm(), privateName).isTrue();
}
bool ReadableStream::isLocked(JSGlobalObject* globalObject, JSReadableStream* readableStream)
{
- auto* dom = reinterpret_cast<JSDOMGlobalObject*>(globalObject);
- return checkReadableStream(*dom, readableStream, dom->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get());
+ auto clientData = WebCore::clientData(globalObject->vm());
+ auto& privateName = clientData->builtinNames().readerPrivateName();
+ return readableStream->getDirect(globalObject->vm(), privateName).isTrue();
}
bool ReadableStream::isDisturbed(JSGlobalObject* globalObject, JSReadableStream* readableStream)
{
- auto* dom = reinterpret_cast<JSDOMGlobalObject*>(globalObject);
- return checkReadableStream(*dom, readableStream, dom->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamDisturbedFunction.get());
+ auto clientData = WebCore::clientData(globalObject->vm());
+ auto& privateName = clientData->builtinNames().disturbedPrivateName();
+ return readableStream->getDirect(globalObject->vm(), privateName).isTrue();
}
bool ReadableStream::isDisturbed() const
{
- return checkReadableStream(*globalObject(), readableStream(), globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamDisturbedFunction.get());
+ auto clientData = WebCore::clientData(globalObject()->vm());
+ auto& privateName = clientData->builtinNames().disturbedPrivateName();
+ return readableStream()->getDirect(globalObject()->vm(), privateName).isTrue();
}
}