aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/JSSink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/JSSink.cpp')
-rw-r--r--src/bun.js/bindings/JSSink.cpp463
1 files changed, 462 insertions, 1 deletions
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index fbb8b56fb..47bb2cac3 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-27T22:18:48.797Z
+// Generated by 'make generate-sink' at 2022-09-23T02:14:49.416Z
// To regenerate this file, run:
//
// make generate-sink
@@ -101,6 +101,16 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
}
+ else if (WebCore::JSReadableFileSinkController* FileSinkController = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(callFrame->thisValue())) {
+ if (FileSinkController->wrapped() == nullptr) {
+ scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s));
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ FileSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction);
+ }
+
+
else if (WebCore::JSReadableHTTPResponseSinkController* HTTPResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(callFrame->thisValue())) {
if (HTTPResponseSinkController->wrapped() == nullptr) {
scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s));
@@ -210,6 +220,88 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica
+JSC_DEFINE_CUSTOM_GETTER(functionFileSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+
+ return JSC::JSValue::encode(globalObject->FileSink());
+}
+
+
+JSC_DECLARE_HOST_FUNCTION(JSReadableFileSinkController__close);
+JSC_DEFINE_HOST_FUNCTION(JSReadableFileSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+{
+
+ auto& vm = lexicalGlobalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ WebCore::JSReadableFileSinkController* controller = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(callFrame->thisValue());
+ if (!controller) {
+ scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected JSReadableFileSinkController"_s));
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ void *ptr = controller->wrapped();
+ if (ptr == nullptr) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ controller->detach();
+ FileSink__close(lexicalGlobalObject, ptr);
+ // Release the controller right before close.
+ controller->m_hasPendingActivity = false;
+ return JSC::JSValue::encode(JSC::jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(JSReadableFileSinkController__end);
+JSC_DEFINE_HOST_FUNCTION(JSReadableFileSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+{
+
+ auto& vm = lexicalGlobalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ WebCore::JSReadableFileSinkController* controller = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(callFrame->thisValue());
+ if (!controller) {
+ scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected JSReadableFileSinkController"_s));
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ void *ptr = controller->wrapped();
+ if (ptr == nullptr) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ controller->detach();
+ return FileSink__endWithSink(ptr, lexicalGlobalObject);
+}
+
+
+JSC_DECLARE_HOST_FUNCTION(FileSink__doClose);
+JSC_DEFINE_HOST_FUNCTION(FileSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+{
+
+ auto& vm = lexicalGlobalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ WebCore::JSFileSink* sink = JSC::jsDynamicCast<WebCore::JSFileSink*>(callFrame->thisValue());
+ if (!sink) {
+ scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected FileSink"_s));
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ void *ptr = sink->wrapped();
+ if (ptr == nullptr) {
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ }
+
+ sink->detach();
+ FileSink__close(lexicalGlobalObject, ptr);
+ return JSC::JSValue::encode(JSC::jsUndefined());
+}
+
+
+
JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
{
auto& vm = lexicalGlobalObject->vm();
@@ -398,6 +490,28 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
*/
+/* Source for JSFileSinkPrototypeTableValues.lut.h
+@begin JSFileSinkPrototypeTable
+ close FileSink__doClose ReadOnly|DontDelete|Function 0
+ flush FileSink__flush ReadOnly|DontDelete|Function 1
+ end FileSink__end ReadOnly|DontDelete|Function 0
+ start FileSink__start ReadOnly|DontDelete|Function 1
+ write FileSink__write ReadOnly|DontDelete|Function 1
+@end
+*/
+
+
+/* Source for JSReadableFileSinkControllerPrototypeTableValues.lut.h
+@begin JSReadableFileSinkControllerPrototypeTable
+ close JSReadableFileSinkController__close ReadOnly|DontDelete|Function 0
+ flush FileSink__flush ReadOnly|DontDelete|Function 1
+ end JSReadableFileSinkController__end ReadOnly|DontDelete|Function 0
+ start FileSink__start ReadOnly|DontDelete|Function 1
+ write FileSink__write ReadOnly|DontDelete|Function 1
+@end
+*/
+
+
/* Source for JSHTTPResponseSinkPrototypeTableValues.lut.h
@begin JSHTTPResponseSinkPrototypeTable
close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0
@@ -688,6 +802,252 @@ void JSReadableArrayBufferSinkController::destroy(JSCell* cell)
+#pragma mark - FileSink
+
+class JSFileSinkPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSFileSinkPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSFileSinkPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileSinkPrototype>(vm)) JSFileSinkPrototype(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:
+ JSFileSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFileSinkPrototype, JSFileSinkPrototype::Base);
+
+class JSReadableFileSinkControllerPrototype final : public JSC::JSNonFinalObject {
+ public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSReadableFileSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableFileSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableFileSinkControllerPrototype>(vm)) JSReadableFileSinkControllerPrototype(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:
+ JSReadableFileSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+ };
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableFileSinkControllerPrototype, JSReadableFileSinkControllerPrototype::Base);
+
+const ClassInfo JSFileSinkPrototype::s_info = { "FileSink"_s, &Base::s_info, &JSFileSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSFileSinkPrototype) };
+const ClassInfo JSFileSink::s_info = { "FileSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSink) };
+const ClassInfo JSFileSinkConstructor::s_info = { "FileSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSinkConstructor) };
+
+
+const ClassInfo JSReadableFileSinkControllerPrototype::s_info = { "ReadableFileSinkController"_s, &Base::s_info, &JSReadableFileSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableFileSinkControllerPrototype) };
+const ClassInfo JSReadableFileSinkController::s_info = { "ReadableFileSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableFileSinkController) };
+
+JSFileSink::~JSFileSink()
+{
+ if (m_sinkPtr) {
+ FileSink__finalize(m_sinkPtr);
+ }
+}
+
+
+JSReadableFileSinkController::~JSReadableFileSinkController()
+{
+ if (m_sinkPtr) {
+ FileSink__finalize(m_sinkPtr);
+ }
+}
+
+JSObject* JSFileSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSFileSinkPrototype::create(vm, &globalObject, JSFileSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableFileSinkController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableFileSinkControllerPrototype::create(vm, &globalObject, JSReadableFileSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+void JSReadableFileSinkController::detach() {
+ m_sinkPtr = nullptr;
+ m_onPull.clear();
+
+ auto readableStream = m_weakReadableStream.get();
+ auto onClose = m_onClose.get();
+ m_onClose.clear();
+
+ if (readableStream && onClose) {
+ JSC::JSGlobalObject *globalObject = this->globalObject();
+ auto callData = JSC::getCallData(onClose);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ arguments.append(jsUndefined());
+ JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments);
+ }
+
+ m_weakReadableStream.clear();
+}
+
+
+JSFileSinkConstructor* JSFileSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype)
+{
+ JSFileSinkConstructor* ptr = new (NotNull, JSC::allocateCell<JSFileSinkConstructor>(vm)) JSFileSinkConstructor(vm, structure, FileSink__construct);
+ ptr->finishCreation(vm, globalObject, prototype);
+ return ptr;
+}
+
+JSFileSink* JSFileSink::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr)
+{
+ JSFileSink* ptr = new (NotNull, JSC::allocateCell<JSFileSink>(vm)) JSFileSink(vm, structure, sinkPtr);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+JSReadableFileSinkController* JSReadableFileSinkController::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr)
+{
+ JSReadableFileSinkController* ptr = new (NotNull, JSC::allocateCell<JSReadableFileSinkController>(vm)) JSReadableFileSinkController(vm, structure, sinkPtr);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+void JSFileSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+ initializeProperties(vm, globalObject, prototype);
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSFileSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) {
+ return FileSink__construct(globalObject, callFrame);
+}
+
+
+void JSFileSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "FileSink"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+}
+
+void JSFileSinkPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSFileSink::info(), JSFileSinkPrototypeTableValues, *this);
+ putDirect(vm, JSC::Identifier::fromString(vm, "sinkId"_s), JSC::jsNumber(JSFileSink::Sink), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSReadableFileSinkControllerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableFileSinkController::info(), JSReadableFileSinkControllerPrototypeTableValues, *this);
+ putDirect(vm, JSC::Identifier::fromString(vm, "sinkId"_s), JSC::jsNumber(JSFileSink::Sink), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSFileSink::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+void JSReadableFileSinkController::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+
+void JSFileSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSFileSink*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ analyzer.setWrappedObjectForCell(cell, wrapped);
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+void JSReadableFileSinkController::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSReadableFileSinkController*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ analyzer.setWrappedObjectForCell(cell, wrapped);
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+
+template<typename Visitor>
+void JSReadableFileSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSReadableFileSinkController* thisObject = jsCast<JSReadableFileSinkController*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_onPull);
+ visitor.append(thisObject->m_onClose);
+ visitor.append(thisObject->m_weakReadableStream);
+}
+
+DEFINE_VISIT_CHILDREN(JSReadableFileSinkController);
+
+
+void JSReadableFileSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) {
+ this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject());
+ this->m_onPull.set(globalObject->vm(), this, onPull);
+ this->m_onClose.set(globalObject->vm(), this, onClose);
+}
+
+void JSFileSink::destroy(JSCell* cell)
+{
+ static_cast<JSFileSink*>(cell)->JSFileSink::~JSFileSink();
+}
+
+
+void JSReadableFileSinkController::destroy(JSCell* cell)
+{
+ static_cast<JSReadableFileSinkController*>(cell)->JSReadableFileSinkController::~JSReadableFileSinkController();
+}
+
+
+
#pragma mark - HTTPResponseSink
class JSHTTPResponseSinkPrototype final : public JSC::JSNonFinalObject {
@@ -1187,6 +1547,9 @@ void JSReadableHTTPSResponseSinkController::destroy(JSCell* cell)
case ArrayBufferSink:
return JSArrayBufferSinkPrototype::create(vm, globalObject, JSArrayBufferSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+ case FileSink:
+ return JSFileSinkPrototype::create(vm, globalObject, JSFileSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+
case HTTPResponseSink:
return JSHTTPResponseSinkPrototype::create(vm, globalObject, JSHTTPResponseSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
@@ -1204,6 +1567,9 @@ JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* glob
case ArrayBufferSink:
return JSReadableArrayBufferSinkControllerPrototype::create(vm, globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+ case FileSink:
+ return JSReadableFileSinkControllerPrototype::create(vm, globalObject, JSReadableFileSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+
case HTTPResponseSink:
return JSReadableHTTPResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
@@ -1223,6 +1589,11 @@ Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* glo
return JSReadableArrayBufferSinkController::createStructure(vm, globalObject, prototype);
}
+ case FileSink: {
+ auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID);
+ return JSReadableFileSinkController::createStructure(vm, globalObject, prototype);
+ }
+
case HTTPResponseSink: {
auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID);
return JSReadableHTTPResponseSinkController::createStructure(vm, globalObject, prototype);
@@ -1330,6 +1701,96 @@ extern "C" void ArrayBufferSink__onClose(JSC__JSValue controllerValue, JSC__JSVa
}
+extern "C" JSC__JSValue FileSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr)
+{
+ auto& vm = arg0->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
+ JSC::JSValue prototype = globalObject->FileSinkPrototype();
+ JSC::Structure* structure = WebCore::JSFileSink::createStructure(vm, globalObject, prototype);
+ return JSC::JSValue::encode(WebCore::JSFileSink::create(vm, globalObject, structure, sinkPtr));
+}
+
+extern "C" void* FileSink__fromJS(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1)
+{
+ JSC::VM& vm = WebCore::getVM(arg0);
+ if (auto* sink = JSC::jsDynamicCast<WebCore::JSFileSink*>(JSC::JSValue::decode(JSValue1)))
+ return sink->wrapped();
+
+ if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(JSValue1)))
+ return controller->wrapped();
+
+ return nullptr;
+}
+
+extern "C" void FileSink__detachPtr(JSC__JSValue JSValue0)
+{
+ if (auto* sink = JSC::jsDynamicCast<WebCore::JSFileSink*>(JSC::JSValue::decode(JSValue0))) {
+ sink->detach();
+ return;
+ }
+
+
+ if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(JSValue0))) {
+ controller->detach();
+ return;
+ }
+}
+
+extern "C" JSC__JSValue FileSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue)
+{
+ auto& vm = arg0->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
+
+ JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableFileSinkController>(vm, *globalObject);
+ WebCore::JSReadableFileSinkController *controller = WebCore::JSReadableFileSinkController::create(vm, globalObject, structure, sinkPtr);
+ *controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
+ return globalObject->assignToStream(JSC::JSValue::decode(stream), controller);
+}
+
+extern "C" void FileSink__onReady(JSC__JSValue controllerValue, JSC__JSValue amt, JSC__JSValue offset)
+{
+ WebCore::JSReadableFileSinkController* controller = JSC::jsCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
+
+ JSC::JSFunction *function = controller->m_onPull.get();
+ if (function == nullptr)
+ return;
+ JSC::JSGlobalObject *globalObject = controller->globalObject();
+
+ auto callData = JSC::getCallData(function);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(controller);
+ arguments.append(JSC::JSValue::decode(amt));
+ arguments.append(JSC::JSValue::decode(offset));
+
+ JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
+}
+
+extern "C" void FileSink__onStart(JSC__JSValue controllerValue)
+{
+
+}
+
+extern "C" void FileSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason)
+{
+ WebCore::JSReadableFileSinkController* controller = JSC::jsCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
+
+ JSC::JSFunction *function = controller->m_onClose.get();
+ if (function == nullptr)
+ return;
+ // only call close once
+ controller->m_onClose.clear();
+ JSC::JSGlobalObject *globalObject = controller->globalObject();
+
+ auto callData = JSC::getCallData(function);
+ JSC::MarkedArgumentBuffer arguments;
+ auto readableStream = controller->m_weakReadableStream.get();
+ arguments.append(readableStream ? readableStream : JSC::jsUndefined());
+
+ arguments.append(JSC::JSValue::decode(reason));
+ JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
+}
+
+
extern "C" JSC__JSValue HTTPResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr)
{
auto& vm = arg0->vm();