aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigGlobalObject.h
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-08-27 23:46:05 -0700
committerGravatar GitHub <noreply@github.com> 2022-08-27 23:46:05 -0700
commitaf5c4dedca550a856486ec8bbc9f6da76396496e (patch)
tree618a42aed0eb46e9a726fc58731358b3bb7cbc27 /src/bun.js/bindings/ZigGlobalObject.h
parent8b3afa5831b7ac5fcabb47138c67d60e86247cd3 (diff)
downloadbun-af5c4dedca550a856486ec8bbc9f6da76396496e.tar.gz
bun-af5c4dedca550a856486ec8bbc9f6da76396496e.tar.zst
bun-af5c4dedca550a856486ec8bbc9f6da76396496e.zip
Update WebKit (#1165)
* Update WebKit * Fix `DataView` and non-8 bit sized typed arrays with TextDecoder * New WebKit Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.h')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h
index 8bdd3fafe..53935a0ae 100644
--- a/src/bun.js/bindings/ZigGlobalObject.h
+++ b/src/bun.js/bindings/ZigGlobalObject.h
@@ -213,12 +213,86 @@ public:
EncodedJSValue assignToStream(JSValue stream, JSValue controller);
+ enum class PromiseFunctions : uint8_t {
+ Bun__HTTPRequestContext__onReject,
+ Bun__HTTPRequestContext__onRejectStream,
+ Bun__HTTPRequestContext__onResolve,
+ Bun__HTTPRequestContext__onResolveStream,
+ Bun__HTTPRequestContextTLS__onReject,
+ Bun__HTTPRequestContextTLS__onRejectStream,
+ Bun__HTTPRequestContextTLS__onResolve,
+ Bun__HTTPRequestContextTLS__onResolveStream,
+ Bun__HTTPRequestContextDebug__onReject,
+ Bun__HTTPRequestContextDebug__onRejectStream,
+ Bun__HTTPRequestContextDebug__onResolve,
+ Bun__HTTPRequestContextDebug__onResolveStream,
+ Bun__HTTPRequestContextDebugTLS__onReject,
+ Bun__HTTPRequestContextDebugTLS__onRejectStream,
+ Bun__HTTPRequestContextDebugTLS__onResolve,
+ Bun__HTTPRequestContextDebugTLS__onResolveStream,
+
+ };
+
+ static PromiseFunctions promiseHandlerID(EncodedJSValue (*handler)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1))
+ {
+ if (handler == Bun__HTTPRequestContext__onReject) {
+ return PromiseFunctions::Bun__HTTPRequestContext__onReject;
+ } else if (handler == Bun__HTTPRequestContext__onRejectStream) {
+ return PromiseFunctions::Bun__HTTPRequestContext__onRejectStream;
+ } else if (handler == Bun__HTTPRequestContext__onResolve) {
+ return PromiseFunctions::Bun__HTTPRequestContext__onResolve;
+ } else if (handler == Bun__HTTPRequestContext__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContext__onResolveStream;
+ } else if (handler == Bun__HTTPRequestContextTLS__onReject) {
+ return PromiseFunctions::Bun__HTTPRequestContextTLS__onReject;
+ } else if (handler == Bun__HTTPRequestContextTLS__onRejectStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextTLS__onRejectStream;
+ } else if (handler == Bun__HTTPRequestContextTLS__onResolve) {
+ return PromiseFunctions::Bun__HTTPRequestContextTLS__onResolve;
+ } else if (handler == Bun__HTTPRequestContextTLS__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextTLS__onResolveStream;
+ } else if (handler == Bun__HTTPRequestContextDebug__onReject) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebug__onReject;
+ } else if (handler == Bun__HTTPRequestContextDebug__onRejectStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebug__onRejectStream;
+ } else if (handler == Bun__HTTPRequestContextDebug__onResolve) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebug__onResolve;
+ } else if (handler == Bun__HTTPRequestContextDebug__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebug__onResolveStream;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onReject) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onReject;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onRejectStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onRejectStream;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onResolve) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolve;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolveStream;
+ } else {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ }
+
+ JSFunction* thenable(EncodedJSValue (*handler)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1))
+ {
+ auto& barrier = this->m_thenables[static_cast<size_t>(GlobalObject::promiseHandlerID(handler))];
+ if (JSFunction* func = barrier.get()) {
+ return func;
+ }
+
+ JSFunction* func = JSC::JSFunction::create(vm(), this, 2,
+ String(), handler, ImplementationVisibility::Public);
+
+ barrier.set(vm(), this, func);
+ return func;
+ }
+
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;
+ mutable WriteBarrier<JSFunction> m_thenables[16];
void trackFFIFunction(JSC::JSFunction* function)
{