Fix more errors

This commit is contained in:
Jarred Sumner
2024-12-19 05:07:18 -08:00
parent c2b9ea21e2
commit be1631d28b
2 changed files with 22 additions and 6 deletions

View File

@@ -10,7 +10,12 @@
#include "BunReadableStreamDefaultReader.h"
#include "DOMIsoSubspaces.h"
#include "BunClientData.h"
#include "BunStreamStructures.h"
#include "DOMClientIsoSubspaces.h"
#include <JavaScriptCore/LazyPropertyInlines.h>
#include <JavaScriptCore/JSPromise.h>
#include "BunStreamInlines.h"
namespace Bun {
using namespace JSC;
@@ -167,7 +172,7 @@ private:
}
};
JSReadableStreamDefaultController* JSReadableStreamDefaultController::create(VM& vm, Structure* structure, JSReadableStream* stream)
JSReadableStreamDefaultController* JSReadableStreamDefaultController::create(VM& vm, JSGlobalObject* globalObject, Structure* structure, JSReadableStream* stream)
{
JSReadableStreamDefaultController* controller = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultController>(vm)) JSReadableStreamDefaultController(vm, structure);
controller->finishCreation(vm, stream);
@@ -241,7 +246,7 @@ JSValue JSReadableStreamDefaultController::enqueue(JSGlobalObject* globalObject,
}
// Enqueue the chunk
JSArray* queue = m_queue.get(this);
JSArray* queue = m_queue.getInitializedOnMainThread(globalObject);
scope.release();
queue->push(globalObject, chunk);
@@ -369,7 +374,7 @@ void JSReadableStreamDefaultController::callPullIfNeeded(JSGlobalObject* globalO
// Handle the promise returned by pull
if (JSPromise* promise = jsDynamicCast<JSPromise*>(result)) {
Bun::performPromiseThen(globalObject, promise, jsReadableStreamDefaultControllerFullfillPull, jsReadableStreamDefaultControllerRejectPull, this);
Bun::then(globalObject, promise, jsReadableStreamDefaultControllerFullfillPull, jsReadableStreamDefaultControllerRejectPull, this);
} else {
// Not a promise, just mark pulling as done
m_pulling = false;
@@ -405,6 +410,12 @@ bool JSReadableStreamDefaultController::shouldCallPull() const
return true;
}
void JSReadableStreamDefaultController::finishCreation(VM& vm, JSReadableStream* stream)
{
Base::finishCreation(vm);
m_stream.set(vm, this, stream);
}
const ClassInfo JSReadableStreamDefaultControllerConstructor::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerConstructor) };
const ClassInfo JSReadableStreamDefaultControllerPrototype::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerPrototype) };
const ClassInfo JSReadableStreamDefaultController::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultController) };

View File

@@ -15,12 +15,17 @@ public:
using Base = JSC::JSDestructibleObject;
static constexpr bool needsDestruction = true;
static JSReadableStreamDefaultController* create(JSC::VM&, JSC::JSGlobalObject*, JSC::Structure*);
static JSReadableStreamDefaultController* create(JSC::VM&, JSC::JSGlobalObject*, JSC::Structure*, JSReadableStream*);
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);
template<typename CellType, JSC::SubspaceAccess mode>
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm);
DECLARE_INFO;
void attach(JSReadableStream* stream);
@@ -58,11 +63,11 @@ public:
private:
JSReadableStreamDefaultController(JSC::VM&, JSC::Structure*);
~JSReadableStreamDefaultController();
void finishCreation(JSC::VM&);
void finishCreation(JSC::VM&, JSReadableStream*);
// Internal slots
JSC::WriteBarrier<JSReadableStream> m_stream;
JSC::WriteBarrier<JSC::JSArray> m_queue;
JSC::LazyProperty<JSObject, JSC::JSArray> m_queue;
JSC::WriteBarrier<JSC::JSObject> m_pullAlgorithm;
JSC::WriteBarrier<JSC::JSObject> m_cancelAlgorithm;
JSC::WriteBarrier<JSC::JSObject> m_strategySizeAlgorithm;