aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/scripts/generate-jssink.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/scripts/generate-jssink.js')
-rw-r--r--src/bun.js/scripts/generate-jssink.js40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/bun.js/scripts/generate-jssink.js b/src/bun.js/scripts/generate-jssink.js
index 715df1f82..dc8a117b3 100644
--- a/src/bun.js/scripts/generate-jssink.js
+++ b/src/bun.js/scripts/generate-jssink.js
@@ -149,14 +149,14 @@ function header() {
void* wrapped() const { return m_sinkPtr; }
void detach();
- void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose);
+ void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose);
DECLARE_VISIT_CHILDREN;
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
void* m_sinkPtr;
- mutable WriteBarrier<JSC::JSFunction> m_onPull;
- mutable WriteBarrier<JSC::JSFunction> m_onClose;
+ mutable WriteBarrier<JSC::Unknown> m_onPull;
+ mutable WriteBarrier<JSC::Unknown> m_onClose;
mutable JSC::Weak<JSObject> m_weakReadableStream;
${controller}(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
@@ -175,7 +175,7 @@ JSC_DECLARE_CUSTOM_GETTER(function${name}__getter);
const outer = `
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at ${new Date().toISOString()}
+// Generated by 'make generate-sink'
//
#pragma once
@@ -211,7 +211,7 @@ Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* glo
async function implementation() {
const head = `
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at ${new Date().toISOString()}
+// Generated by 'make generate-sink'
// To regenerate this file, run:
//
// make generate-sink
@@ -221,6 +221,7 @@ async function implementation() {
#include "BunClientData.h"
#include "JSSink.h"
+#include "AsyncContextFrame.h"
#include "ActiveDOMObject.h"
#include "ExtendedDOMClientIsoSubspaces.h"
@@ -285,6 +286,8 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
JSC::JSValue readableStream = callFrame->argument(0);
JSC::JSValue onPull = callFrame->argument(1);
JSC::JSValue onClose = callFrame->argument(2);
+ JSC::JSValue asyncContext = callFrame->argument(3);
+
if (!readableStream.isObject()) {
scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ReadableStream"_s));
return JSC::JSValue::encode(JSC::jsUndefined());
@@ -292,15 +295,16 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
if (!onPull.isObject() || !onPull.isCallable()) {
onPull = JSC::jsUndefined();
+ } else if (!asyncContext.isUndefined()) {
+ onPull = AsyncContextFrame::create(globalObject, onPull, asyncContext);
}
if (!onClose.isObject() || !onClose.isCallable()) {
onClose = JSC::jsUndefined();
+ } else if (!asyncContext.isUndefined()) {
+ onClose = AsyncContextFrame::create(globalObject, onClose, asyncContext);
}
- JSC::JSFunction *onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull);
- JSC::JSFunction *onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose);
-
`;
var templ = head;
@@ -318,7 +322,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
return JSC::JSValue::encode(JSC::jsUndefined());
}
- ${name}Controller->start(globalObject, readableStream, onPullFunction, onCloseFunction);
+ ${name}Controller->start(globalObject, readableStream, onPull, onClose);
}
`;
isFirst = false;
@@ -771,7 +775,7 @@ void ${className}::visitChildrenImpl(JSCell* cell, Visitor& visitor)
DEFINE_VISIT_CHILDREN(${className});
-void ${controller}::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) {
+void ${controller}::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue 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);
@@ -901,18 +905,17 @@ extern "C" void ${name}__onReady(JSC__JSValue controllerValue, JSC__JSValue amt,
{
WebCore::${controller}* controller = JSC::jsCast<WebCore::${controller}*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onPull.get();
- if (function == nullptr)
+ JSC::JSValue function = controller->m_onPull.get();
+ if (!function)
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);
+ AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments);
}
extern "C" void ${name}__onStart(JSC__JSValue controllerValue)
@@ -924,20 +927,19 @@ extern "C" void ${name}__onClose(JSC__JSValue controllerValue, JSC__JSValue reas
{
WebCore::${controller}* controller = JSC::jsCast<WebCore::${controller}*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onClose.get();
- if (function == nullptr)
+ JSC::JSValue function = controller->m_onClose.get();
+ if (!function)
return;
// only call close once
controller->m_onClose.clear();
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ 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);
+ AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments);
}
`;